spec/yajp_spec.rb in danger-yajp-0.0.2 vs spec/yajp_spec.rb in danger-yajp-0.1.0
- old
+ new
@@ -1,9 +1,10 @@
# frozen_string_literal: true
require_relative 'spec_helper'
+# rubocop:disable Metrics/ModuleLength
module Danger
describe Danger::DangerYajp do
before do
ENV['DANGER_JIRA_URL'] = 'https://jira.company.com/jira'
ENV['DANGER_JIRA_USER'] = 'username'
@@ -70,10 +71,11 @@
allow(plugin).to receive_message_chain('github.branch_for_head').and_return('bugfix/WEB-128')
issues = plugin.find_issues('WEB', search_branch: true)
expect(issues).to eq(['WEB-128', 'WEB-129'])
end
+ # rubocop:disable Naming/VariableNumber
it 'can split transition field from other fields' do
json = File.read("#{File.dirname(__FILE__)}/support/transitions.all.json")
url = "#{ENV['DANGER_JIRA_URL']}/rest/api/2/issue/WEB-130/transitions"
transition_data = { assignee: { name: 'username' }, summary: 'new_summary' }
fields = { colour: 'red', customfield_11005: 'example' }
@@ -114,8 +116,29 @@
result = plugin.update([issue1, issue2], assignee: { name: 'username' }, customfield_11005: 'example')
expect(stub).to have_been_requested.twice
expect(result).to be true
end
+ # rubocop:enable Naming/VariableNumber
+
+ it 'can add remote link' do
+ pr_title = 'PR Title'
+ pr_json = '{"html_url":"https://github.com/test/pull/1234"}'
+ url = "#{ENV['DANGER_JIRA_URL']}/rest/api/2/issue/WEB-134/remotelink"
+ json = File.read("#{File.dirname(__FILE__)}/support/remotelink.json")
+ issue = plugin.api.Issue.build
+
+ allow(issue).to receive(:key_value).and_return('WEB-134')
+ allow(dangerfile.github).to receive(:pr_json).and_return(pr_json)
+ allow(dangerfile.github).to receive(:pr_title).and_return(pr_title)
+
+ stub = stub_request(:post, url).
+ with(body: json)
+ result = plugin.pr_as_remotelink(issue, status: true)
+
+ expect(stub).to have_been_requested.once
+ expect(result).to be true
+ end
end
end
end
+# rubocop:enable Metrics/ModuleLength