diff options
Diffstat (limited to 'features/support')
-rw-r--r-- | features/support/factories/blog_categories.rb | 4 | ||||
-rw-r--r-- | features/support/factories/blog_comments.rb | 10 | ||||
-rw-r--r-- | features/support/factories/blog_posts.rb | 4 | ||||
-rw-r--r-- | features/support/paths.rb | 24 |
4 files changed, 42 insertions, 0 deletions
diff --git a/features/support/factories/blog_categories.rb b/features/support/factories/blog_categories.rb new file mode 100644 index 0000000..be28d88 --- /dev/null +++ b/features/support/factories/blog_categories.rb @@ -0,0 +1,4 @@ +Factory.define(:blog_category) do |f| + f.title "Shopping" + f.posts {|p| [p.association(:post)]} +end
\ No newline at end of file diff --git a/features/support/factories/blog_comments.rb b/features/support/factories/blog_comments.rb new file mode 100644 index 0000000..93beaf3 --- /dev/null +++ b/features/support/factories/blog_comments.rb @@ -0,0 +1,10 @@ +Factory.sequence :email do |n| + "person#{n}@example.com" +end + +Factory.define(:blog_comment) do |f| + f.name "Joe Commenter" + f.email { Factory.next(:email) } + f.body "Which one is the best for picking up new shoes?" + f.association :post +end
\ No newline at end of file diff --git a/features/support/factories/blog_posts.rb b/features/support/factories/blog_posts.rb new file mode 100644 index 0000000..6947e81 --- /dev/null +++ b/features/support/factories/blog_posts.rb @@ -0,0 +1,4 @@ +Factory.define(:post, :class => BlogPost) do |f| + f.title "Top Ten Shopping Centers in Chicago" + f.body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it." +end
\ No newline at end of file diff --git a/features/support/paths.rb b/features/support/paths.rb new file mode 100644 index 0000000..dbd04dd --- /dev/null +++ b/features/support/paths.rb @@ -0,0 +1,24 @@ +module NavigationHelpers + module Refinery + module Blog + def path_to(page_name) + case page_name + when /the list of blog posts/ + admin_blog_posts_path + when /the new blog posts? form/ + new_admin_blog_post_path + else + begin + if page_name =~ /the blog post titled "?([^\"]*)"?/ and (page = BlogPost.find_by_title($1)).present? + self.url_for(page.url) + else + nil + end + rescue + nil + end + end + end + end + end +end |