Permalink
Browse files

(#99) added features around the moderator abilities

  • Loading branch information...
1 parent 9d85db2 commit e8acec3b0227c755105b5c3afecfbeeee56a392e @coreypurcell coreypurcell committed Feb 4, 2012
Showing with 43 additions and 1 deletion.
  1. +1 −1 Gemfile.lock
  2. +15 −0 features/moderator.feature
  3. +27 −0 features/step_definitions/question_steps.rb
View
@@ -208,7 +208,7 @@ GEM
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
- tilt (!= 1.3.0, ~> 1.1)
+ tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
term-ansicolor (1.0.7)
thor (0.14.6)
View
@@ -0,0 +1,15 @@
+Feature: Moderate questions
+
+ As a moderator, I should be able to delete questions from the site.
+
+ Background:
+ Given there is a question from someone else
+
+ Scenario: Delete a question
+ Given I am a moderator
+ Then I can delete that question
+
+ Scenario: Normal users cannot moderate
+ Given I am not a moderator
+ Then I cannot delete that question
+
@@ -48,3 +48,30 @@ def create_question_for(user)
visit user_path(@user)
page.should have_content("My Question")
end
+
+Given /^I am a moderator$/ do
+ step %{a logged in user}
+ @user.moderator = true
+ @user.save
+end
+
+Given /^I am not a moderator$/ do
+ step %{a logged in user}
+ @user.moderator = false
+ @user.save
+end
+
+Given /^there is a question from someone else$/ do
+ @question = Question.create(:title => "A question to delete",
+ :description => "moderator should delete me!")
+end
+
+Then /^I can delete that question$/ do
+ visit question_path(@question)
+ page.should have_content('Delete')
+end
+
+Then /^I cannot delete that question$/ do
+ visit question_path(@question)
+ page.should_not have_content('Delete')
+end

0 comments on commit e8acec3

Please sign in to comment.