summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorKirill Zaitsev <kirik910@gmail.com>2016-02-06 17:20:21 +0300
committerRémy Coutable <remy@rymai.me>2016-02-11 17:22:11 +0100
commitb123171d3da752c084ef7bfa82dbed962b3e5168 (patch)
tree8a31350c2d57776b6e174ccb03c2556b873a1bc4 /spec/models
parent9b1dfd3e81855c99b0ccb703d3aecc3f1a7ac7c9 (diff)
downloadgitlab-ce-b123171d3da752c084ef7bfa82dbed962b3e5168.tar.gz
Add new data to project in push, issue, merge-request and note webhooks databugagazavr/gitlab-ce-extend-hooks
- Add `avatar_url`, `description`, `git_ssh_url`, `git_http_url`, `path_with_namespace` and `default_branch` in `project` in push, issue, merge-request and note webhooks data - Deprecate the `ssh_url` in favor of `git_ssh_url` and `http_url` in favor of `git_http_url` in `project` for push, issue, merge-request and note webhooks data - Deprecate the `repository` key in push, issue, merge-request and note webhooks data, use `project` instead
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/concerns/issuable_spec.rb23
-rw-r--r--spec/models/merge_request_spec.rb21
2 files changed, 27 insertions, 17 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 8f09ff03a78..600089802b2 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -69,27 +69,28 @@ describe Issue, "Issuable" do
end
describe "#to_hook_data" do
- let(:hook_data) { issue.to_hook_data(user) }
+ let(:data) { issue.to_hook_data(user) }
+ let(:project) { issue.project }
+
it "returns correct hook data" do
- expect(hook_data[:object_kind]).to eq("issue")
- expect(hook_data[:user]).to eq(user.hook_attrs)
- expect(hook_data[:repository][:name]).to eq(issue.project.name)
- expect(hook_data[:repository][:url]).to eq(issue.project.url_to_repo)
- expect(hook_data[:repository][:description]).to eq(issue.project.description)
- expect(hook_data[:repository][:homepage]).to eq(issue.project.web_url)
- expect(hook_data[:object_attributes]).to eq(issue.hook_attrs)
- expect(hook_data).to_not have_key(:assignee)
+ expect(data[:object_kind]).to eq("issue")
+ expect(data[:user]).to eq(user.hook_attrs)
+ expect(data[:object_attributes]).to eq(issue.hook_attrs)
+ expect(data).to_not have_key(:assignee)
end
context "issue is assigned" do
before { issue.update_attribute(:assignee, user) }
it "returns correct hook data" do
- expect(hook_data[:object_attributes]['assignee_id']).to eq(user.id)
- expect(hook_data[:assignee]).to eq(user.hook_attrs)
+ expect(data[:object_attributes]['assignee_id']).to eq(user.id)
+ expect(data[:assignee]).to eq(user.hook_attrs)
end
end
+
+ include_examples 'project hook data'
+ include_examples 'deprecated repository hook data'
end
describe '#card_attributes' do
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index c61ddf01118..f35b48601ad 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -254,13 +254,22 @@ describe MergeRequest, models: true do
end
describe "#hook_attrs" do
+ let(:attrs_hash) { subject.hook_attrs.to_h }
+
+ [:source, :target].each do |key|
+ describe "#{key} key" do
+ include_examples 'project hook data', project_key: key do
+ let(:data) { attrs_hash }
+ let(:project) { subject.send("#{key}_project") }
+ end
+ end
+ end
+
it "has all the required keys" do
- attrs = subject.hook_attrs
- attrs = attrs.to_h
- expect(attrs).to include(:source)
- expect(attrs).to include(:target)
- expect(attrs).to include(:last_commit)
- expect(attrs).to include(:work_in_progress)
+ expect(attrs_hash).to include(:source)
+ expect(attrs_hash).to include(:target)
+ expect(attrs_hash).to include(:last_commit)
+ expect(attrs_hash).to include(:work_in_progress)
end
end