additional checks on forum topic visibility
This commit is contained in:
@@ -45,6 +45,7 @@ class ForumPostsControllerTest < ActionController::TestCase
|
||||
|
||||
context "with private topics" do
|
||||
setup do
|
||||
CurrentUser.user = @mod
|
||||
@mod_topic = FactoryGirl.create(:mod_up_forum_topic)
|
||||
@mod_posts = 2.times.map do
|
||||
FactoryGirl.create(:forum_post, :topic_id => @mod_topic.id)
|
||||
@@ -53,6 +54,7 @@ class ForumPostsControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "list only permitted posts for members" do
|
||||
CurrentUser.user = @user
|
||||
get :index, {}, { :user_id => @user.id }
|
||||
|
||||
assert_response :success
|
||||
|
||||
@@ -18,7 +18,9 @@ class ForumTopicsControllerTest < ActionController::TestCase
|
||||
|
||||
context "for a level restricted topic" do
|
||||
setup do
|
||||
@forum_topic.update_attribute(:min_level, 50)
|
||||
CurrentUser.user = @mod
|
||||
@forum_topic.update_attribute(:min_level, User::Levels::MODERATOR)
|
||||
CurrentUser.user = @user
|
||||
end
|
||||
|
||||
should "not allow users to see the topic" do
|
||||
@@ -42,7 +44,9 @@ class ForumTopicsControllerTest < ActionController::TestCase
|
||||
assert_equal(false, @gold_user.reload.has_forum_been_updated?)
|
||||
|
||||
# Then adding an unread private topic should not bump.
|
||||
FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id)
|
||||
CurrentUser.scoped(@mod) do
|
||||
FactoryGirl.create(:forum_post, :topic_id => @forum_topic.id)
|
||||
end
|
||||
assert_equal(false, @gold_user.reload.has_forum_been_updated?)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ module Maintenance
|
||||
post :create, {:user => {:email => ""}}
|
||||
assert_equal("Email address not found", flash[:notice])
|
||||
@blank_email_user.reload
|
||||
assert_equal(@blank_email_user.created_at, @blank_email_user.updated_at)
|
||||
assert_equal(@blank_email_user.created_at.to_i, @blank_email_user.updated_at.to_i)
|
||||
assert_equal(0, ActionMailer::Base.deliveries.size)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -73,9 +73,9 @@ class WikiPagesControllerTest < ActionController::TestCase
|
||||
end
|
||||
|
||||
should "destroy a wiki_page" do
|
||||
assert_difference("WikiPage.count", -1) do
|
||||
post :destroy, {:id => @wiki_page.id}, {:user_id => @mod.id}
|
||||
end
|
||||
post :destroy, {:id => @wiki_page.id}, {:user_id => @mod.id}
|
||||
@wiki_page.reload
|
||||
assert_equal(true, @wiki_page.is_deleted?)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user