diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/lib/atlassian | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/lib/atlassian')
-rw-r--r-- | spec/lib/atlassian/jira_connect/client_spec.rb | 66 | ||||
-rw-r--r-- | spec/lib/atlassian/jira_connect/serializers/feature_flag_entity_spec.rb | 5 |
2 files changed, 10 insertions, 61 deletions
diff --git a/spec/lib/atlassian/jira_connect/client_spec.rb b/spec/lib/atlassian/jira_connect/client_spec.rb index 21ee40f22fe..5c8d4282118 100644 --- a/spec/lib/atlassian/jira_connect/client_spec.rb +++ b/spec/lib/atlassian/jira_connect/client_spec.rb @@ -18,15 +18,15 @@ RSpec.describe Atlassian::JiraConnect::Client do end end - around do |example| - freeze_time { example.run } - end - describe '.generate_update_sequence_id' do - it 'returns monotonic_time converted it to integer' do - allow(Gitlab::Metrics::System).to receive(:monotonic_time).and_return(1.0) + it 'returns unix time in microseconds as integer', :aggregate_failures do + travel_to(Time.utc(1970, 1, 1, 0, 0, 1)) do + expect(described_class.generate_update_sequence_id).to eq(1000) + end - expect(described_class.generate_update_sequence_id).to eq(1) + travel_to(Time.utc(1970, 1, 1, 0, 0, 5)) do + expect(described_class.generate_update_sequence_id).to eq(5000) + end end end @@ -238,22 +238,6 @@ RSpec.describe Atlassian::JiraConnect::Client do expect(response['errorMessages']).to eq(%w(X Y Z)) end end - - it 'does not call the API if the feature flag is not enabled' do - stub_feature_flags(jira_sync_deployments: false) - - expect(subject).not_to receive(:post) - - subject.send(:store_deploy_info, project: project, deployments: deployments) - end - - it 'does call the API if the feature flag enabled for the project' do - stub_feature_flags(jira_sync_deployments: project) - - expect(subject).to receive(:post).with('/rest/deployments/0.1/bulk', { deployments: Array }).and_call_original - - subject.send(:store_deploy_info, project: project, deployments: deployments) - end end describe '#store_ff_info' do @@ -319,24 +303,6 @@ RSpec.describe Atlassian::JiraConnect::Client do expect(response['errorMessages']).to eq(['a: X', 'a: Y', 'b: Z']) end end - - it 'does not call the API if the feature flag is not enabled' do - stub_feature_flags(jira_sync_feature_flags: false) - - expect(subject).not_to receive(:post) - - subject.send(:store_ff_info, project: project, feature_flags: feature_flags) - end - - it 'does call the API if the feature flag enabled for the project' do - stub_feature_flags(jira_sync_feature_flags: project) - - expect(subject).to receive(:post).with('/rest/featureflags/0.1/bulk', { - flags: Array, properties: Hash - }).and_call_original - - subject.send(:store_ff_info, project: project, feature_flags: feature_flags) - end end describe '#store_build_info' do @@ -384,24 +350,6 @@ RSpec.describe Atlassian::JiraConnect::Client do subject.send(:store_build_info, project: project, pipelines: pipelines.take(1)) end - it 'does not call the API if the feature flag is not enabled' do - stub_feature_flags(jira_sync_builds: false) - - expect(subject).not_to receive(:post) - - subject.send(:store_build_info, project: project, pipelines: pipelines) - end - - it 'does call the API if the feature flag enabled for the project' do - stub_feature_flags(jira_sync_builds: project) - - expect(subject).to receive(:post) - .with('/rest/builds/0.1/bulk', { builds: Array }) - .and_call_original - - subject.send(:store_build_info, project: project, pipelines: pipelines) - end - context 'there are errors' do let(:failures) do [{ errors: [{ message: 'X' }, { message: 'Y' }] }, { errors: [{ message: 'Z' }] }] diff --git a/spec/lib/atlassian/jira_connect/serializers/feature_flag_entity_spec.rb b/spec/lib/atlassian/jira_connect/serializers/feature_flag_entity_spec.rb index 964801338cf..2d12cd1ed0a 100644 --- a/spec/lib/atlassian/jira_connect/serializers/feature_flag_entity_spec.rb +++ b/spec/lib/atlassian/jira_connect/serializers/feature_flag_entity_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Atlassian::JiraConnect::Serializers::FeatureFlagEntity do subject { described_class.represent(feature_flag) } context 'when the feature flag does not belong to any Jira issue' do - let_it_be(:feature_flag) { create(:operations_feature_flag) } + let_it_be(:feature_flag) { create(:operations_feature_flag, project: project) } describe '#issue_keys' do it 'is empty' do @@ -30,7 +30,7 @@ RSpec.describe Atlassian::JiraConnect::Serializers::FeatureFlagEntity do context 'when the feature flag does belong to a Jira issue' do let(:feature_flag) do - create(:operations_feature_flag, description: 'THING-123') + create(:operations_feature_flag, project: project, description: 'THING-123') end describe '#issue_keys' do @@ -66,6 +66,7 @@ RSpec.describe Atlassian::JiraConnect::Serializers::FeatureFlagEntity do end it 'has the correct summary' do + expect(entity.dig('summary', 'url')).to eq "http://localhost/#{project.full_path}/-/feature_flags/#{feature_flag.iid}/edit" expect(entity.dig('summary', 'status')).to eq( 'enabled' => true, 'defaultValue' => '', |