2020-09-01 12:11:01 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Atlassian::JiraConnect::Serializers::RepositoryEntity do
|
2020-11-03 03:08:56 +00:00
|
|
|
let(:update_sequence_id) { nil }
|
|
|
|
|
2020-09-01 12:11:01 +00:00
|
|
|
subject do
|
|
|
|
project = create(:project, :repository)
|
|
|
|
commits = [project.commit]
|
|
|
|
branches = [project.repository.find_branch('master')]
|
|
|
|
merge_requests = [create(:merge_request, source_project: project, target_project: project)]
|
|
|
|
|
|
|
|
described_class.represent(
|
|
|
|
project,
|
|
|
|
commits: commits,
|
|
|
|
branches: branches,
|
2020-11-03 03:08:56 +00:00
|
|
|
merge_requests: merge_requests,
|
|
|
|
update_sequence_id: update_sequence_id
|
2020-09-01 12:11:01 +00:00
|
|
|
).to_json
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to match_schema('jira_connect/repository') }
|
2020-11-03 03:08:56 +00:00
|
|
|
|
|
|
|
context 'with custom update_sequence_id' do
|
|
|
|
let(:update_sequence_id) { 1.0 }
|
|
|
|
|
|
|
|
it 'passes the update_sequence_id on to the nested entities', :aggregate_failures do
|
|
|
|
parsed_subject = Gitlab::Json.parse(subject)
|
|
|
|
|
|
|
|
expect(parsed_subject['updateSequenceId']).to eq(update_sequence_id)
|
|
|
|
expect(parsed_subject['commits'].first['updateSequenceId']).to eq(update_sequence_id)
|
|
|
|
expect(parsed_subject['branches'].first['updateSequenceId']).to eq(update_sequence_id)
|
|
|
|
expect(parsed_subject['pullRequests'].first['updateSequenceId']).to eq(update_sequence_id)
|
|
|
|
end
|
|
|
|
end
|
2020-09-01 12:11:01 +00:00
|
|
|
end
|