Skip to content

Commit

Permalink
The params that come from the selected topics on the forum show page …
Browse files Browse the repository at this point in the history
…are params[:moderated_topics]. Use these.
  • Loading branch information
radar committed Feb 6, 2010
1 parent 74706e8 commit 7d0f9ea
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/controllers/moderator/topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ def destroy
#
# The second comes from forums/show which will use all the currently selected moderations as the objects.
def moderate
@moderations = Moderation.for_user(current_user).topics.find(params[:moderation_ids]) if params[:moderation_ids]
# Topics
@moderations = Topic.find(params[:moderated_topics], :include => :moderations).each do |topic|
topic.moderations.find_or_create_by_user_id(current_user.id)
end if params[:moderated_topics]
# Moderation objects
@moderations ||= Moderation.for_user(current_user).topics.find(params[:moderation_ids]) if params[:moderation_ids]
# All moderations for the current user.
@moderations ||= Moderation.topics.for_user(current_user.id)
case params[:commit]
when "Lock"
Expand Down
8 changes: 8 additions & 0 deletions features/step_definitions/topics_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Then /^I should see (\d+) sticky topics?$/ do |num|
Nokogiri::HTML(response.body).xpath("//img[@src]").select { |i| i['src'].match(/sticky/) }.size.should eql(num.to_i)
end

Then /^I should see (\d+) locked topics?$/ do |num|
p Topic.all.map(&:locked)
Nokogiri::HTML(response.body).xpath("//img[@src]").select { |i| i['src'].match(/locked/) }.size.should eql(num.to_i)
end
17 changes: 17 additions & 0 deletions features/topics_moderation.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: Topics moderation
In order to lock, delete, sticky and merge topics
As a person who's able to do that
I want the buttons to work for me

Background:
Given there is the usual setup

Scenario: Locking selected topics
Given I am logged in as "administrator" with the password "godly"
And I am on the homepage
When I follow "Public Forum"
Then I should see 0 locked topics
When I select "Default topic" for moderation
And I press "Lock"
Then I should see "All selected topics have been locked."
Then I should see 1 locked topic

0 comments on commit 7d0f9ea

Please sign in to comment.