DEV: Add tests for `Guardian#is_developer?` (#28419)

DEV: Add tests for `Guardian#is_developer?`

Follow up to e1c4cf2566
This commit is contained in:
Alan Guo Xiang Tan 2024-08-19 14:20:09 +08:00 committed by GitHub
parent 0679e6eb7a
commit 9d5f4bf2f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 0 deletions

View File

@ -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