Skip to content

Commit e8acec3

Browse files
committed
(#99) added features around the moderator abilities
1 parent 9d85db2 commit e8acec3

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ GEM
208208
sprockets (2.0.3)
209209
hike (~> 1.2)
210210
rack (~> 1.0)
211-
tilt (!= 1.3.0, ~> 1.1)
211+
tilt (~> 1.1, != 1.3.0)
212212
sqlite3 (1.3.5)
213213
term-ansicolor (1.0.7)
214214
thor (0.14.6)

features/moderator.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: Moderate questions
2+
3+
As a moderator, I should be able to delete questions from the site.
4+
5+
Background:
6+
Given there is a question from someone else
7+
8+
Scenario: Delete a question
9+
Given I am a moderator
10+
Then I can delete that question
11+
12+
Scenario: Normal users cannot moderate
13+
Given I am not a moderator
14+
Then I cannot delete that question
15+

features/step_definitions/question_steps.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,30 @@ def create_question_for(user)
4848
visit user_path(@user)
4949
page.should have_content("My Question")
5050
end
51+
52+
Given /^I am a moderator$/ do
53+
step %{a logged in user}
54+
@user.moderator = true
55+
@user.save
56+
end
57+
58+
Given /^I am not a moderator$/ do
59+
step %{a logged in user}
60+
@user.moderator = false
61+
@user.save
62+
end
63+
64+
Given /^there is a question from someone else$/ do
65+
@question = Question.create(:title => "A question to delete",
66+
:description => "moderator should delete me!")
67+
end
68+
69+
Then /^I can delete that question$/ do
70+
visit question_path(@question)
71+
page.should have_content('Delete')
72+
end
73+
74+
Then /^I cannot delete that question$/ do
75+
visit question_path(@question)
76+
page.should_not have_content('Delete')
77+
end

0 commit comments

Comments
 (0)