aboutsummaryrefslogtreecommitdiffstats
path: root/features
diff options
context:
space:
mode:
Diffstat (limited to 'features')
-rw-r--r--features/authors.feature15
-rw-r--r--features/support/factories/blog_posts.rb1
-rw-r--r--features/support/step_definitions/authors_steps.rb7
-rw-r--r--features/support/step_definitions/tags_steps.rb11
-rw-r--r--features/tags.feature26
5 files changed, 60 insertions, 0 deletions
diff --git a/features/authors.feature b/features/authors.feature
new file mode 100644
index 0000000..1042c9f
--- /dev/null
+++ b/features/authors.feature
@@ -0,0 +1,15 @@
+@blog
+Feature: Blog Post Authors
+ Blog posts can be assigned authors through the given user model
+ current_user is assumed through admin screens
+
+ Scenario: Saving a blog post in blog_posts#new associates the current_user as the author
+ Given I am a logged in refinery user
+
+ When I am on the new blog post form
+ And I fill in "Title" with "This is my blog post"
+ And I fill in "Body" with "And I love it"
+ And I press "Save"
+
+ Then there should be 1 blog post
+ And the blog post should belong to me \ No newline at end of file
diff --git a/features/support/factories/blog_posts.rb b/features/support/factories/blog_posts.rb
index 24436b8..3eecf53 100644
--- a/features/support/factories/blog_posts.rb
+++ b/features/support/factories/blog_posts.rb
@@ -2,5 +2,6 @@ Factory.define(:post, :class => BlogPost) do |f|
f.sequence(:title) { |n| "Top #{n} 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."
f.draft false
+ f.tag_list "chicago, shopping, fun times"
f.published_at Time.now
end
diff --git a/features/support/step_definitions/authors_steps.rb b/features/support/step_definitions/authors_steps.rb
new file mode 100644
index 0000000..d78ca90
--- /dev/null
+++ b/features/support/step_definitions/authors_steps.rb
@@ -0,0 +1,7 @@
+Then /^there should be (\d+) blog posts?$/ do |num|
+ BlogPost.all.size == num
+end
+
+Then /^the blog post should belong to me$/ do
+ BlogPost.first.author.login == User.last.login
+end \ No newline at end of file
diff --git a/features/support/step_definitions/tags_steps.rb b/features/support/step_definitions/tags_steps.rb
new file mode 100644
index 0000000..5d4dced
--- /dev/null
+++ b/features/support/step_definitions/tags_steps.rb
@@ -0,0 +1,11 @@
+Given /^there is a blog post titled "([^"]*)" and tagged "([^"]*)"$/ do |title, tag_name|
+ @blog_post = Factory(:post, :title => title, :tag_list => tag_name)
+end
+
+When /^I visit the tagged posts page for "([^"]*)"$/ do |tag_name|
+ visit tagged_posts_path(tag_name.parameterize)
+end
+
+Then /^the blog post should have the tags "([^"]*)"$/ do |tag_list|
+ BlogPost.last.tag_list == tag_list.split(', ')
+end
diff --git a/features/tags.feature b/features/tags.feature
new file mode 100644
index 0000000..07c73cd
--- /dev/null
+++ b/features/tags.feature
@@ -0,0 +1,26 @@
+@blog_tags
+Feature: Blog Post Tags
+ Blog posts can be assigned tags
+
+ Background:
+ Given I am a logged in refinery user
+
+ Scenario: The blog post new/edit form has tag_list
+ When I am on the new blog post form
+ Then I should see "Tags"
+
+ Scenario: The blog post new/edit form saves tag_list
+ When I am on the new blog post form
+ And I fill in "Title" with "This is my blog post"
+ And I fill in "Body" with "And I love it"
+ And I fill in "Tags" with "chicago, bikes, beers, babes"
+ And I press "Save"
+
+ Then there should be 1 blog post
+ And the blog post should have the tags "chicago, bikes, beers, babes"
+
+ Scenario: The blog has a "tagged" route & view
+ Given there is a blog post titled "I love my city" and tagged "chicago"
+ When I visit the tagged posts page for "chicago"
+ Then I should see "Chicago"
+ And I should see "I love my city" \ No newline at end of file