2013-07-23 17:58:26 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2013-09-10 21:21:16 -04:00
|
|
|
describe UserHistory do
|
2014-02-28 16:30:45 -05:00
|
|
|
|
|
|
|
describe '#staff_action_records' do
|
|
|
|
context "with some records" do
|
|
|
|
before do
|
|
|
|
@change_site_setting = UserHistory.create!({action: UserHistory.actions[:change_site_setting], subject: "title", previous_value: "Old", new_value: "New"})
|
|
|
|
@change_trust_level = UserHistory.create!({action: UserHistory.actions[:change_trust_level], target_user_id: Fabricate(:user).id, details: "stuff happened"})
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns all records for admins" do
|
|
|
|
records = described_class.staff_action_records(Fabricate(:admin)).to_a
|
|
|
|
records.size.should == 2
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't return records to moderators that only admins should see" do
|
|
|
|
records = described_class.staff_action_records(Fabricate(:moderator)).to_a
|
|
|
|
records.should == [@change_trust_level]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-07-23 17:58:26 -04:00
|
|
|
end
|