diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-08-05 17:10:08 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-08-15 13:18:15 -0500 |
commit | 43e756d4eafd79f4d2f366b646ebb94af78b5a4c (patch) | |
tree | 07949d3368affcda301fd266e1e5bf0649474b23 /spec/models/concerns/spammable_spec.rb | |
parent | 7179165af7553720089a0b7e7024374c371e2f90 (diff) | |
download | gitlab-ce-43e756d4eafd79f4d2f366b646ebb94af78b5a4c.tar.gz |
Refactored AkismetHelper into AkismetService and cleaned up `Spammable`
- Refactored SpamCheckService into SpamService
Diffstat (limited to 'spec/models/concerns/spammable_spec.rb')
-rw-r--r-- | spec/models/concerns/spammable_spec.rb | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/spec/models/concerns/spammable_spec.rb b/spec/models/concerns/spammable_spec.rb index 4e52d05918f..7944305e7b3 100644 --- a/spec/models/concerns/spammable_spec.rb +++ b/spec/models/concerns/spammable_spec.rb @@ -14,25 +14,24 @@ describe Issue, 'Spammable' do end describe 'InstanceMethods' do - before do - allow_any_instance_of(Gitlab::AkismetHelper).to receive(:akismet_enabled?).and_return(true) - end - it 'should return the correct creator' do - expect(issue.send(:owner).id).to eq(issue.author_id) + expect(issue.owner_id).to eq(issue.author_id) end it 'should be invalid if spam' do - issue.spam = true - expect(issue.valid?).to be_truthy + issue = build(:issue, spam: true) + expect(issue.valid?).to be_falsey end - it 'should be submittable' do + it 'should not be submitted' do create(:user_agent_detail, subject: issue) - expect(issue.can_be_submitted?).to be_truthy + expect(issue.submitted?).to be_falsey end describe '#check_for_spam?' do + before do + allow_any_instance_of(ApplicationSetting).to receive(:akismet_enabled).and_return(true) + end it 'returns true for public project' do issue.project.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC) expect(issue.check_for_spam?).to eq(true) @@ -43,14 +42,4 @@ describe Issue, 'Spammable' do end end end - - describe 'AkismetMethods' do - before do - allow_any_instance_of(Gitlab::AkismetHelper).to receive_messages(is_spam?: true, spam!: true, akismet_enabled?: true) - allow_any_instance_of(Spammable).to receive(:can_be_submitted?).and_return(true) - end - - it { expect(issue.spam_detected?(:mock_env)).to be_truthy } - it { expect(issue.submit_spam).to be_truthy } - end end |