fixes #2417
This commit is contained in:
@@ -22,10 +22,10 @@ class JanitorTrialTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
should "toggle the janitor flag on the user" do
|
||||
should "toggle the can_approve_posts flag on the user" do
|
||||
janitor_trial = JanitorTrial.create(:user_id => @user.id)
|
||||
@user.reload
|
||||
assert(@user.is_janitor?)
|
||||
assert(@user.can_approve_posts?)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,6 +39,12 @@ class JanitorTrialTest < ActiveSupport::TestCase
|
||||
@janitor_trial.demote!
|
||||
end
|
||||
end
|
||||
|
||||
should "revoke approval privileges" do
|
||||
@janitor_trial.demote!
|
||||
@user.reload
|
||||
assert_equal(false, @user.can_approve_posts?)
|
||||
end
|
||||
end
|
||||
|
||||
context "upon promotion" do
|
||||
|
||||
@@ -102,9 +102,9 @@ class TagTest < ActiveSupport::TestCase
|
||||
MEMCACHE.flush_all
|
||||
end
|
||||
|
||||
should "be lockable by a janitor" do
|
||||
should "be lockable by a moderator" do
|
||||
@tag = FactoryGirl.create(:tag)
|
||||
@tag.update_attributes({:is_locked => true}, :as => :janitor)
|
||||
@tag.update_attributes({:is_locked => true}, :as => :moderator)
|
||||
@tag.reload
|
||||
assert_equal(true, @tag.is_locked?)
|
||||
end
|
||||
|
||||
@@ -14,25 +14,25 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
context "A wiki page" do
|
||||
context "that is locked" do
|
||||
should "not be editable by a member" do
|
||||
CurrentUser.user = FactoryGirl.create(:janitor_user)
|
||||
CurrentUser.user = FactoryGirl.create(:moderator_user)
|
||||
@wiki_page = FactoryGirl.create(:wiki_page, :is_locked => true)
|
||||
CurrentUser.user = FactoryGirl.create(:user)
|
||||
@wiki_page.update_attributes(:body => "hello")
|
||||
assert_equal(["Is locked and cannot be updated"], @wiki_page.errors.full_messages)
|
||||
end
|
||||
|
||||
should "be editable by a janitor" do
|
||||
CurrentUser.user = FactoryGirl.create(:janitor_user)
|
||||
should "be editable by a moderator" do
|
||||
CurrentUser.user = FactoryGirl.create(:moderator_user)
|
||||
@wiki_page = FactoryGirl.create(:wiki_page, :is_locked => true)
|
||||
CurrentUser.user = FactoryGirl.create(:janitor_user)
|
||||
CurrentUser.user = FactoryGirl.create(:moderator_user)
|
||||
@wiki_page.update_attributes(:body => "hello")
|
||||
assert_equal([], @wiki_page.errors.full_messages)
|
||||
end
|
||||
end
|
||||
|
||||
context "updated by a janitor" do
|
||||
context "updated by a moderator" do
|
||||
setup do
|
||||
@user = FactoryGirl.create(:janitor_user)
|
||||
@user = FactoryGirl.create(:moderator_user)
|
||||
CurrentUser.user = @user
|
||||
@wiki_page = FactoryGirl.create(:wiki_page)
|
||||
end
|
||||
@@ -53,7 +53,7 @@ class WikiPageTest < ActiveSupport::TestCase
|
||||
|
||||
should "not allow the is_locked attribute to be updated" do
|
||||
@wiki_page.update_attributes(:is_locked => true)
|
||||
assert_equal(["Is locked can be modified by janitors only", "Is locked and cannot be updated"], @wiki_page.errors.full_messages)
|
||||
assert_equal(["Is locked can be modified by moderators only", "Is locked and cannot be updated"], @wiki_page.errors.full_messages)
|
||||
@wiki_page.reload
|
||||
assert_equal(false, @wiki_page.is_locked?)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user