From 7a1c5ba7471b233c994f5b5b313085d0d1292b5d Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 28 Apr 2017 08:56:04 +1100 Subject: Add index on ci_runners.contacted_at --- .../add_index_on_ci_runners_contacted_at.yml | 4 ++++ ...0426181740_add_index_on_ci_runners_contacted_at.rb | 19 +++++++++++++++++++ db/schema.rb | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml create mode 100644 db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb diff --git a/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml b/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml new file mode 100644 index 00000000000..10c3206c2ff --- /dev/null +++ b/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml @@ -0,0 +1,4 @@ +--- +title: Add index on ci_runners.contacted_at +merge_request: 10876 +author: blackst0ne diff --git a/db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb b/db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb new file mode 100644 index 00000000000..879825a1934 --- /dev/null +++ b/db/migrate/20170426181740_add_index_on_ci_runners_contacted_at.rb @@ -0,0 +1,19 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddIndexOnCiRunnersContactedAt < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_runners, :contacted_at + end + + def down + remove_concurrent_index :ci_runners, :contacted_at if index_exists?(:ci_runners, :contacted_at) + end +end diff --git a/db/schema.rb b/db/schema.rb index 49d7c996661..a615a078e49 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170426175636) do +ActiveRecord::Schema.define(version: 20170425101740) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -296,6 +296,7 @@ ActiveRecord::Schema.define(version: 20170426175636) do t.boolean "locked", default: false, null: false end + add_index "ci_runners", ["contacted_at"], name: "index_ci_runners_on_contacted_at", using: :btree add_index "ci_runners", ["is_shared"], name: "index_ci_runners_on_is_shared", using: :btree add_index "ci_runners", ["locked"], name: "index_ci_runners_on_locked", using: :btree add_index "ci_runners", ["token"], name: "index_ci_runners_on_token", using: :btree -- cgit v1.2.1 From ec1ec9b67a95de3b775eefe0f4cdce6fd3aa7b70 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 25 Aug 2017 08:54:50 +1100 Subject: Replace 'source/search_code.feature' spinach test with an rspec analog --- .../add_index_on_ci_runners_contacted_at.yml | 4 -- .../replace_spinach_search_code-feature.yml | 5 ++ features/project/source/search_code.feature | 15 ------ features/steps/project/source/search_code.rb | 19 ------- features/steps/shared/paths.rb | 4 -- spec/features/projects/files/find_files_spec.rb | 23 --------- .../projects/files/user_searches_for_files_spec.rb | 58 ++++++++++++++++++++++ 7 files changed, 63 insertions(+), 65 deletions(-) delete mode 100644 changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml create mode 100644 changelogs/unreleased/replace_spinach_search_code-feature.yml delete mode 100644 features/project/source/search_code.feature delete mode 100644 features/steps/project/source/search_code.rb delete mode 100644 spec/features/projects/files/find_files_spec.rb create mode 100644 spec/features/projects/files/user_searches_for_files_spec.rb diff --git a/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml b/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml deleted file mode 100644 index 10c3206c2ff..00000000000 --- a/changelogs/unreleased/add_index_on_ci_runners_contacted_at.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Add index on ci_runners.contacted_at -merge_request: 10876 -author: blackst0ne diff --git a/changelogs/unreleased/replace_spinach_search_code-feature.yml b/changelogs/unreleased/replace_spinach_search_code-feature.yml new file mode 100644 index 00000000000..28d2108c871 --- /dev/null +++ b/changelogs/unreleased/replace_spinach_search_code-feature.yml @@ -0,0 +1,5 @@ +--- +title: Replace 'source/search_code.feature' spinach test with an rspec analog +merge_request: 13697 +author: blackst0ne +type: other diff --git a/features/project/source/search_code.feature b/features/project/source/search_code.feature deleted file mode 100644 index 4f9dcea249f..00000000000 --- a/features/project/source/search_code.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: Project Source Search Code - Background: - Given I sign in as a user - - Scenario: Search for term "coffee" - Given I own project "Shop" - And I visit project source page - When I search for term "coffee" - Then I should see files from repository containing "coffee" - - Scenario: Search on empty project - Given I own an empty project - And I visit my project's home page - When I search for term "coffee" - Then I should see empty result diff --git a/features/steps/project/source/search_code.rb b/features/steps/project/source/search_code.rb deleted file mode 100644 index feee756d7ec..00000000000 --- a/features/steps/project/source/search_code.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Spinach::Features::ProjectSourceSearchCode < Spinach::FeatureSteps - include SharedAuthentication - include SharedProject - include SharedPaths - - step 'I search for term "coffee"' do - fill_in "search", with: "coffee" - click_button "Go" - end - - step 'I should see files from repository containing "coffee"' do - expect(page).to have_content 'coffee' - expect(page).to have_content 'CONTRIBUTING.md' - end - - step 'I should see empty result' do - expect(page).to have_content "We couldn't find any" - end -end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 830263fd038..be69a96c3ee 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -304,10 +304,6 @@ module SharedPaths visit project_commits_path(@project, 'stable', { limit: 5 }) end - step 'I visit project source page' do - visit project_tree_path(@project, root_ref) - end - step 'I visit blob file from repo' do visit project_blob_path(@project, File.join(sample_commit.id, sample_blob.path)) end diff --git a/spec/features/projects/files/find_files_spec.rb b/spec/features/projects/files/find_files_spec.rb deleted file mode 100644 index 57d67b28920..00000000000 --- a/spec/features/projects/files/find_files_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -feature 'Find files button in the tree header' do - given(:user) { create(:user) } - given(:project) { create(:project, :repository) } - - background do - sign_in(user) - project.team << [user, :developer] - end - - scenario 'project main screen' do - visit project_path(project) - - expect(page).to have_selector('.tree-controls .shortcuts-find-file') - end - - scenario 'project tree screen' do - visit project_tree_path(project, project.default_branch) - - expect(page).to have_selector('.tree-controls .shortcuts-find-file') - end -end diff --git a/spec/features/projects/files/user_searches_for_files_spec.rb b/spec/features/projects/files/user_searches_for_files_spec.rb new file mode 100644 index 00000000000..a105685bca7 --- /dev/null +++ b/spec/features/projects/files/user_searches_for_files_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +describe 'User searches for files' do + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + + before do + sign_in(user) + end + + describe 'project main screen' do + context 'when project is empty' do + let(:empty_project) { create(:project) } + + before do + empty_project.add_developer(user) + visit project_path(empty_project) + end + + it 'does not show any result' do + fill_in('search', with: 'coffee') + click_button('Go') + + expect(page).to have_content("We couldn't find any") + end + end + + context 'when project is not empty' do + before do + project.add_developer(user) + visit project_path(project) + end + + it 'shows "Find file" button' do + expect(page).to have_selector('.tree-controls .shortcuts-find-file') + end + end + end + + describe 'project tree screen' do + before do + project.add_developer(user) + visit project_tree_path(project, project.default_branch) + end + + it 'shows "Find file" button' do + expect(page).to have_selector('.tree-controls .shortcuts-find-file') + end + + it 'shows found files' do + fill_in('search', with: 'coffee') + click_button('Go') + + expect(page).to have_content('coffee') + expect(page).to have_content('CONTRIBUTING.md') + end + end +end -- cgit v1.2.1