summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-06 16:13:43 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-06 16:13:43 -0800
commite68ad7fbb83d1b2799d3672791d723adfd494219 (patch)
tree80542df39b9b7917b002e875d3f8e0354685e2ae /spec
parent7dadd423d5279a67cad6d7919370432931deee3e (diff)
parent1cc41ce1adce23d3eb4a9c4ed0ab17e11ea1f1e3 (diff)
downloadgitlab-ce-e68ad7fbb83d1b2799d3672791d723adfd494219.tar.gz
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
Diffstat (limited to 'spec')
-rw-r--r--spec/models/project_services/hipchat_service_spec.rb45
-rw-r--r--spec/models/project_services/slack_service/issue_message_spec.rb11
-rw-r--r--spec/models/project_services/slack_service/merge_message_spec.rb13
-rw-r--r--spec/models/project_services/slack_service/note_message_spec.rb8
-rw-r--r--spec/models/project_services/slack_service/push_message_spec.rb20
5 files changed, 74 insertions, 23 deletions
diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb
index 95ce4f8e4aa..b9f2bee148d 100644
--- a/spec/models/project_services/hipchat_service_spec.rb
+++ b/spec/models/project_services/hipchat_service_spec.rb
@@ -50,6 +50,35 @@ describe HipchatService do
expect(WebMock).to have_requested(:post, api_url).once
end
+
+ it "should create a push message" do
+ message = hipchat.send(:create_push_message, push_sample_data)
+
+ obj_attr = push_sample_data[:object_attributes]
+ branch = push_sample_data[:ref].gsub('refs/heads/', '')
+ expect(message).to include("#{user.name} pushed to branch " \
+ "<a href=\"#{project.web_url}/commits/#{branch}\">#{branch}</a> of " \
+ "<a href=\"#{project.web_url}\">#{project_name}</a>")
+ end
+ end
+
+ context 'tag_push events' do
+ let(:push_sample_data) { Gitlab::PushDataBuilder.build(project, user, '000000', '111111', 'refs/tags/test', []) }
+
+ it "should call Hipchat API for tag push events" do
+ hipchat.execute(push_sample_data)
+
+ expect(WebMock).to have_requested(:post, api_url).once
+ end
+
+ it "should create a tag push message" do
+ message = hipchat.send(:create_push_message, push_sample_data)
+
+ obj_attr = push_sample_data[:object_attributes]
+ expect(message).to eq("#{user.name} pushed new tag " \
+ "<a href=\"#{project.web_url}/commits/test\">test</a> to " \
+ "<a href=\"#{project.web_url}\">#{project_name}</a>\n")
+ end
end
context 'issue events' do
@@ -67,8 +96,8 @@ describe HipchatService do
message = hipchat.send(:create_issue_message, issues_sample_data)
obj_attr = issues_sample_data[:object_attributes]
- expect(message).to eq("#{user.username} opened issue " \
- "<a href=\"#{obj_attr[:url]}\">##{obj_attr["iid"]}</a> in " \
+ expect(message).to eq("#{user.name} opened " \
+ "<a href=\"#{obj_attr[:url]}\">issue ##{obj_attr["iid"]}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>Awesome issue</b>" \
"<pre>please fix</pre>")
@@ -91,8 +120,8 @@ describe HipchatService do
merge_sample_data)
obj_attr = merge_sample_data[:object_attributes]
- expect(message).to eq("#{user.username} opened merge request " \
- "<a href=\"#{obj_attr[:url]}\">##{obj_attr["iid"]}</a> in " \
+ expect(message).to eq("#{user.name} opened " \
+ "<a href=\"#{obj_attr[:url]}\">merge request ##{obj_attr["iid"]}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>Awesome merge request</b>" \
"<pre>please fix</pre>")
@@ -122,7 +151,7 @@ describe HipchatService do
commit_id = Commit.truncate_sha(data[:commit][:id])
title = hipchat.send(:format_title, data[:commit][:message])
- expect(message).to eq("#{user.username} commented on " \
+ expect(message).to eq("#{user.name} commented on " \
"<a href=\"#{obj_attr[:url]}\">commit #{commit_id}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"#{title}" \
@@ -141,7 +170,7 @@ describe HipchatService do
merge_id = data[:merge_request]['iid']
title = data[:merge_request]['title']
- expect(message).to eq("#{user.username} commented on " \
+ expect(message).to eq("#{user.name} commented on " \
"<a href=\"#{obj_attr[:url]}\">merge request ##{merge_id}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>#{title}</b>" \
@@ -158,7 +187,7 @@ describe HipchatService do
issue_id = data[:issue]['iid']
title = data[:issue]['title']
- expect(message).to eq("#{user.username} commented on " \
+ expect(message).to eq("#{user.name} commented on " \
"<a href=\"#{obj_attr[:url]}\">issue ##{issue_id}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>#{title}</b>" \
@@ -177,7 +206,7 @@ describe HipchatService do
snippet_id = data[:snippet]['id']
title = data[:snippet]['title']
- expect(message).to eq("#{user.username} commented on " \
+ expect(message).to eq("#{user.name} commented on " \
"<a href=\"#{obj_attr[:url]}\">snippet ##{snippet_id}</a> in " \
"<a href=\"#{project.web_url}\">#{project_name}</a>: " \
"<b>#{title}</b>" \
diff --git a/spec/models/project_services/slack_service/issue_message_spec.rb b/spec/models/project_services/slack_service/issue_message_spec.rb
index a23a7cc068e..8bca1fef44c 100644
--- a/spec/models/project_services/slack_service/issue_message_spec.rb
+++ b/spec/models/project_services/slack_service/issue_message_spec.rb
@@ -6,7 +6,8 @@ describe SlackService::IssueMessage do
let(:args) {
{
user: {
- username: 'username'
+ name: 'Test User',
+ username: 'Test User'
},
project_name: 'project_name',
project_url: 'somewhere.com',
@@ -29,8 +30,8 @@ describe SlackService::IssueMessage do
context 'open' do
it 'returns a message regarding opening of issues' do
expect(subject.pretext).to eq(
- 'username opened issue <url|#100> in <somewhere.com|project_name>: '\
- 'Issue title')
+ 'Test User opened <url|issue #100> in <somewhere.com|project_name>: '\
+ '*Issue title*')
expect(subject.attachments).to eq([
{
text: "issue description",
@@ -47,8 +48,8 @@ describe SlackService::IssueMessage do
end
it 'returns a message regarding closing of issues' do
expect(subject.pretext). to eq(
- 'username closed issue <url|#100> in <somewhere.com|project_name>: '\
- 'Issue title')
+ 'Test User closed <url|issue #100> in <somewhere.com|project_name>: '\
+ '*Issue title*')
expect(subject.attachments).to be_empty
end
end
diff --git a/spec/models/project_services/slack_service/merge_message_spec.rb b/spec/models/project_services/slack_service/merge_message_spec.rb
index 25d03cd8736..aeb408aa766 100644
--- a/spec/models/project_services/slack_service/merge_message_spec.rb
+++ b/spec/models/project_services/slack_service/merge_message_spec.rb
@@ -6,13 +6,14 @@ describe SlackService::MergeMessage do
let(:args) {
{
user: {
- username: 'username'
+ name: 'Test User',
+ username: 'Test User'
},
project_name: 'project_name',
project_url: 'somewhere.com',
object_attributes: {
- title: 'Issue title',
+ title: "Issue title\nSecond line",
id: 10,
iid: 100,
assignee_id: 1,
@@ -30,8 +31,8 @@ describe SlackService::MergeMessage do
context 'open' do
it 'returns a message regarding opening of merge requests' do
expect(subject.pretext).to eq(
- 'username opened merge request <somewhere.com/merge_requests/100|#100> '\
- 'in <somewhere.com|project_name>')
+ 'Test User opened <somewhere.com/merge_requests/100|merge request #100> '\
+ 'in <somewhere.com|project_name>: *Issue title*')
expect(subject.attachments).to be_empty
end
end
@@ -42,8 +43,8 @@ describe SlackService::MergeMessage do
end
it 'returns a message regarding closing of merge requests' do
expect(subject.pretext).to eq(
- 'username closed merge request <somewhere.com/merge_requests/100|#100> '\
- 'in <somewhere.com|project_name>')
+ 'Test User closed <somewhere.com/merge_requests/100|merge request #100> '\
+ 'in <somewhere.com|project_name>: *Issue title*')
expect(subject.attachments).to be_empty
end
end
diff --git a/spec/models/project_services/slack_service/note_message_spec.rb b/spec/models/project_services/slack_service/note_message_spec.rb
index f2516c10008..21fb575480b 100644
--- a/spec/models/project_services/slack_service/note_message_spec.rb
+++ b/spec/models/project_services/slack_service/note_message_spec.rb
@@ -37,7 +37,7 @@ describe SlackService::NoteMessage do
it 'returns a message regarding notes on commits' do
message = SlackService::NoteMessage.new(@args)
- expect(message.pretext).to eq("username commented on " \
+ expect(message.pretext).to eq("Test User commented on " \
"<url|commit 5f163b2b> in <somewhere.com|project_name>: " \
"*Added a commit message*")
expected_attachments = [
@@ -62,7 +62,7 @@ describe SlackService::NoteMessage do
end
it 'returns a message regarding notes on a merge request' do
message = SlackService::NoteMessage.new(@args)
- expect(message.pretext).to eq("username commented on " \
+ expect(message.pretext).to eq("Test User commented on " \
"<url|merge request #30> in <somewhere.com|project_name>: " \
"*merge request title*")
expected_attachments = [
@@ -89,7 +89,7 @@ describe SlackService::NoteMessage do
it 'returns a message regarding notes on an issue' do
message = SlackService::NoteMessage.new(@args)
expect(message.pretext).to eq(
- "username commented on " \
+ "Test User commented on " \
"<url|issue #20> in <somewhere.com|project_name>: " \
"*issue title*")
expected_attachments = [
@@ -114,7 +114,7 @@ describe SlackService::NoteMessage do
it 'returns a message regarding notes on a project snippet' do
message = SlackService::NoteMessage.new(@args)
- expect(message.pretext).to eq("username commented on " \
+ expect(message.pretext).to eq("Test User commented on " \
"<url|snippet #5> in <somewhere.com|project_name>: " \
"*snippet title*")
expected_attachments = [
diff --git a/spec/models/project_services/slack_service/push_message_spec.rb b/spec/models/project_services/slack_service/push_message_spec.rb
index ef0e7a6ee30..3ef065459d8 100644
--- a/spec/models/project_services/slack_service/push_message_spec.rb
+++ b/spec/models/project_services/slack_service/push_message_spec.rb
@@ -39,6 +39,26 @@ describe SlackService::PushMessage do
end
end
+ context 'tag push' do
+ let(:args) {
+ {
+ after: 'after',
+ before: '000000',
+ project_name: 'project_name',
+ ref: 'refs/tags/new_tag',
+ user_name: 'user_name',
+ project_url: 'url'
+ }
+ }
+
+ it 'returns a message regarding pushes' do
+ expect(subject.pretext).to eq('user_name pushed new tag ' \
+ '<url/commits/new_tag|new_tag> to ' \
+ '<url|project_name>')
+ expect(subject.attachments).to be_empty
+ end
+ end
+
context 'new branch' do
before do
args[:before] = '000000'