discourse/spec/jobs/bulk_grant_trust_level_spec.rb
Sam Saffron 4ea21fa2d0 DEV: use #frozen_string_literal: true on all spec
This change both speeds up specs (less strings to allocate) and helps catch
cases where methods in Discourse are mutating inputs.

Overall we will be migrating everything to use #frozen_string_literal: true
it will take a while, but this is the first and safest move in this direction
2019-04-30 10:27:42 +10:00

28 lines
883 B
Ruby

# frozen_string_literal: true
require 'rails_helper'
require_dependency 'jobs/regular/bulk_grant_trust_level'
describe Jobs::BulkGrantTrustLevel do
it "raises an error when trust_level is missing" do
expect { Jobs::BulkGrantTrustLevel.new.execute(user_ids: [1, 2]) }.to raise_error(Discourse::InvalidParameters)
end
it "raises an error when user_ids are missing" do
expect { Jobs::BulkGrantTrustLevel.new.execute(trust_level: 0) }.to raise_error(Discourse::InvalidParameters)
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)
Jobs::BulkGrantTrustLevel.new.execute(trust_level: 3, user_ids: [user1.id, user2.id])
user1.reload
user2.reload
expect(user1.trust_level).to eq(3)
expect(user2.trust_level).to eq(3)
end
end