2016-07-28 20:02:56 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Issue, 'Spammable' do
|
|
|
|
let(:issue) { create(:issue, description: 'Test Desc.') }
|
|
|
|
|
|
|
|
describe 'Associations' do
|
|
|
|
it { is_expected.to have_one(:user_agent_detail).dependent(:destroy) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'ClassMethods' do
|
|
|
|
it 'should return correct attr_spammable' do
|
2016-08-09 13:43:47 -04:00
|
|
|
expect(issue.spammable_text).to eq("#{issue.title}\n#{issue.description}")
|
2016-07-28 20:02:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'InstanceMethods' do
|
|
|
|
it 'should be invalid if spam' do
|
2016-08-05 18:10:08 -04:00
|
|
|
issue = build(:issue, spam: true)
|
|
|
|
expect(issue.valid?).to be_falsey
|
2016-07-28 20:02:56 -04:00
|
|
|
end
|
|
|
|
|
2016-07-30 00:18:32 -04:00
|
|
|
describe '#check_for_spam?' do
|
|
|
|
it 'returns true for public project' do
|
|
|
|
issue.project.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC)
|
|
|
|
expect(issue.check_for_spam?).to eq(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns false for other visibility levels' do
|
|
|
|
expect(issue.check_for_spam?).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
2016-07-28 20:02:56 -04:00
|
|
|
end
|
|
|
|
end
|