diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 00:09:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 00:09:07 +0000 |
commit | e144369009f3404072f7e0f969f7cded93195a01 (patch) | |
tree | d7a354e2c3c69a7ad65dc81aba8fe2ba59b0a26f /spec/models/concerns | |
parent | d466ee5042520ad078fe050cb078d81dc2ebe196 (diff) | |
download | gitlab-ce-e144369009f3404072f7e0f969f7cded93195a01.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/concerns')
-rw-r--r-- | spec/models/concerns/mentionable_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb index 883f678b8f5..13a3d1cdd82 100644 --- a/spec/models/concerns/mentionable_spec.rb +++ b/spec/models/concerns/mentionable_spec.rb @@ -26,6 +26,42 @@ describe Mentionable do expect(mentionable.referenced_mentionables).to be_empty end end + + describe '#any_mentionable_attributes_changed?' do + Message = Struct.new(:text) + + let(:mentionable) { Example.new } + let(:changes) do + msg = Message.new('test') + + changes = {} + changes[msg] = ['', 'some message'] + changes[:random_sym_key] = ['', 'some message'] + changes["random_string_key"] = ['', 'some message'] + changes + end + + it 'returns true with key string' do + changes["message"] = ['', 'some message'] + + allow(mentionable).to receive(:saved_changes).and_return(changes) + + expect(mentionable.send(:any_mentionable_attributes_changed?)).to be true + end + + it 'returns false with key symbol' do + changes[:message] = ['', 'some message'] + allow(mentionable).to receive(:saved_changes).and_return(changes) + + expect(mentionable.send(:any_mentionable_attributes_changed?)).to be false + end + + it 'returns false when no attr_mentionable keys' do + allow(mentionable).to receive(:saved_changes).and_return(changes) + + expect(mentionable.send(:any_mentionable_attributes_changed?)).to be false + end + end end describe Issue, "Mentionable" do |