diff options
Diffstat (limited to 'spec/lib/atlassian/jira_connect/client_spec.rb')
-rw-r--r-- | spec/lib/atlassian/jira_connect/client_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/atlassian/jira_connect/client_spec.rb b/spec/lib/atlassian/jira_connect/client_spec.rb new file mode 100644 index 00000000000..40ffec21b26 --- /dev/null +++ b/spec/lib/atlassian/jira_connect/client_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Atlassian::JiraConnect::Client do + include StubRequests + + subject { described_class.new('https://gitlab-test.atlassian.net', 'sample_secret') } + + around do |example| + Timecop.freeze { example.run } + end + + describe '#store_dev_info' do + it "calls the API with auth headers" do + expected_jwt = Atlassian::Jwt.encode( + Atlassian::Jwt.build_claims( + Atlassian::JiraConnect.app_key, + '/rest/devinfo/0.10/bulk', + 'POST' + ), + 'sample_secret' + ) + + stub_full_request('https://gitlab-test.atlassian.net/rest/devinfo/0.10/bulk', method: :post) + .with( + headers: { + 'Authorization' => "JWT #{expected_jwt}", + 'Content-Type' => 'application/json' + } + ) + + subject.store_dev_info(project: create(:project)) + end + end +end |