diff options
author | Rémy Coutable <remy@rymai.me> | 2018-04-09 19:26:29 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-04-09 19:26:29 +0200 |
commit | eeea537c40702c50912be26ae7fbecc9ca135e8c (patch) | |
tree | 049026a2bc94d5b0f881087fe60be260ac8104a3 | |
parent | 449b75389432fef82d0dcf558b068085aa9f59f8 (diff) | |
download | gitlab-ce-port-features-project-project-to-rspec.tar.gz |
Address review feedbackport-features-project-project-to-rspec
Signed-off-by: Rémy Coutable <remy@rymai.me>
20 files changed, 57 insertions, 101 deletions
diff --git a/spec/features/projects/activity/rss_spec.rb b/spec/features/projects/activity/rss_spec.rb index 2693e539268..cd1cfe07998 100644 --- a/spec/features/projects/activity/rss_spec.rb +++ b/spec/features/projects/activity/rss_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' feature 'Project Activity RSS' do - let(:user) { create(:user) } - let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let(:project) { create(:project, :public) } + let(:user) { project.owner } let(:path) { activity_project_path(project) } before do @@ -11,8 +11,7 @@ feature 'Project Activity RSS' do context 'when signed in' do before do - project.add_developer(user) - sign_in(user) + sign_in(project.owner) visit path end diff --git a/spec/features/projects/activity/user_sees_activity_spec.rb b/spec/features/projects/activity/user_sees_activity_spec.rb index a1252a13260..644a837dc14 100644 --- a/spec/features/projects/activity/user_sees_activity_spec.rb +++ b/spec/features/projects/activity/user_sees_activity_spec.rb @@ -15,22 +15,7 @@ feature 'Projects > Activity > User sees activity' do visit activity_project_path(project) end - shared_examples 'push appears in activity' do - it 'shows the last push in the activity page', :js do - expect(page).to have_content "#{user.name} pushed new branch fix" - end - end - - context 'when signed in' do - before do - project.add_developer(user) - sign_in(user) - end - - it_behaves_like 'push appears in activity' - end - - context 'when signed out' do - it_behaves_like 'push appears in activity' + it 'shows the last push in the activity page', :js do + expect(page).to have_content "#{user.name} pushed new branch fix" end end diff --git a/spec/features/projects/files/dockerfile_dropdown_spec.rb b/spec/features/projects/files/dockerfile_dropdown_spec.rb index 10376afa009..004585f7c9e 100644 --- a/spec/features/projects/files/dockerfile_dropdown_spec.rb +++ b/spec/features/projects/files/dockerfile_dropdown_spec.rb @@ -1,22 +1,15 @@ require 'spec_helper' -require 'fileutils' describe 'Projects > Files > User wants to add a Dockerfile file' do before do - user = create(:user) project = create(:project, :repository) - project.add_master(user) - - sign_in user - + sign_in project.owner visit project_new_blob_path(project, 'master', file_name: 'Dockerfile') end - it 'user can see Dockerfile dropdown' do + it 'user can pick a Dockerfile file from the dropdown', :js do expect(page).to have_css('.dockerfile-selector') - end - it 'user can pick a Dockerfile file from the dropdown', :js do find('.js-dockerfile-selector').click wait_for_requests diff --git a/spec/features/projects/files/download_buttons_spec.rb b/spec/features/projects/files/download_buttons_spec.rb index 8c9252baf15..03cb3530e2b 100644 --- a/spec/features/projects/files/download_buttons_spec.rb +++ b/spec/features/projects/files/download_buttons_spec.rb @@ -1,17 +1,15 @@ require 'spec_helper' describe 'Projects > Files > Download buttons in files tree' do - let(:user) { create(:user) } - let(:role) { :developer } - let(:status) { 'success' } let(:project) { create(:project, :repository) } + let(:user) { project.creator } let(:pipeline) do create(:ci_pipeline, project: project, sha: project.commit.sha, ref: project.default_branch, - status: status) + status: 'success') end let!(:build) do @@ -23,20 +21,16 @@ describe 'Projects > Files > Download buttons in files tree' do before do sign_in(user) - project.add_role(user, role) - end + project.add_developer(user) - describe 'when files tree' do - context 'with artifacts' do - before do - visit project_tree_path(project, project.default_branch) - end + visit project_tree_path(project, project.default_branch) + end - it 'shows download artifacts button' do - href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build') + context 'with artifacts' do + it 'shows download artifacts button' do + href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build') - expect(page).to have_link "Download '#{build.name}'", href: href - end + expect(page).to have_link "Download '#{build.name}'", href: href end end end diff --git a/spec/features/projects/files/edit_file_soft_wrap_spec.rb b/spec/features/projects/files/edit_file_soft_wrap_spec.rb index 556a5834a6d..41af70d8ebc 100644 --- a/spec/features/projects/files/edit_file_soft_wrap_spec.rb +++ b/spec/features/projects/files/edit_file_soft_wrap_spec.rb @@ -2,9 +2,8 @@ require 'spec_helper' describe 'Projects > Files > User uses soft wrap whilst editing file', :js do before do - user = create(:user) project = create(:project, :repository) - project.add_master(user) + user = project.owner sign_in user visit project_new_blob_path(project, 'master', file_name: 'test_file-name') page.within('.file-editor.code') do diff --git a/spec/features/projects/files/editing_a_file_spec.rb b/spec/features/projects/files/editing_a_file_spec.rb index 14371c423b8..4074e67e2d2 100644 --- a/spec/features/projects/files/editing_a_file_spec.rb +++ b/spec/features/projects/files/editing_a_file_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe 'Projects > Files > User wants to edit a file' do let(:project) { create(:project, :repository) } - let(:user) { create(:user) } + let(:user) { project.owner } let(:commit_params) do { start_branch: project.default_branch, @@ -16,7 +16,6 @@ describe 'Projects > Files > User wants to edit a file' do end before do - project.add_master(user) sign_in user visit project_edit_blob_path(project, File.join(project.default_branch, '.gitignore')) diff --git a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb index 143565013b0..b6dbf76bc9b 100644 --- a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb +++ b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb @@ -1,11 +1,10 @@ require 'spec_helper' describe 'Projects > Files > User views files page' do - let(:user) { create(:user) } let(:project) { create(:forked_project_with_submodules) } + let(:user) { project.owner } before do - project.add_master(user) sign_in user visit project_tree_path(project, project.repository.root_ref) end diff --git a/spec/features/projects/files/find_file_keyboard_spec.rb b/spec/features/projects/files/find_file_keyboard_spec.rb index e925203793a..cd0235f2b9e 100644 --- a/spec/features/projects/files/find_file_keyboard_spec.rb +++ b/spec/features/projects/files/find_file_keyboard_spec.rb @@ -1,11 +1,10 @@ require 'spec_helper' describe 'Projects > Files > Find file keyboard shortcuts', :js do - let(:user) { create(:user) } let(:project) { create(:project, :repository) } + let(:user) { project.owner } before do - project.add_master(user) sign_in user visit project_find_file_path(project, project.repository.root_ref) diff --git a/spec/features/projects/files/gitignore_dropdown_spec.rb b/spec/features/projects/files/gitignore_dropdown_spec.rb index 4351e1c8d50..9fa4c053a40 100644 --- a/spec/features/projects/files/gitignore_dropdown_spec.rb +++ b/spec/features/projects/files/gitignore_dropdown_spec.rb @@ -2,24 +2,23 @@ require 'spec_helper' describe 'Projects > Files > User wants to add a .gitignore file' do before do - user = create(:user) project = create(:project, :repository) - project.add_master(user) - sign_in user + sign_in project.owner visit project_new_blob_path(project, 'master', file_name: '.gitignore') end - it 'user can see .gitignore dropdown' do + it 'user can pick a .gitignore file from the dropdown', :js do expect(page).to have_css('.gitignore-selector') - end - it 'user can pick a .gitignore file from the dropdown', :js do find('.js-gitignore-selector').click + wait_for_requests + within '.gitignore-selector' do find('.dropdown-input-field').set('rails') find('.dropdown-content li', text: 'Rails').click end + wait_for_requests expect(page).to have_css('.gitignore-selector .dropdown-toggle-text', text: 'Rails') diff --git a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb index 29ed37aa14e..53aff183562 100644 --- a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb +++ b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb @@ -2,24 +2,23 @@ require 'spec_helper' describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do before do - user = create(:user) project = create(:project, :repository) - project.add_master(user) - sign_in user + sign_in project.owner visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml') end - it 'user can see .gitlab-ci.yml dropdown' do + it 'user can pick a template from the dropdown', :js do expect(page).to have_css('.gitlab-ci-yml-selector') - end - it 'user can pick a template from the dropdown', :js do find('.js-gitlab-ci-yml-selector').click + wait_for_requests + within '.gitlab-ci-yml-selector' do find('.dropdown-input-field').set('Jekyll') find('.dropdown-content li', text: 'Jekyll').click end + wait_for_requests expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Jekyll') diff --git a/spec/features/projects/files/project_owner_creates_license_file_spec.rb b/spec/features/projects/files/project_owner_creates_license_file_spec.rb index edf91f9ddbf..b410199fd1f 100644 --- a/spec/features/projects/files/project_owner_creates_license_file_spec.rb +++ b/spec/features/projects/files/project_owner_creates_license_file_spec.rb @@ -1,13 +1,12 @@ require 'spec_helper' describe 'Projects > Files > Project owner creates a license file', :js do - let(:project_master) { create(:user) } let(:project) { create(:project, :repository) } + let(:project_master) { project.owner } before do project.repository.delete_file(project_master, 'LICENSE', message: 'Remove LICENSE', branch_name: 'master') - project.add_master(project_master) sign_in(project_master) visit project_path(project) end diff --git a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb index 7f7244cd3e3..53d8ace7c94 100644 --- a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb +++ b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb @@ -1,11 +1,10 @@ require 'spec_helper' describe 'Projects > Files > Project owner sees a link to create a license file in empty project', :js do - let(:project_master) { create(:user) } let(:project) { create(:project_empty_repo) } + let(:project_master) { project.owner } before do - project.add_master(project_master) sign_in(project_master) end diff --git a/spec/features/projects/files/template_type_dropdown_spec.rb b/spec/features/projects/files/template_type_dropdown_spec.rb index 43f476553b1..342a93b328f 100644 --- a/spec/features/projects/files/template_type_dropdown_spec.rb +++ b/spec/features/projects/files/template_type_dropdown_spec.rb @@ -2,10 +2,9 @@ require 'spec_helper' describe 'Projects > Files > Template type dropdown selector', :js do let(:project) { create(:project, :repository) } - let(:user) { create(:user) } + let(:user) { project.owner } before do - project.add_master(user) sign_in user end diff --git a/spec/features/projects/files/undo_template_spec.rb b/spec/features/projects/files/undo_template_spec.rb index bf8fc6d37d2..5de0bc009fb 100644 --- a/spec/features/projects/files/undo_template_spec.rb +++ b/spec/features/projects/files/undo_template_spec.rb @@ -2,10 +2,9 @@ require 'spec_helper' describe 'Projects > Files > Template Undo Button', :js do let(:project) { create(:project, :repository) } - let(:user) { create(:user) } + let(:user) { project.owner } before do - project.add_master(user) sign_in user end diff --git a/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb b/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb index 8f5422d6b63..2d67837763c 100644 --- a/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb +++ b/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb @@ -3,7 +3,7 @@ require 'spec_helper' # This is a regression test for https://gitlab.com/gitlab-org/gitlab-ce/issues/37569 describe 'Projects > Files > User browses a tree with a folder containing only a folder' do let(:project) { create(:project, :empty_repo) } - let(:user) { project.creator } + let(:user) { project.owner } before do # We need to disable the tree.flat_path provided by Gitaly to reproduce the issue diff --git a/spec/features/projects/files/user_browses_files_spec.rb b/spec/features/projects/files/user_browses_files_spec.rb index b8432470813..9c1f11f4c12 100644 --- a/spec/features/projects/files/user_browses_files_spec.rb +++ b/spec/features/projects/files/user_browses_files_spec.rb @@ -10,10 +10,9 @@ describe 'Projects > Files > User browses files' do let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } let(:tree_path_ref_6d39438) { project_tree_path(project, '6d39438') } let(:tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } - let(:user) { project.creator } + let(:user) { project.owner } before do - project.add_master(user) sign_in(user) end diff --git a/spec/features/projects/files/user_browses_lfs_files_spec.rb b/spec/features/projects/files/user_browses_lfs_files_spec.rb index f321d7f322e..c559a301ca1 100644 --- a/spec/features/projects/files/user_browses_lfs_files_spec.rb +++ b/spec/features/projects/files/user_browses_lfs_files_spec.rb @@ -2,10 +2,9 @@ require 'spec_helper' describe 'Projects > Files > User browses LFS files' do let(:project) { create(:project, :repository) } - let(:user) { project.creator } + let(:user) { project.owner } before do - project.add_master(user) sign_in(user) 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 index 282806567ce..a90e4918fb1 100644 --- a/spec/features/projects/files/user_searches_for_files_spec.rb +++ b/spec/features/projects/files/user_searches_for_files_spec.rb @@ -1,8 +1,7 @@ require 'spec_helper' describe 'Projects > Files > User searches for files' do - let(:user) { create(:user) } - let(:project) { create(:project, :repository) } + let(:user) { project.owner } before do sign_in(user) @@ -10,11 +9,10 @@ describe 'Projects > Files > User searches for files' do describe 'project main screen' do context 'when project is empty' do - let(:empty_project) { create(:project) } + let(:project) { create(:project) } before do - empty_project.add_developer(user) - visit project_path(empty_project) + visit project_path(project) end it 'does not show any result' do @@ -26,6 +24,8 @@ describe 'Projects > Files > User searches for files' do end context 'when project is not empty' do + let(:project) { create(:project, :repository) } + before do project.add_developer(user) visit project_path(project) @@ -38,16 +38,16 @@ describe 'Projects > Files > User searches for files' do end describe 'project tree screen' do + let(:project) { create(:project, :repository) } + before do project.add_developer(user) visit project_tree_path(project, project.default_branch) end - it 'shows "Find file" button' do + it 'shows found files' 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') diff --git a/spec/features/projects/settings/lfs_settings_spec.rb b/spec/features/projects/settings/lfs_settings_spec.rb index 04d3f9e452c..0fd28a5681c 100644 --- a/spec/features/projects/settings/lfs_settings_spec.rb +++ b/spec/features/projects/settings/lfs_settings_spec.rb @@ -6,11 +6,12 @@ describe 'Projects > Settings > LFS settings' do context 'LFS enabled setting' do before do + allow(Gitlab.config.lfs).to receive(:enabled).and_return(true) + sign_in(admin) end it 'displays the correct elements', :js do - allow(Gitlab.config.lfs).to receive(:enabled).and_return(true) visit edit_project_path(project) expect(page).to have_content('Git Large File Storage') diff --git a/spec/features/projects/show/user_manages_notifications_spec.rb b/spec/features/projects/show/user_manages_notifications_spec.rb index 38b57fe2483..31b105229be 100644 --- a/spec/features/projects/show/user_manages_notifications_spec.rb +++ b/spec/features/projects/show/user_manages_notifications_spec.rb @@ -1,23 +1,19 @@ require 'spec_helper' -describe 'Projects > Show > User manages notifications' do +describe 'Projects > Show > User manages notifications', :js do let(:project) { create(:project, :public, :repository) } - context 'when user is signed in', :js do - let(:user) { create(:user) } - - before do - sign_in(user) - visit project_path(project) - end + before do + sign_in(project.owner) + visit project_path(project) + end - it 'changes the notification setting' do - first('.notifications-btn').click - click_link 'On mention' + it 'changes the notification setting' do + first('.notifications-btn').click + click_link 'On mention' - page.within '#notifications-button' do - expect(page).to have_content 'On mention' - end + page.within '#notifications-button' do + expect(page).to have_content 'On mention' end end end |