From 5983e9bdf2aebb455aa7395541bb9d93d6d4de38 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Fri, 11 Dec 2015 16:06:17 +0100 Subject: Minor fix in flow 'Merge when build succeeds' When a user, which is not the merge user, want to removes the source branch after the automatic merge this might fail because of checks in the DeleteBranchService --- .../merge_requests/widget/open/_merge_when_build_succeeds.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/merge_requests/widget/open/_merge_when_build_succeeds.html.haml b/app/views/projects/merge_requests/widget/open/_merge_when_build_succeeds.html.haml index 08af124274b..2168294c683 100644 --- a/app/views/projects/merge_requests/widget/open/_merge_when_build_succeeds.html.haml +++ b/app/views/projects/merge_requests/widget/open/_merge_when_build_succeeds.html.haml @@ -12,7 +12,7 @@ - else The source branch will not be removed. - - remove_source_branch_button = @merge_request.can_remove_source_branch?(current_user) && !should_remove_source_branch + - remove_source_branch_button = @merge_request.can_remove_source_branch?(current_user) && !should_remove_source_branch && @merge_request.merge_user == current_user - user_can_cancel_automatic_merge = @merge_request.can_cancel_merge_when_build_succeeds?(current_user) - if remove_source_branch_button || user_can_cancel_automatic_merge .clearfix.prepend-top-10 -- cgit v1.2.1 From 208f99ff6c24a2dd5a69ed5666a1fd224d78c59b Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 14 Dec 2015 12:03:28 +0100 Subject: Fix MySQL migration of CI emails [ci skip] --- db/migrate/20151209145909_migrate_ci_emails.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/migrate/20151209145909_migrate_ci_emails.rb b/db/migrate/20151209145909_migrate_ci_emails.rb index 202fac8e3fc..7f330a2cf0a 100644 --- a/db/migrate/20151209145909_migrate_ci_emails.rb +++ b/db/migrate/20151209145909_migrate_ci_emails.rb @@ -25,7 +25,11 @@ class MigrateCiEmails < ActiveRecord::Migration # This function escapes double-quotes and slash def escape_text(name) - "REPLACE(REPLACE(#{name}, '\\', '\\\\'), '\"', '\\\"')" + if Gitlab::Database.postgresql? + "REPLACE(REPLACE(#{name}, '\\', '\\\\'), '\"', '\\\"')" + else + "REPLACE(REPLACE(#{name}, '\\\\', '\\\\\\\\'), '\\\"', '\\\\\\\"')" + end end # This function returns 0 or 1 for column -- cgit v1.2.1 From 927c40ca496dcb1e7daa567ce173de044b1d3377 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 14 Dec 2015 12:31:23 +0100 Subject: Fix Ci::Project migration not migrating columns that cannot be NULL [ci skip] --- db/migrate/20151210125930_migrate_ci_to_project.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/migrate/20151210125930_migrate_ci_to_project.rb b/db/migrate/20151210125930_migrate_ci_to_project.rb index d17b2a425f8..7dfe05174ee 100644 --- a/db/migrate/20151210125930_migrate_ci_to_project.rb +++ b/db/migrate/20151210125930_migrate_ci_to_project.rb @@ -27,11 +27,11 @@ class MigrateCiToProject < ActiveRecord::Migration def migrate_project_column(column, new_column = nil) new_column ||= column subquery = "SELECT ci_projects.#{column} FROM ci_projects WHERE projects.id = ci_projects.gitlab_id" - execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE #{new_column} IS NULL AND (#{subquery}) IS NOT NULL") + execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE (#{subquery}) IS NOT NULL") end def migrate_ci_service - subquery = "SELECT active FROM services WHERE projects.id = services.project_id AND type='GitlabCiService'" - execute("UPDATE projects SET builds_enabled=(#{subquery}) WHERE builds_enabled IS NULL AND (#{subquery}) IS NOT NULL") + subquery = "SELECT active FROM services WHERE projects.id = services.project_id AND type='GitlabCiService' LIMIT 1" + execute("UPDATE projects SET builds_enabled=(#{subquery}) WHERE (#{subquery}) IS NOT NULL") end end -- cgit v1.2.1 From cb4b4c57864867ba4aff04c38516042ef89f0bf7 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 14 Dec 2015 12:45:03 +0100 Subject: Fix 500 when viewing specific runners on runners page [ci skip] --- app/views/admin/runners/show.html.haml | 2 +- app/views/projects/runners/_runner.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/runners/show.html.haml b/app/views/admin/runners/show.html.haml index 32051852dc0..8700b4820cd 100644 --- a/app/views/admin/runners/show.html.haml +++ b/app/views/admin/runners/show.html.haml @@ -60,7 +60,7 @@ = project.name_with_namespace %td .pull-right - = link_to 'Disable', [:admin, project.namespace, project, runner_project], method: :delete, class: 'btn btn-danger btn-xs' + = link_to 'Disable', [:admin, project.namespace.becomes(Namespace), project, runner_project], method: :delete, class: 'btn btn-danger btn-xs' %table.table %thead diff --git a/app/views/projects/runners/_runner.html.haml b/app/views/projects/runners/_runner.html.haml index 4d95afc28bb..47ec420189d 100644 --- a/app/views/projects/runners/_runner.html.haml +++ b/app/views/projects/runners/_runner.html.haml @@ -18,7 +18,7 @@ - runner_project = @project.runner_projects.find_by(runner_id: runner) = link_to 'Disable for this project', namespace_project_runner_project_path(@project.namespace, @project, runner_project), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm' - elsif runner.specific? - = form_for [@project.namespace, @project, @project.runner_projects.new] do |f| + = form_for [@project.namespace.becomes(Namespace), @project, @project.runner_projects.new] do |f| = f.hidden_field :runner_id, value: runner.id = f.submit 'Enable for this project', class: 'btn btn-sm' .pull-right -- cgit v1.2.1 From c0ff4fdd99d44e154083242e32207f567374c8b1 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 14 Dec 2015 13:06:59 +0100 Subject: Move CI admin builds and runners specs to correct directory [ci skip] --- spec/features/admin/admin_builds_spec.rb | 69 +++++++++++++++++++++++++++++++ spec/features/admin/admin_runners_spec.rb | 64 ++++++++++++++++++++++++++++ spec/features/atom/builds_spec.rb | 69 ------------------------------- spec/features/atom/runners_spec.rb | 64 ---------------------------- 4 files changed, 133 insertions(+), 133 deletions(-) create mode 100644 spec/features/admin/admin_builds_spec.rb create mode 100644 spec/features/admin/admin_runners_spec.rb delete mode 100644 spec/features/atom/builds_spec.rb delete mode 100644 spec/features/atom/runners_spec.rb diff --git a/spec/features/admin/admin_builds_spec.rb b/spec/features/admin/admin_builds_spec.rb new file mode 100644 index 00000000000..72764b1629d --- /dev/null +++ b/spec/features/admin/admin_builds_spec.rb @@ -0,0 +1,69 @@ +require 'spec_helper' + +describe "Admin Builds" do + let(:commit) { FactoryGirl.create :ci_commit } + let(:build) { FactoryGirl.create :ci_build, commit: commit } + + before do + login_as :admin + end + + describe "GET /admin/builds" do + before do + build + visit admin_builds_path + end + + it { expect(page).to have_content "Running" } + it { expect(page).to have_content build.short_sha } + end + + describe "Tabs" do + it "shows all builds" do + FactoryGirl.create :ci_build, commit: commit, status: "pending" + FactoryGirl.create :ci_build, commit: commit, status: "running" + FactoryGirl.create :ci_build, commit: commit, status: "success" + FactoryGirl.create :ci_build, commit: commit, status: "failed" + + visit admin_builds_path + + within ".center-top-menu" do + click_on "All" + end + + expect(page.all(".build-link").size).to eq(4) + end + + it "shows finished builds" do + build = FactoryGirl.create :ci_build, commit: commit, status: "pending" + build1 = FactoryGirl.create :ci_build, commit: commit, status: "running" + build2 = FactoryGirl.create :ci_build, commit: commit, status: "success" + + visit admin_builds_path + + within ".center-top-menu" do + click_on "Finished" + end + + expect(page.find(".build-link")).not_to have_content(build.id) + expect(page.find(".build-link")).not_to have_content(build1.id) + expect(page.find(".build-link")).to have_content(build2.id) + end + + it "shows running builds" do + build = FactoryGirl.create :ci_build, commit: commit, status: "pending" + build2 = FactoryGirl.create :ci_build, commit: commit, status: "success" + build3 = FactoryGirl.create :ci_build, commit: commit, status: "failed" + + visit admin_builds_path + + within ".center-top-menu" do + click_on "Running" + end + + expect(page.find(".build-link")).to have_content(build.id) + expect(page.find(".build-link")).not_to have_content(build2.id) + expect(page.find(".build-link")).not_to have_content(build3.id) + end + end +end diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb new file mode 100644 index 00000000000..b1f2d401042 --- /dev/null +++ b/spec/features/admin/admin_runners_spec.rb @@ -0,0 +1,64 @@ +require 'spec_helper' + +describe "Admin Runners" do + before do + login_as :admin + end + + describe "Runners page" do + before do + runner = FactoryGirl.create(:ci_runner) + commit = FactoryGirl.create(:ci_commit) + FactoryGirl.create(:ci_build, commit: commit, runner_id: runner.id) + visit admin_runners_path + end + + it { page.has_text? "Manage Runners" } + it { page.has_text? "To register a new runner" } + it { page.has_text? "Runners with last contact less than a minute ago: 1" } + + describe 'search' do + before do + FactoryGirl.create :ci_runner, description: 'runner-foo' + FactoryGirl.create :ci_runner, description: 'runner-bar' + + search_form = find('#runners-search') + search_form.fill_in 'search', with: 'runner-foo' + search_form.click_button 'Search' + end + + it { expect(page).to have_content("runner-foo") } + it { expect(page).not_to have_content("runner-bar") } + end + end + + describe "Runner show page" do + let(:runner) { FactoryGirl.create :ci_runner } + + before do + @project1 = FactoryGirl.create(:empty_project) + @project2 = FactoryGirl.create(:empty_project) + visit admin_runner_path(runner) + end + + describe 'runner info' do + it { expect(find_field('runner_token').value).to eq runner.token } + end + + describe 'projects' do + it { expect(page).to have_content(@project1.name_with_namespace) } + it { expect(page).to have_content(@project2.name_with_namespace) } + end + + describe 'search' do + before do + search_form = find('#runner-projects-search') + search_form.fill_in 'search', with: @project1.name + search_form.click_button 'Search' + end + + it { expect(page).to have_content(@project1.name_with_namespace) } + it { expect(page).not_to have_content(@project2.name_with_namespace) } + end + end +end diff --git a/spec/features/atom/builds_spec.rb b/spec/features/atom/builds_spec.rb deleted file mode 100644 index 72764b1629d..00000000000 --- a/spec/features/atom/builds_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'spec_helper' - -describe "Admin Builds" do - let(:commit) { FactoryGirl.create :ci_commit } - let(:build) { FactoryGirl.create :ci_build, commit: commit } - - before do - login_as :admin - end - - describe "GET /admin/builds" do - before do - build - visit admin_builds_path - end - - it { expect(page).to have_content "Running" } - it { expect(page).to have_content build.short_sha } - end - - describe "Tabs" do - it "shows all builds" do - FactoryGirl.create :ci_build, commit: commit, status: "pending" - FactoryGirl.create :ci_build, commit: commit, status: "running" - FactoryGirl.create :ci_build, commit: commit, status: "success" - FactoryGirl.create :ci_build, commit: commit, status: "failed" - - visit admin_builds_path - - within ".center-top-menu" do - click_on "All" - end - - expect(page.all(".build-link").size).to eq(4) - end - - it "shows finished builds" do - build = FactoryGirl.create :ci_build, commit: commit, status: "pending" - build1 = FactoryGirl.create :ci_build, commit: commit, status: "running" - build2 = FactoryGirl.create :ci_build, commit: commit, status: "success" - - visit admin_builds_path - - within ".center-top-menu" do - click_on "Finished" - end - - expect(page.find(".build-link")).not_to have_content(build.id) - expect(page.find(".build-link")).not_to have_content(build1.id) - expect(page.find(".build-link")).to have_content(build2.id) - end - - it "shows running builds" do - build = FactoryGirl.create :ci_build, commit: commit, status: "pending" - build2 = FactoryGirl.create :ci_build, commit: commit, status: "success" - build3 = FactoryGirl.create :ci_build, commit: commit, status: "failed" - - visit admin_builds_path - - within ".center-top-menu" do - click_on "Running" - end - - expect(page.find(".build-link")).to have_content(build.id) - expect(page.find(".build-link")).not_to have_content(build2.id) - expect(page.find(".build-link")).not_to have_content(build3.id) - end - end -end diff --git a/spec/features/atom/runners_spec.rb b/spec/features/atom/runners_spec.rb deleted file mode 100644 index b1f2d401042..00000000000 --- a/spec/features/atom/runners_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'spec_helper' - -describe "Admin Runners" do - before do - login_as :admin - end - - describe "Runners page" do - before do - runner = FactoryGirl.create(:ci_runner) - commit = FactoryGirl.create(:ci_commit) - FactoryGirl.create(:ci_build, commit: commit, runner_id: runner.id) - visit admin_runners_path - end - - it { page.has_text? "Manage Runners" } - it { page.has_text? "To register a new runner" } - it { page.has_text? "Runners with last contact less than a minute ago: 1" } - - describe 'search' do - before do - FactoryGirl.create :ci_runner, description: 'runner-foo' - FactoryGirl.create :ci_runner, description: 'runner-bar' - - search_form = find('#runners-search') - search_form.fill_in 'search', with: 'runner-foo' - search_form.click_button 'Search' - end - - it { expect(page).to have_content("runner-foo") } - it { expect(page).not_to have_content("runner-bar") } - end - end - - describe "Runner show page" do - let(:runner) { FactoryGirl.create :ci_runner } - - before do - @project1 = FactoryGirl.create(:empty_project) - @project2 = FactoryGirl.create(:empty_project) - visit admin_runner_path(runner) - end - - describe 'runner info' do - it { expect(find_field('runner_token').value).to eq runner.token } - end - - describe 'projects' do - it { expect(page).to have_content(@project1.name_with_namespace) } - it { expect(page).to have_content(@project2.name_with_namespace) } - end - - describe 'search' do - before do - search_form = find('#runner-projects-search') - search_form.fill_in 'search', with: @project1.name - search_form.click_button 'Search' - end - - it { expect(page).to have_content(@project1.name_with_namespace) } - it { expect(page).not_to have_content(@project2.name_with_namespace) } - end - end -end -- cgit v1.2.1