Commit aad0df7e authored by Robert Speicher's avatar Robert Speicher

Merge branch '5943_improve_license_management_tests' into 'master'

5943 improve license management tests

Closes #5943

See merge request gitlab-org/gitlab-ee!5718
parents b40594d5 b7a58d83
...@@ -16,8 +16,10 @@ describe MergeRequestWidgetEntity do ...@@ -16,8 +16,10 @@ describe MergeRequestWidgetEntity do
end end
it 'has blob path data' do it 'has blob path data' do
allow(merge_request).to receive(:base_pipeline).and_return(pipeline) allow(merge_request).to receive_messages(
allow(merge_request).to receive(:head_pipeline).and_return(pipeline) base_pipeline: pipeline,
head_pipeline: pipeline
)
expect(subject.as_json).to include(:blob_path) expect(subject.as_json).to include(:blob_path)
expect(subject.as_json[:blob_path]).to include(:base_path) expect(subject.as_json[:blob_path]).to include(:base_path)
...@@ -27,9 +29,11 @@ describe MergeRequestWidgetEntity do ...@@ -27,9 +29,11 @@ describe MergeRequestWidgetEntity do
it 'has performance data' do it 'has performance data' do
build = create(:ci_build, name: 'job') build = create(:ci_build, name: 'job')
allow(merge_request).to receive(:expose_performance_data?).and_return(true) allow(merge_request).to receive_messages(
allow(merge_request).to receive(:base_performance_artifact).and_return(build) expose_performance_data?: true,
allow(merge_request).to receive(:head_performance_artifact).and_return(build) base_performance_artifact: build,
head_performance_artifact: build
)
expect(subject.as_json).to include(:performance) expect(subject.as_json).to include(:performance)
end end
...@@ -37,10 +41,12 @@ describe MergeRequestWidgetEntity do ...@@ -37,10 +41,12 @@ describe MergeRequestWidgetEntity do
it 'has sast data' do it 'has sast data' do
build = create(:ci_build, name: 'sast', pipeline: pipeline) build = create(:ci_build, name: 'sast', pipeline: pipeline)
allow(merge_request).to receive(:expose_sast_data?).and_return(true) allow(merge_request).to receive_messages(
allow(merge_request).to receive(:base_has_sast_data?).and_return(true) expose_sast_data?: true,
allow(merge_request).to receive(:base_sast_artifact).and_return(build) base_has_sast_data?: true,
allow(merge_request).to receive(:head_sast_artifact).and_return(build) base_sast_artifact: build,
head_sast_artifact: build
)
expect(subject.as_json).to include(:sast) expect(subject.as_json).to include(:sast)
expect(subject.as_json[:sast]).to include(:head_path) expect(subject.as_json[:sast]).to include(:head_path)
...@@ -50,10 +56,12 @@ describe MergeRequestWidgetEntity do ...@@ -50,10 +56,12 @@ describe MergeRequestWidgetEntity do
it 'has dependency_scanning data' do it 'has dependency_scanning data' do
build = create(:ci_build, name: 'dependency_scanning', pipeline: pipeline) build = create(:ci_build, name: 'dependency_scanning', pipeline: pipeline)
allow(merge_request).to receive(:expose_dependency_scanning_data?).and_return(true) allow(merge_request).to receive_messages(
allow(merge_request).to receive(:base_has_dependency_scanning_data?).and_return(true) expose_dependency_scanning_data?: true,
allow(merge_request).to receive(:base_dependency_scanning_artifact).and_return(build) base_has_dependency_scanning_data?: true,
allow(merge_request).to receive(:head_dependency_scanning_artifact).and_return(build) base_dependency_scanning_artifact: build,
head_dependency_scanning_artifact: build
)
expect(subject.as_json).to include(:dependency_scanning) expect(subject.as_json).to include(:dependency_scanning)
expect(subject.as_json[:dependency_scanning]).to include(:head_path) expect(subject.as_json[:dependency_scanning]).to include(:head_path)
...@@ -63,10 +71,12 @@ describe MergeRequestWidgetEntity do ...@@ -63,10 +71,12 @@ describe MergeRequestWidgetEntity do
it 'has license_management data' do it 'has license_management data' do
build = create(:ci_build, name: 'license_management', pipeline: pipeline) build = create(:ci_build, name: 'license_management', pipeline: pipeline)
allow(merge_request).to receive(:expose_license_management_data?).and_return(true) allow(merge_request).to receive_messages(
allow(merge_request).to receive(:base_has_license_management_data?).and_return(true) expose_license_management_data?: true,
allow(merge_request).to receive(:base_license_management_artifact).and_return(build) base_has_license_management_data?: true,
allow(merge_request).to receive(:head_license_management_artifact).and_return(build) base_license_management_artifact: build,
head_license_management_artifact: build
)
expect(subject.as_json).to include(:license_management) expect(subject.as_json).to include(:license_management)
expect(subject.as_json[:license_management]).to include(:head_path) expect(subject.as_json[:license_management]).to include(:head_path)
...@@ -76,10 +86,12 @@ describe MergeRequestWidgetEntity do ...@@ -76,10 +86,12 @@ describe MergeRequestWidgetEntity do
it 'has sast_container data' do it 'has sast_container data' do
build = create(:ci_build, name: 'sast:image', pipeline: pipeline) build = create(:ci_build, name: 'sast:image', pipeline: pipeline)
allow(merge_request).to receive(:expose_sast_container_data?).and_return(true) allow(merge_request).to receive_messages(
allow(merge_request).to receive(:base_has_sast_container_data?).and_return(true) expose_sast_container_data?: true,
allow(merge_request).to receive(:base_sast_container_artifact).and_return(build) base_has_sast_container_data?: true,
allow(merge_request).to receive(:head_sast_container_artifact).and_return(build) base_sast_container_artifact: build,
head_sast_container_artifact: build
)
expect(subject.as_json).to include(:sast_container) expect(subject.as_json).to include(:sast_container)
expect(subject.as_json[:sast_container]).to include(:head_path) expect(subject.as_json[:sast_container]).to include(:head_path)
...@@ -89,10 +101,12 @@ describe MergeRequestWidgetEntity do ...@@ -89,10 +101,12 @@ describe MergeRequestWidgetEntity do
it 'has dast data' do it 'has dast data' do
build = create(:ci_build, name: 'dast', pipeline: pipeline) build = create(:ci_build, name: 'dast', pipeline: pipeline)
allow(merge_request).to receive(:expose_dast_data?).and_return(true) allow(merge_request).to receive_messages(
allow(merge_request).to receive(:base_has_dast_data?).and_return(true) expose_dast_data?: true,
allow(merge_request).to receive(:base_dast_artifact).and_return(build) base_has_dast_data?: true,
allow(merge_request).to receive(:head_dast_artifact).and_return(build) base_dast_artifact: build,
head_dast_artifact: build
)
expect(subject.as_json).to include(:dast) expect(subject.as_json).to include(:dast)
expect(subject.as_json[:dast]).to include(:head_path) expect(subject.as_json[:dast]).to include(:head_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment