diff options
Diffstat (limited to 'spec/models/integrations/chat_message')
-rw-r--r-- | spec/models/integrations/chat_message/wiki_page_message_spec.rb | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/spec/models/integrations/chat_message/wiki_page_message_spec.rb b/spec/models/integrations/chat_message/wiki_page_message_spec.rb index e8672a0f9c8..ded467dc910 100644 --- a/spec/models/integrations/chat_message/wiki_page_message_spec.rb +++ b/spec/models/integrations/chat_message/wiki_page_message_spec.rb @@ -5,20 +5,30 @@ require 'spec_helper' RSpec.describe Integrations::ChatMessage::WikiPageMessage do subject { described_class.new(args) } + let(:name) { 'Test User' } + let(:username) { 'test.user' } + let(:avatar_url) { 'http://someavatar.com' } + let(:project_name) { 'project_name' } + let(:project_url) {'http://somewhere.com' } + let(:url) { 'http://url.com' } + let(:diff_url) { 'http://url.com/diff?version_id=1234' } + let(:wiki_page_title) { 'Wiki page title' } + let(:commit_message) { 'Wiki page commit message' } let(:args) do { user: { - name: 'Test User', - username: 'test.user', - avatar_url: 'http://someavatar.com' + name: name, + username: username, + avatar_url: avatar_url }, - project_name: 'project_name', - project_url: 'http://somewhere.com', + project_name: project_name, + project_url: project_url, object_attributes: { - title: 'Wiki page title', - url: 'http://url.com', + title: wiki_page_title, + url: url, content: 'Wiki page content', - message: 'Wiki page commit message' + message: commit_message, + diff_url: diff_url } } end @@ -32,8 +42,8 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do it 'returns a message that a new wiki page was created' do expect(subject.pretext).to eq( - 'Test User (test.user) created <http://url.com|wiki page> in <http://somewhere.com|project_name>: '\ - '*Wiki page title*') + "#{name} (#{username}) created <#{url}|wiki page> (<#{diff_url}|Compare changes>) in <#{project_url}|#{project_name}>: "\ + "*#{wiki_page_title}*") end end @@ -44,8 +54,8 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do it 'returns a message that a wiki page was updated' do expect(subject.pretext).to eq( - 'Test User (test.user) edited <http://url.com|wiki page> in <http://somewhere.com|project_name>: '\ - '*Wiki page title*') + "#{name} (#{username}) edited <#{url}|wiki page> (<#{diff_url}|Compare changes>) in <#{project_url}|#{project_name}>: "\ + "*#{wiki_page_title}*") end end end @@ -61,7 +71,7 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do it 'returns the commit message for a new wiki page' do expect(subject.attachments).to eq([ { - text: "Wiki page commit message", + text: commit_message, color: color } ]) @@ -76,7 +86,7 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do it 'returns the commit message for an updated wiki page' do expect(subject.attachments).to eq([ { - text: "Wiki page commit message", + text: commit_message, color: color } ]) @@ -98,7 +108,7 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do it 'returns a message that a new wiki page was created' do expect(subject.pretext).to eq( - 'Test User (test.user) created [wiki page](http://url.com) in [project_name](http://somewhere.com): *Wiki page title*') + "#{name} (#{username}) created [wiki page](#{url}) ([Compare changes](#{diff_url})) in [#{project_name}](#{project_url}): *#{wiki_page_title}*") end end @@ -109,7 +119,7 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do it 'returns a message that a wiki page was updated' do expect(subject.pretext).to eq( - 'Test User (test.user) edited [wiki page](http://url.com) in [project_name](http://somewhere.com): *Wiki page title*') + "#{name} (#{username}) edited [wiki page](#{url}) ([Compare changes](#{diff_url})) in [#{project_name}](#{project_url}): *#{wiki_page_title}*") end end end @@ -121,7 +131,7 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do end it 'returns the commit message for a new wiki page' do - expect(subject.attachments).to eq('Wiki page commit message') + expect(subject.attachments).to eq(commit_message) end end @@ -131,7 +141,7 @@ RSpec.describe Integrations::ChatMessage::WikiPageMessage do end it 'returns the commit message for an updated wiki page' do - expect(subject.attachments).to eq('Wiki page commit message') + expect(subject.attachments).to eq(commit_message) end end end |