diff options
author | Rémy Coutable <remy@rymai.me> | 2017-09-15 20:08:27 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-10-09 16:07:10 +0300 |
commit | 67d5ca9f9220e5572f3fa6d0d8290cd7b802f02f (patch) | |
tree | d424fc71d20847c8a7c0314ff081f3d2ed9afbe4 /spec/models/concerns | |
parent | f277fa14094e5515e2317d2baa1fa0bfb95966da (diff) |
Include the changes in issuable webhook payloads
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/models/concerns')
-rw-r--r-- | spec/models/concerns/issuable_spec.rb | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index fb5fb7daaab..5763e1ba6d4 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Issuable do let(:issuable_class) { Issue } - let(:issue) { create(:issue) } + let(:issue) { create(:issue, title: 'An issue', description: 'A description') } let(:user) { create(:user) } describe "Associations" do @@ -265,17 +265,17 @@ describe Issuable do end describe "#to_hook_data" do - let(:data) { issue.to_hook_data(user) } - let(:project) { issue.project } + it_behaves_like 'issuable hook data', 'issue' do + let(:issuable) { create(:issue, description: 'A description') } + end - it "returns correct hook data" do - 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).not_to have_key(:assignee) + it_behaves_like 'issuable hook data', 'merge_request' do + let(:issuable) { create(:merge_request, description: 'A description') } end context "issue is assigned" do + let(:data) { issue.to_hook_data(user) } + before do issue.assignees << user end @@ -296,23 +296,12 @@ describe Issuable do it "returns correct hook data" do expect(data[:object_attributes]['assignee_id']).to eq(user.id) expect(data[:assignee]).to eq(user.hook_attrs) + expect(data[:changes]).to match(hash_including({ + 'assignee_id' => [nil, user.id], + 'updated_at' => [a_kind_of(ActiveSupport::TimeWithZone), a_kind_of(ActiveSupport::TimeWithZone)] + })) end end - - context 'issue has labels' do - let(:labels) { [create(:label), create(:label)] } - - before do - issue.update_attribute(:labels, labels) - end - - it 'includes labels in the hook data' do - expect(data[:labels]).to eq(labels.map(&:hook_attrs)) - end - end - - include_examples 'project hook data' - include_examples 'deprecated repository hook data' end describe '#labels_array' do |