diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-09-29 17:28:45 +0300 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-10-04 11:45:48 +0300 |
commit | 4ff345c488c993e9f67f34ad271bc98a1f3ffa61 (patch) | |
tree | b695447f54f09f45e1464fea038b4e0500538047 /spec/models/concerns/mentionable_spec.rb | |
parent | ccd89ec965aa26812b4e48aabc15ca1594914b66 (diff) |
Simplify Mentionable concern instance methods
We remove some arguments that are rarely used or
used just to simplify setups on specs.
Modified Mentionable#create_new_cross_references method
we don’t need to calculate previous references to avoid the
duplication because we do that at database level when
creating references extracted from the current entity state.
MergeRequests won’t create cross_references for commits that are included so we change a spec to use a different merge request to make references to commits to other branches
Diffstat (limited to 'spec/models/concerns/mentionable_spec.rb')
-rw-r--r-- | spec/models/concerns/mentionable_spec.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb index 549b0042038..132858950d5 100644 --- a/spec/models/concerns/mentionable_spec.rb +++ b/spec/models/concerns/mentionable_spec.rb @@ -1,18 +1,27 @@ require 'spec_helper' describe Mentionable do - include Mentionable + class Example + include Mentionable - def author - nil + attr_accessor :project, :message + attr_mentionable :message + + def author + nil + end end describe 'references' do let(:project) { create(:project) } + let(:mentionable) { Example.new } it 'excludes JIRA references' do allow(project).to receive_messages(jira_tracker?: true) - expect(referenced_mentionables(project, 'JIRA-123')).to be_empty + + mentionable.project = project + mentionable.message = 'JIRA-123' + expect(mentionable.referenced_mentionables).to be_empty end end end @@ -39,9 +48,8 @@ describe Issue, "Mentionable" do let(:user) { create(:user) } def referenced_issues(current_user) - text = "#{private_issue.to_reference(project)} and #{public_issue.to_reference}" - - issue.referenced_mentionables(current_user, text) + issue.title = "#{private_issue.to_reference(project)} and #{public_issue.to_reference}" + issue.referenced_mentionables(current_user) end context 'when the current user can see the issue' do |