mirror of
https://github.com/discourse/discourse.git
synced 2025-03-03 17:59:20 +00:00
DEV: Add tests for Guardian#is_developer?
(#28419)
DEV: Add tests for `Guardian#is_developer?` Follow up to e1c4cf2566172b4461119f2c145764b978809100
This commit is contained in:
parent
0679e6eb7a
commit
9d5f4bf2f1
@ -4469,4 +4469,24 @@ RSpec.describe Guardian do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#is_developer?" do
|
||||
after { Developer.rebuild_cache }
|
||||
|
||||
it "returns true if user is an admin and has an associated `Developer` object" do
|
||||
Developer.create!(user: admin)
|
||||
|
||||
expect(Guardian.new(admin).is_developer?).to eq(true)
|
||||
end
|
||||
|
||||
it "returns false if user is an admin but does not have an associated `Developer` object" do
|
||||
expect(Guardian.new(admin).is_developer?).to eq(false)
|
||||
end
|
||||
|
||||
it "returns true if user's email has been configured as part of `Rails.configuration.developer_emails`" do
|
||||
Rails.configuration.stubs(:developer_emails).returns([user.email])
|
||||
|
||||
expect(Guardian.new(user).is_developer?).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user