2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 21:27:38 -05:00
|
|
|
RSpec.describe Jobs::BulkGrantTrustLevel do
|
2017-03-02 12:16:01 -06:00
|
|
|
it "raises an error when trust_level is missing" do
|
2023-01-09 05:18:21 -06:00
|
|
|
expect { Jobs::BulkGrantTrustLevel.new.execute(user_ids: [1, 2]) }.to raise_error(
|
|
|
|
Discourse::InvalidParameters,
|
|
|
|
)
|
2017-03-02 12:16:01 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an error when user_ids are missing" do
|
2023-01-09 05:18:21 -06:00
|
|
|
expect { Jobs::BulkGrantTrustLevel.new.execute(trust_level: 0) }.to raise_error(
|
|
|
|
Discourse::InvalidParameters,
|
|
|
|
)
|
2017-03-02 12:16:01 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
it "updates the trust_level" do
|
|
|
|
user1 = Fabricate(:user, email: "foo@wat.com", trust_level: 0)
|
|
|
|
user2 = Fabricate(:user, email: "foo@bar.com", trust_level: 2)
|
|
|
|
|
2017-07-27 20:20:09 -05:00
|
|
|
Jobs::BulkGrantTrustLevel.new.execute(trust_level: 3, user_ids: [user1.id, user2.id])
|
2017-03-02 12:16:01 -06:00
|
|
|
|
|
|
|
user1.reload
|
|
|
|
user2.reload
|
|
|
|
expect(user1.trust_level).to eq(3)
|
|
|
|
expect(user2.trust_level).to eq(3)
|
|
|
|
end
|
|
|
|
end
|