diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-02-10 11:41:22 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-02-20 16:28:13 +0100 |
commit | 5be8f03747eff470e3093e6a3f97c475ddba9a90 (patch) | |
tree | 02f675d7f8f439e5925df46f40d2f0c7b8d2a374 /spec | |
parent | c89449e6110c2bdf6e1410bae3e7b7d807c5e305 (diff) | |
download | gitlab-ce-5be8f03747eff470e3093e6a3f97c475ddba9a90.tar.gz |
Improve performance of User Agent Detail
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/concerns/spammable_spec.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/models/concerns/spammable_spec.rb b/spec/models/concerns/spammable_spec.rb index 32935bc0b09..b6e5c95d18a 100644 --- a/spec/models/concerns/spammable_spec.rb +++ b/spec/models/concerns/spammable_spec.rb @@ -14,8 +14,9 @@ describe Issue, 'Spammable' do end describe 'InstanceMethods' do + let(:issue) { build(:issue, spam: true) } + it 'should be invalid if spam' do - issue = build(:issue, spam: true) expect(issue.valid?).to be_falsey end @@ -29,5 +30,20 @@ describe Issue, 'Spammable' do expect(issue.check_for_spam?).to eq(false) end end + + describe '#submittable_as_spam_by?' do + let(:admin) { build(:admin) } + let(:user) { build(:user) } + + before do + allow(issue).to receive(:submittable_as_spam?).and_return(true) + end + + it 'tests if the user can submit spam' do + expect(issue.submittable_as_spam_by?(admin)).to be(true) + expect(issue.submittable_as_spam_by?(user)).to be(false) + expect(issue.submittable_as_spam_by?(nil)).to be_nil + end + end end end |