diff options
39 files changed, 149 insertions, 171 deletions
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index ebf28dc842c..7b4832b84a8 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -265,6 +265,7 @@ class JiraService < IssueTrackerService def find_remote_link(issue, url) links = jira_request { issue.remotelink.all } + return unless links links.find { |link| link.object["url"] == url } end diff --git a/app/services/projects/after_import_service.rb b/app/services/projects/after_import_service.rb index afb9048e87b..bbdde4408d2 100644 --- a/app/services/projects/after_import_service.rb +++ b/app/services/projects/after_import_service.rb @@ -9,7 +9,7 @@ module Projects end def execute - Projects::HousekeepingService.new(@project, :gc).execute do + Projects::HousekeepingService.new(@project).execute do repository.delete_all_refs_except(RESERVED_REF_PREFIXES) end rescue Projects::HousekeepingService::LeaseTaken => e diff --git a/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb b/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb index 05974948505..9b72480d18b 100644 --- a/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb +++ b/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb @@ -37,7 +37,17 @@ module Projects raise DownloadLinksError, response.message unless response.success? - parse_response_links(response['objects']) + # Since the LFS Batch API may return a Content-Ttpe of + # application/vnd.git-lfs+json + # (https://github.com/git-lfs/git-lfs/blob/master/docs/api/batch.md#requests), + # HTTParty does not know this is actually JSON. + data = JSON.parse(response.body) + + raise DownloadLinksError, "LFS Batch API did return any objects" unless data.is_a?(Hash) && data.key?('objects') + + parse_response_links(data['objects']) + rescue JSON::ParserError + raise DownloadLinksError, "LFS Batch API response is not JSON" end def parse_response_links(objects_response) diff --git a/changelogs/unreleased/60180-jira-service-fix-nil-on-find-call.yml b/changelogs/unreleased/60180-jira-service-fix-nil-on-find-call.yml new file mode 100644 index 00000000000..6891a9ca83c --- /dev/null +++ b/changelogs/unreleased/60180-jira-service-fix-nil-on-find-call.yml @@ -0,0 +1,5 @@ +--- +title: 'Resolved JIRA service: NoMethodError: undefined method ''find'' for nil:NilClass' +merge_request: 28206 +author: +type: fixed diff --git a/changelogs/unreleased/sh-fix-lfs-download-errors.yml b/changelogs/unreleased/sh-fix-lfs-download-errors.yml new file mode 100644 index 00000000000..ad67df6bb06 --- /dev/null +++ b/changelogs/unreleased/sh-fix-lfs-download-errors.yml @@ -0,0 +1,5 @@ +--- +title: Properly handle LFS Batch API response in project import +merge_request: 28223 +author: +type: fixed diff --git a/doc/user/admin_area/settings/continuous_integration.md b/doc/user/admin_area/settings/continuous_integration.md index 834a1e2423a..42fc4efa4ce 100644 --- a/doc/user/admin_area/settings/continuous_integration.md +++ b/doc/user/admin_area/settings/continuous_integration.md @@ -98,8 +98,7 @@ the group. NOTE: **Note:** Only available on GitLab.com. -If you have a Group with a [paid plan](https://about.gitlab.com/pricing/#gitlab-com) on GitLab.com, -then you can purchase additional CI minutes so your pipelines will not be blocked after you have +You can purchase additional CI minutes so your pipelines will not be blocked after you have used all your CI minutes from your main quota. In order to purchase additional minutes, you should follow these steps: diff --git a/spec/javascripts/fixtures/abuse_reports.rb b/spec/javascripts/fixtures/abuse_reports.rb index 54b6419bcdb..e0aaecf626a 100644 --- a/spec/javascripts/fixtures/abuse_reports.rb +++ b/spec/javascripts/fixtures/abuse_reports.rb @@ -18,10 +18,9 @@ describe Admin::AbuseReportsController, '(JavaScript fixtures)', type: :controll sign_in(admin) end - it 'abuse_reports/abuse_reports_list.html' do |example| + it 'abuse_reports/abuse_reports_list.html' do get :index expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/admin_users.rb b/spec/javascripts/fixtures/admin_users.rb index 76dbdf603da..22a5de66577 100644 --- a/spec/javascripts/fixtures/admin_users.rb +++ b/spec/javascripts/fixtures/admin_users.rb @@ -17,13 +17,12 @@ describe Admin::UsersController, '(JavaScript fixtures)', type: :controller do clean_frontend_fixtures('admin/users') end - it 'admin/users/new_with_internal_user_regex.html' do |example| + it 'admin/users/new_with_internal_user_regex.html' do stub_application_setting(user_default_external: true) stub_application_setting(user_default_internal_regex: '^(?:(?!\.ext@).)*$\r?') get :new expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/application_settings.rb b/spec/javascripts/fixtures/application_settings.rb index c535e598e12..d4651fa6ece 100644 --- a/spec/javascripts/fixtures/application_settings.rb +++ b/spec/javascripts/fixtures/application_settings.rb @@ -23,12 +23,11 @@ describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', type: :c remove_repository(project) end - it 'application_settings/accounts_and_limit.html' do |example| + it 'application_settings/accounts_and_limit.html' do stub_application_setting(user_default_external: false) get :show expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/autocomplete_sources.rb b/spec/javascripts/fixtures/autocomplete_sources.rb index c117fb7cd24..b20a0159d7d 100644 --- a/spec/javascripts/fixtures/autocomplete_sources.rb +++ b/spec/javascripts/fixtures/autocomplete_sources.rb @@ -18,7 +18,7 @@ describe Projects::AutocompleteSourcesController, '(JavaScript fixtures)', type: sign_in(admin) end - it 'autocomplete_sources/labels.json' do |example| + it 'autocomplete_sources/labels.json' do issue.labels << create(:label, project: project, title: 'bug') issue.labels << create(:label, project: project, title: 'critical') @@ -35,6 +35,5 @@ describe Projects::AutocompleteSourcesController, '(JavaScript fixtures)', type: } expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/balsamiq.rb b/spec/javascripts/fixtures/balsamiq.rb deleted file mode 100644 index 234e246119a..00000000000 --- a/spec/javascripts/fixtures/balsamiq.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe 'Balsamiq file', '(JavaScript fixtures)', type: :controller do - include JavaScriptFixturesHelpers - - let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} - let(:project) { create(:project, :repository, namespace: namespace, path: 'balsamiq-project') } - - before(:all) do - clean_frontend_fixtures('blob/balsamiq/') - end - - it 'blob/balsamiq/test.bmpr' do |example| - blob = project.repository.blob_at('b89b56d79', 'files/images/balsamiq.bmpr') - - store_frontend_fixture(blob.data.force_encoding('utf-8'), example.description) - end -end diff --git a/spec/javascripts/fixtures/blob.rb b/spec/javascripts/fixtures/blob.rb index db7749bc000..07670552cd5 100644 --- a/spec/javascripts/fixtures/blob.rb +++ b/spec/javascripts/fixtures/blob.rb @@ -22,7 +22,7 @@ describe Projects::BlobController, '(JavaScript fixtures)', type: :controller do remove_repository(project) end - it 'blob/show.html' do |example| + it 'blob/show.html' do get(:show, params: { namespace_id: project.namespace, project_id: project, @@ -30,6 +30,5 @@ describe Projects::BlobController, '(JavaScript fixtures)', type: :controller do }) expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/boards.rb b/spec/javascripts/fixtures/boards.rb index c4390e89578..5835721d3d5 100644 --- a/spec/javascripts/fixtures/boards.rb +++ b/spec/javascripts/fixtures/boards.rb @@ -17,13 +17,12 @@ describe Projects::BoardsController, '(JavaScript fixtures)', type: :controller sign_in(admin) end - it 'boards/show.html' do |example| + it 'boards/show.html' do get(:index, params: { namespace_id: project.namespace, project_id: project }) expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/branches.rb b/spec/javascripts/fixtures/branches.rb index 5d2d6c7ec0e..204aa9b7c7a 100644 --- a/spec/javascripts/fixtures/branches.rb +++ b/spec/javascripts/fixtures/branches.rb @@ -21,13 +21,12 @@ describe Projects::BranchesController, '(JavaScript fixtures)', type: :controlle remove_repository(project) end - it 'branches/new_branch.html' do |example| + it 'branches/new_branch.html' do get :new, params: { namespace_id: project.namespace.to_param, project_id: project } expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/clusters.rb b/spec/javascripts/fixtures/clusters.rb index 8ebd8a41366..1076404e0e3 100644 --- a/spec/javascripts/fixtures/clusters.rb +++ b/spec/javascripts/fixtures/clusters.rb @@ -22,7 +22,7 @@ describe Projects::ClustersController, '(JavaScript fixtures)', type: :controlle remove_repository(project) end - it 'clusters/show_cluster.html' do |example| + it 'clusters/show_cluster.html' do get :show, params: { namespace_id: project.namespace.to_param, project_id: project, @@ -30,6 +30,5 @@ describe Projects::ClustersController, '(JavaScript fixtures)', type: :controlle } expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/commit.rb b/spec/javascripts/fixtures/commit.rb index ab10f559e4b..ff9a4bc1adc 100644 --- a/spec/javascripts/fixtures/commit.rb +++ b/spec/javascripts/fixtures/commit.rb @@ -19,7 +19,7 @@ describe Projects::CommitController, '(JavaScript fixtures)', type: :controller allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon') end - it 'commit/show.html' do |example| + it 'commit/show.html' do params = { namespace_id: project.namespace, project_id: project, @@ -29,6 +29,5 @@ describe Projects::CommitController, '(JavaScript fixtures)', type: :controller get :show, params: params expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/deploy_keys.rb b/spec/javascripts/fixtures/deploy_keys.rb index a333d9c0150..38eab853da2 100644 --- a/spec/javascripts/fixtures/deploy_keys.rb +++ b/spec/javascripts/fixtures/deploy_keys.rb @@ -24,7 +24,7 @@ describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :control render_views - it 'deploy_keys/keys.json' do |example| + it 'deploy_keys/keys.json' do create(:rsa_deploy_key_2048, public: true) project_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCdMHEHyhRjbhEZVddFn6lTWdgEy5Q6Bz4nwGB76xWZI5YT/1WJOMEW+sL5zYd31kk7sd3FJ5L9ft8zWMWrr/iWXQikC2cqZK24H1xy+ZUmrRuJD4qGAaIVoyyzBL+avL+lF8J5lg6YSw8gwJY/lX64/vnJHUlWw2n5BF8IFOWhiw== dummy@gitlab.com') internal_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNd/UJWhPrpb+b/G5oL109y57yKuCxE+WUGJGYaj7WQKsYRJmLYh1mgjrl+KVyfsWpq4ylOxIfFSnN9xBBFN8mlb0Fma5DC7YsSsibJr3MZ19ZNBprwNcdogET7aW9I0In7Wu5f2KqI6e5W/spJHCy4JVxzVMUvk6Myab0LnJ2iQ== dummy@gitlab.com') @@ -39,6 +39,5 @@ describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :control }, format: :json expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/groups.rb b/spec/javascripts/fixtures/groups.rb index 16e31028b05..4d0afc3ce1a 100644 --- a/spec/javascripts/fixtures/groups.rb +++ b/spec/javascripts/fixtures/groups.rb @@ -18,20 +18,18 @@ describe 'Groups (JavaScript fixtures)', type: :controller do end describe GroupsController, '(JavaScript fixtures)', type: :controller do - it 'groups/edit.html' do |example| + it 'groups/edit.html' do get :edit, params: { id: group } expect(response).to be_success - store_frontend_fixture(response, example.description) end end describe Groups::Settings::CiCdController, '(JavaScript fixtures)', type: :controller do - it 'groups/ci_cd_settings.html' do |example| + it 'groups/ci_cd_settings.html' do get :show, params: { group_id: group } expect(response).to be_success - store_frontend_fixture(response, example.description) end end end diff --git a/spec/javascripts/fixtures/issues.rb b/spec/javascripts/fixtures/issues.rb index 0f3f9a10f94..d8d77f767de 100644 --- a/spec/javascripts/fixtures/issues.rb +++ b/spec/javascripts/fixtures/issues.rb @@ -21,26 +21,26 @@ describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller remove_repository(project) end - it 'issues/open-issue.html' do |example| - render_issue(example.description, create(:issue, project: project)) + it 'issues/open-issue.html' do + render_issue(create(:issue, project: project)) end - it 'issues/closed-issue.html' do |example| - render_issue(example.description, create(:closed_issue, project: project)) + it 'issues/closed-issue.html' do + render_issue(create(:closed_issue, project: project)) end - it 'issues/issue-with-task-list.html' do |example| + it 'issues/issue-with-task-list.html' do issue = create(:issue, project: project, description: '- [ ] Task List Item') - render_issue(example.description, issue) + render_issue(issue) end - it 'issues/issue_with_comment.html' do |example| + it 'issues/issue_with_comment.html' do issue = create(:issue, project: project) create(:note, project: project, noteable: issue, note: '- [ ] Task List Item').save - render_issue(example.description, issue) + render_issue(issue) end - it 'issues/issue_list.html' do |example| + it 'issues/issue_list.html' do create(:issue, project: project) get :index, params: { @@ -49,12 +49,11 @@ describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller } expect(response).to be_success - store_frontend_fixture(response, example.description) end private - def render_issue(fixture_file_name, issue) + def render_issue(issue) get :show, params: { namespace_id: project.namespace.to_param, project_id: project, @@ -62,7 +61,6 @@ describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller } expect(response).to be_success - store_frontend_fixture(response, fixture_file_name) end end @@ -89,7 +87,7 @@ describe API::Issues, '(JavaScript fixtures)', type: :request do end end - it 'issues/related_merge_requests.json' do |example| + it 'issues/related_merge_requests.json' do user = create(:user) project = create(:project, :public, creator_id: user.id, namespace: user.namespace) issue_title = 'foo' @@ -120,6 +118,5 @@ describe API::Issues, '(JavaScript fixtures)', type: :request do get_related_merge_requests(project.id, issue.iid, user) expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/jobs.rb b/spec/javascripts/fixtures/jobs.rb index 941235190b5..46ccd6f8c8a 100644 --- a/spec/javascripts/fixtures/jobs.rb +++ b/spec/javascripts/fixtures/jobs.rb @@ -32,7 +32,7 @@ describe Projects::JobsController, '(JavaScript fixtures)', type: :controller do remove_repository(project) end - it 'builds/build-with-artifacts.html' do |example| + it 'builds/build-with-artifacts.html' do get :show, params: { namespace_id: project.namespace.to_param, project_id: project, @@ -40,10 +40,9 @@ describe Projects::JobsController, '(JavaScript fixtures)', type: :controller do } expect(response).to be_success - store_frontend_fixture(response, example.description) end - it 'jobs/delayed.json' do |example| + it 'jobs/delayed.json' do get :show, params: { namespace_id: project.namespace.to_param, project_id: project, @@ -51,6 +50,5 @@ describe Projects::JobsController, '(JavaScript fixtures)', type: :controller do }, format: :json expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/labels.rb b/spec/javascripts/fixtures/labels.rb index 9420194e675..4d1b7317274 100644 --- a/spec/javascripts/fixtures/labels.rb +++ b/spec/javascripts/fixtures/labels.rb @@ -30,13 +30,12 @@ describe 'Labels (JavaScript fixtures)' do sign_in(admin) end - it 'labels/group_labels.json' do |example| + it 'labels/group_labels.json' do get :index, params: { group_id: group }, format: 'json' expect(response).to be_success - store_frontend_fixture(response, example.description) end end @@ -47,14 +46,13 @@ describe 'Labels (JavaScript fixtures)' do sign_in(admin) end - it 'labels/project_labels.json' do |example| + it 'labels/project_labels.json' do get :index, params: { namespace_id: group, project_id: project }, format: 'json' expect(response).to be_success - store_frontend_fixture(response, example.description) end end end diff --git a/spec/javascripts/fixtures/merge_requests.rb b/spec/javascripts/fixtures/merge_requests.rb index 7df1e5cb512..05860be2291 100644 --- a/spec/javascripts/fixtures/merge_requests.rb +++ b/spec/javascripts/fixtures/merge_requests.rb @@ -42,52 +42,52 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont remove_repository(project) end - it 'merge_requests/merge_request_of_current_user.html' do |example| + it 'merge_requests/merge_request_of_current_user.html' do merge_request.update(author: admin) - render_merge_request(example.description, merge_request) + render_merge_request(merge_request) end - it 'merge_requests/merge_request_with_task_list.html' do |example| + it 'merge_requests/merge_request_with_task_list.html' do create(:ci_build, :pending, pipeline: pipeline) - render_merge_request(example.description, merge_request) + render_merge_request(merge_request) end - it 'merge_requests/merged_merge_request.html' do |example| + it 'merge_requests/merged_merge_request.html' do expect_next_instance_of(MergeRequest) do |merge_request| allow(merge_request).to receive(:source_branch_exists?).and_return(true) allow(merge_request).to receive(:can_remove_source_branch?).and_return(true) end - render_merge_request(example.description, merged_merge_request) + render_merge_request(merged_merge_request) end - it 'merge_requests/diff_comment.html' do |example| + it 'merge_requests/diff_comment.html' do create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) create(:note_on_merge_request, author: admin, project: project, noteable: merge_request) - render_merge_request(example.description, merge_request) + render_merge_request(merge_request) end - it 'merge_requests/merge_request_with_comment.html' do |example| + it 'merge_requests/merge_request_with_comment.html' do create(:note_on_merge_request, author: admin, project: project, noteable: merge_request, note: '- [ ] Task List Item') - render_merge_request(example.description, merge_request) + render_merge_request(merge_request) end - it 'merge_requests/discussions.json' do |example| + it 'merge_requests/discussions.json' do create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) - render_discussions_json(merge_request, example.description) + render_discussions_json(merge_request) end - it 'merge_requests/diff_discussion.json' do |example| + it 'merge_requests/diff_discussion.json' do create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) - render_discussions_json(merge_request, example.description) + render_discussions_json(merge_request) end - it 'merge_requests/resolved_diff_discussion.json' do |example| + it 'merge_requests/resolved_diff_discussion.json' do note = create(:discussion_note_on_merge_request, :resolved, project: project, author: admin, position: position, noteable: merge_request) create(:system_note, project: project, author: admin, noteable: merge_request, discussion_id: note.discussion.id) - render_discussions_json(merge_request, example.description) + render_discussions_json(merge_request) end context 'with image diff' do @@ -106,25 +106,23 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont ) end - it 'merge_requests/image_diff_discussion.json' do |example| + it 'merge_requests/image_diff_discussion.json' do create(:diff_note_on_merge_request, project: project, noteable: merge_request2, position: image_position) - render_discussions_json(merge_request2, example.description) + render_discussions_json(merge_request2) end end private - def render_discussions_json(merge_request, fixture_file_name) + def render_discussions_json(merge_request) get :discussions, params: { namespace_id: project.namespace.to_param, project_id: project, id: merge_request.to_param }, format: :json - - store_frontend_fixture(response, fixture_file_name) end - def render_merge_request(fixture_file_name, merge_request) + def render_merge_request(merge_request) get :show, params: { namespace_id: project.namespace.to_param, project_id: project, @@ -132,6 +130,5 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont }, format: :html expect(response).to be_success - store_frontend_fixture(response, fixture_file_name) end end diff --git a/spec/javascripts/fixtures/merge_requests_diffs.rb b/spec/javascripts/fixtures/merge_requests_diffs.rb index 57462e74bb2..03b9b713fd8 100644 --- a/spec/javascripts/fixtures/merge_requests_diffs.rb +++ b/spec/javascripts/fixtures/merge_requests_diffs.rb @@ -34,29 +34,29 @@ describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type remove_repository(project) end - it 'merge_request_diffs/with_commit.json' do |example| + it 'merge_request_diffs/with_commit.json' do # Create a user that matches the selected commit author # This is so that the "author" information will be populated create(:user, email: selected_commit.author_email, name: selected_commit.author_name) - render_merge_request(example.description, merge_request, commit_id: selected_commit.sha) + render_merge_request(merge_request, commit_id: selected_commit.sha) end - it 'merge_request_diffs/inline_changes_tab_with_comments.json' do |example| + it 'merge_request_diffs/inline_changes_tab_with_comments.json' do create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) create(:note_on_merge_request, author: admin, project: project, noteable: merge_request) - render_merge_request(example.description, merge_request) + render_merge_request(merge_request) end - it 'merge_request_diffs/parallel_changes_tab_with_comments.json' do |example| + it 'merge_request_diffs/parallel_changes_tab_with_comments.json' do create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request) create(:note_on_merge_request, author: admin, project: project, noteable: merge_request) - render_merge_request(example.description, merge_request, view: 'parallel') + render_merge_request(merge_request, view: 'parallel') end private - def render_merge_request(fixture_file_name, merge_request, view: 'inline', **extra_params) + def render_merge_request(merge_request, view: 'inline', **extra_params) get :show, params: { namespace_id: project.namespace.to_param, project_id: project, @@ -66,6 +66,5 @@ describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type }, format: :json expect(response).to be_success - store_frontend_fixture(response, fixture_file_name) end end diff --git a/spec/javascripts/fixtures/pdf.rb b/spec/javascripts/fixtures/pdf.rb deleted file mode 100644 index ef9976b9fd3..00000000000 --- a/spec/javascripts/fixtures/pdf.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe 'PDF file', '(JavaScript fixtures)', type: :controller do - include JavaScriptFixturesHelpers - - let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} - let(:project) { create(:project, :repository, namespace: namespace, path: 'pdf-project') } - - before(:all) do - clean_frontend_fixtures('blob/pdf/') - end - - it 'blob/pdf/test.pdf' do |example| - blob = project.repository.blob_at('e774ebd33', 'files/pdf/test.pdf') - - store_frontend_fixture(blob.data.force_encoding("utf-8"), example.description) - end -end diff --git a/spec/javascripts/fixtures/pipeline_schedules.rb b/spec/javascripts/fixtures/pipeline_schedules.rb index e5176a58273..aecd56e6198 100644 --- a/spec/javascripts/fixtures/pipeline_schedules.rb +++ b/spec/javascripts/fixtures/pipeline_schedules.rb @@ -21,7 +21,7 @@ describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', type: : sign_in(admin) end - it 'pipeline_schedules/edit.html' do |example| + it 'pipeline_schedules/edit.html' do get :edit, params: { namespace_id: project.namespace.to_param, project_id: project, @@ -29,10 +29,9 @@ describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', type: : } expect(response).to be_success - store_frontend_fixture(response, example.description) end - it 'pipeline_schedules/edit_with_variables.html' do |example| + it 'pipeline_schedules/edit_with_variables.html' do get :edit, params: { namespace_id: project.namespace.to_param, project_id: project, @@ -40,6 +39,5 @@ describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', type: : } expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/pipelines.rb b/spec/javascripts/fixtures/pipelines.rb index 42b552e81c0..de6fcfe10f4 100644 --- a/spec/javascripts/fixtures/pipelines.rb +++ b/spec/javascripts/fixtures/pipelines.rb @@ -23,13 +23,12 @@ describe Projects::PipelinesController, '(JavaScript fixtures)', type: :controll sign_in(admin) end - it 'pipelines/pipelines.json' do |example| + it 'pipelines/pipelines.json' do get :index, params: { namespace_id: namespace, project_id: project }, format: :json expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/projects.rb b/spec/javascripts/fixtures/projects.rb index 446da83a7f9..94c59207898 100644 --- a/spec/javascripts/fixtures/projects.rb +++ b/spec/javascripts/fixtures/projects.rb @@ -28,49 +28,45 @@ describe 'Projects (JavaScript fixtures)', type: :controller do end describe ProjectsController, '(JavaScript fixtures)', type: :controller do - it 'projects/dashboard.html' do |example| + it 'projects/dashboard.html' do get :show, params: { namespace_id: project.namespace.to_param, id: project } expect(response).to be_success - store_frontend_fixture(response, example.description) end - it 'projects/overview.html' do |example| + it 'projects/overview.html' do get :show, params: { namespace_id: project_with_repo.namespace.to_param, id: project_with_repo } expect(response).to be_success - store_frontend_fixture(response, example.description) end - it 'projects/edit.html' do |example| + it 'projects/edit.html' do get :edit, params: { namespace_id: project.namespace.to_param, id: project } expect(response).to be_success - store_frontend_fixture(response, example.description) end end describe Projects::Settings::CiCdController, '(JavaScript fixtures)', type: :controller do - it 'projects/ci_cd_settings.html' do |example| + it 'projects/ci_cd_settings.html' do get :show, params: { namespace_id: project.namespace.to_param, project_id: project } expect(response).to be_success - store_frontend_fixture(response, example.description) end - it 'projects/ci_cd_settings_with_variables.html' do |example| + it 'projects/ci_cd_settings_with_variables.html' do create(:ci_variable, project: project_variable_populated) create(:ci_variable, project: project_variable_populated) @@ -80,7 +76,6 @@ describe 'Projects (JavaScript fixtures)', type: :controller do } expect(response).to be_success - store_frontend_fixture(response, example.description) end end end diff --git a/spec/javascripts/fixtures/prometheus_service.rb b/spec/javascripts/fixtures/prometheus_service.rb index 29dc95305b7..f3171fdd97b 100644 --- a/spec/javascripts/fixtures/prometheus_service.rb +++ b/spec/javascripts/fixtures/prometheus_service.rb @@ -22,7 +22,7 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle remove_repository(project) end - it 'services/prometheus/prometheus_service.html' do |example| + it 'services/prometheus/prometheus_service.html' do get :edit, params: { namespace_id: namespace, project_id: project, @@ -30,6 +30,5 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle } expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/raw.rb b/spec/javascripts/fixtures/raw.rb index 82770beb39b..801c80a0112 100644 --- a/spec/javascripts/fixtures/raw.rb +++ b/spec/javascripts/fixtures/raw.rb @@ -1,34 +1,39 @@ require 'spec_helper' -describe 'Raw files', '(JavaScript fixtures)', type: :controller do +describe 'Raw files', '(JavaScript fixtures)' do include JavaScriptFixturesHelpers let(:namespace) { create(:namespace, name: 'frontend-fixtures' )} let(:project) { create(:project, :repository, namespace: namespace, path: 'raw-project') } + let(:response) { @blob.data.force_encoding('UTF-8') } before(:all) do + clean_frontend_fixtures('blob/balsamiq/') clean_frontend_fixtures('blob/notebook/') + clean_frontend_fixtures('blob/pdf/') end after do remove_repository(project) end - it 'blob/notebook/basic.json' do |example| - blob = project.repository.blob_at('6d85bb69', 'files/ipython/basic.ipynb') - - store_frontend_fixture(blob.data, example.description) + it 'blob/balsamiq/test.bmpr' do + @blob = project.repository.blob_at('b89b56d79', 'files/images/balsamiq.bmpr') end - it 'blob/notebook/worksheets.json' do |example| - blob = project.repository.blob_at('6d85bb69', 'files/ipython/worksheets.ipynb') + it 'blob/notebook/basic.json' do + @blob = project.repository.blob_at('6d85bb69', 'files/ipython/basic.ipynb') + end - store_frontend_fixture(blob.data, example.description) + it 'blob/notebook/worksheets.json' do + @blob = project.repository.blob_at('6d85bb69', 'files/ipython/worksheets.ipynb') end - it 'blob/notebook/math.json' do |example| - blob = project.repository.blob_at('93ee732', 'files/ipython/math.ipynb') + it 'blob/notebook/math.json' do + @blob = project.repository.blob_at('93ee732', 'files/ipython/math.ipynb') + end - store_frontend_fixture(blob.data, example.description) + it 'blob/pdf/test.pdf' do + @blob = project.repository.blob_at('e774ebd33', 'files/pdf/test.pdf') end end diff --git a/spec/javascripts/fixtures/search.rb b/spec/javascripts/fixtures/search.rb index 5f5b4d4e60d..22fc546d761 100644 --- a/spec/javascripts/fixtures/search.rb +++ b/spec/javascripts/fixtures/search.rb @@ -9,10 +9,9 @@ describe SearchController, '(JavaScript fixtures)', type: :controller do clean_frontend_fixtures('search/') end - it 'search/show.html' do |example| + it 'search/show.html' do get :show expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/services.rb b/spec/javascripts/fixtures/services.rb index dc7ee484c22..2237702ccca 100644 --- a/spec/javascripts/fixtures/services.rb +++ b/spec/javascripts/fixtures/services.rb @@ -22,7 +22,7 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle remove_repository(project) end - it 'services/edit_service.html' do |example| + it 'services/edit_service.html' do get :edit, params: { namespace_id: namespace, project_id: project, @@ -30,6 +30,5 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle } expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/sessions.rb b/spec/javascripts/fixtures/sessions.rb index 8656dea696a..92b74c01c89 100644 --- a/spec/javascripts/fixtures/sessions.rb +++ b/spec/javascripts/fixtures/sessions.rb @@ -16,11 +16,10 @@ describe 'Sessions (JavaScript fixtures)' do set_devise_mapping(context: @request) end - it 'sessions/new.html' do |example| + it 'sessions/new.html' do get :new expect(response).to be_success - store_frontend_fixture(response, example.description) end end end diff --git a/spec/javascripts/fixtures/snippet.rb b/spec/javascripts/fixtures/snippet.rb index ebc5b793166..ace84b14eb7 100644 --- a/spec/javascripts/fixtures/snippet.rb +++ b/spec/javascripts/fixtures/snippet.rb @@ -23,12 +23,11 @@ describe SnippetsController, '(JavaScript fixtures)', type: :controller do remove_repository(project) end - it 'snippets/show.html' do |example| + it 'snippets/show.html' do create(:discussion_note_on_snippet, noteable: snippet, project: project, author: admin, note: '- [ ] Task List Item') get(:show, params: { id: snippet.to_param }) expect(response).to be_success - store_frontend_fixture(response, example.description) end end diff --git a/spec/javascripts/fixtures/todos.rb b/spec/javascripts/fixtures/todos.rb index 6e37a2e5a4c..d0c8a6eca01 100644 --- a/spec/javascripts/fixtures/todos.rb +++ b/spec/javascripts/fixtures/todos.rb @@ -26,11 +26,10 @@ describe 'Todos (JavaScript fixtures)' do sign_in(admin) end - it 'todos/todos.html' do |example| + it 'todos/todos.html' do get :index expect(response).to be_success - store_frontend_fixture(response, example.description) end end @@ -41,7 +40,7 @@ describe 'Todos (JavaScript fixtures)' do sign_in(admin) end - it 'todos/todos.json' do |example| + it 'todos/todos.json' do post :create, params: { namespace_id: namespace, project_id: project, @@ -50,7 +49,6 @@ describe 'Todos (JavaScript fixtures)' do }, format: 'json' expect(response).to be_success - store_frontend_fixture(response, example.description) end end end diff --git a/spec/javascripts/fixtures/u2f.rb b/spec/javascripts/fixtures/u2f.rb index 15866d65a4f..f52832b6efb 100644 --- a/spec/javascripts/fixtures/u2f.rb +++ b/spec/javascripts/fixtures/u2f.rb @@ -18,13 +18,12 @@ context 'U2F' do set_devise_mapping(context: @request) end - it 'u2f/authenticate.html' do |example| + it 'u2f/authenticate.html' do allow(controller).to receive(:find_user).and_return(user) post :create, params: { user: { login: user.username, password: user.password } } expect(response).to be_success - store_frontend_fixture(response, example.description) end end @@ -36,11 +35,10 @@ context 'U2F' do allow_any_instance_of(Profiles::TwoFactorAuthsController).to receive(:build_qr_code).and_return('qrcode:blackandwhitesquares') end - it 'u2f/register.html' do |example| + it 'u2f/register.html' do get :show expect(response).to be_success - store_frontend_fixture(response, example.description) end end end diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index 4a7eee1fbf3..04ae9390436 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -166,6 +166,13 @@ describe JiraService do ).once end + it 'does not fail if remote_link.all on issue returns nil' do + allow(JIRA::Resource::Remotelink).to receive(:all).and_return(nil) + + expect { @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project)) } + .not_to raise_error(NoMethodError) + end + # Check https://developer.atlassian.com/jiradev/jira-platform/guides/other/guide-jira-remote-issue-links/fields-in-remote-issue-links # for more information it 'creates Remote Link reference in JIRA for comment' do diff --git a/spec/services/projects/after_import_service_spec.rb b/spec/services/projects/after_import_service_spec.rb index 95c11f71c5e..51d3fd18881 100644 --- a/spec/services/projects/after_import_service_spec.rb +++ b/spec/services/projects/after_import_service_spec.rb @@ -15,7 +15,7 @@ describe Projects::AfterImportService do describe '#execute' do before do allow(Projects::HousekeepingService) - .to receive(:new).with(project, :gc).and_return(housekeeping_service) + .to receive(:new).with(project).and_return(housekeeping_service) allow(housekeeping_service) .to receive(:execute).and_yield diff --git a/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb b/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb index d8427d0bf78..80debcd3a7a 100644 --- a/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb +++ b/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb @@ -33,7 +33,10 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do before do allow(project).to receive(:lfs_enabled?).and_return(true) - allow(Gitlab::HTTP).to receive(:post).and_return(objects_response) + response = instance_double(HTTParty::Response) + allow(response).to receive(:body).and_return(objects_response.to_json) + allow(response).to receive(:success?).and_return(true) + allow(Gitlab::HTTP).to receive(:post).and_return(response) end describe '#execute' do @@ -89,6 +92,21 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do expect { subject.send(:get_download_links, new_oids) }.to raise_error(described_class::DownloadLinksError) end + + shared_examples 'JSON parse errors' do |body| + it 'raises error' do + response = instance_double(HTTParty::Response) + allow(response).to receive(:body).and_return(body) + allow(response).to receive(:success?).and_return(true) + allow(Gitlab::HTTP).to receive(:post).and_return(response) + + expect { subject.send(:get_download_links, new_oids) }.to raise_error(described_class::DownloadLinksError) + end + end + + it_behaves_like 'JSON parse errors', '{' + it_behaves_like 'JSON parse errors', '{}' + it_behaves_like 'JSON parse errors', '{ foo: 123 }' end describe '#parse_response_links' do diff --git a/spec/support/helpers/javascript_fixtures_helpers.rb b/spec/support/helpers/javascript_fixtures_helpers.rb index 494398dc4de..cdd7724cc13 100644 --- a/spec/support/helpers/javascript_fixtures_helpers.rb +++ b/spec/support/helpers/javascript_fixtures_helpers.rb @@ -11,6 +11,10 @@ module JavaScriptFixturesHelpers base.around do |example| # pick an arbitrary date from the past, so tests are not time dependent Timecop.freeze(Time.utc(2015, 7, 3, 10)) { example.run } + + raise NoMethodError.new('You need to set `response` for the fixture generator! This will automatically happen with `type: :controller` or `type: :request`.', 'response') unless respond_to?(:response) + + store_frontend_fixture(response, example.description) end end @@ -29,7 +33,13 @@ module JavaScriptFixturesHelpers end end - # Public: Store a response object as fixture file + def remove_repository(project) + Gitlab::Shell.new.remove_repository(project.repository_storage, project.disk_path) + end + + private + + # Private: Store a response object as fixture file # # response - string or response object to store # fixture_file_name - file name to store the fixture in (relative to .fixture_root_path) @@ -42,12 +52,6 @@ module JavaScriptFixturesHelpers File.write(full_fixture_path, fixture) end - def remove_repository(project) - Gitlab::Shell.new.remove_repository(project.repository_storage, project.disk_path) - end - - private - # Private: Prepare a response object for use as a frontend fixture # # response - response object to prepare |