diff options
Diffstat (limited to 'spec/features')
25 files changed, 125 insertions, 17 deletions
diff --git a/spec/features/dashboard/snippets_spec.rb b/spec/features/dashboard/snippets_spec.rb index 4fb01995cb0..ff3eb58931d 100644 --- a/spec/features/dashboard/snippets_spec.rb +++ b/spec/features/dashboard/snippets_spec.rb @@ -6,6 +6,7 @@ describe 'Dashboard snippets' do context 'when the project has snippets' do let(:project) { create(:project, :public) } let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) } + before do allow(Snippet).to receive(:default_per_page).and_return(1) sign_in(project.owner) @@ -13,10 +14,16 @@ describe 'Dashboard snippets' do end it_behaves_like 'paginated snippets' + + it 'shows new snippet button in header' do + parent_element = page.find('.page-title-controls') + expect(parent_element).to have_link('New snippet') + end end context 'when there are no project snippets', :js do let(:project) { create(:project, :public) } + before do sign_in(project.owner) visit dashboard_snippets_path @@ -28,6 +35,11 @@ describe 'Dashboard snippets' do expect(element).to have_content("Snippets are small pieces of code or notes that you want to keep.") expect(element.find('.svg-content img')['src']).to have_content('illustrations/snippets_empty') end + + it 'shows new snippet button in main content area' do + parent_element = page.find('.row.empty-state') + expect(parent_element).to have_link('New snippet') + end end context 'filtering by visibility' do @@ -76,4 +88,26 @@ describe 'Dashboard snippets' do expect(page).to have_content(snippets[0].title) end end + + context 'as an external user' do + let(:user) { create(:user, :external) } + before do + sign_in(user) + visit dashboard_snippets_path + end + + context 'without snippets' do + it 'hides new snippet button' do + expect(page).not_to have_link('New snippet') + end + end + + context 'with snippets' do + let!(:snippets) { create(:personal_snippet, author: user) } + + it 'hides new snippet button' do + expect(page).not_to have_link('New snippet') + end + end + end end diff --git a/spec/features/discussion_comments/snippets_spec.rb b/spec/features/discussion_comments/snippets_spec.rb index 082f35050c0..0dccb7f5bb3 100644 --- a/spec/features/discussion_comments/snippets_spec.rb +++ b/spec/features/discussion_comments/snippets_spec.rb @@ -8,6 +8,7 @@ describe 'Thread Comments Snippet', :js do let(:snippet) { create(:project_snippet, :private, project: project, author: user) } before do + stub_feature_flags(snippets_vue: false) project.add_maintainer(user) sign_in(user) diff --git a/spec/features/issues/move_spec.rb b/spec/features/issues/move_spec.rb index 1122504248f..7126707affd 100644 --- a/spec/features/issues/move_spec.rb +++ b/spec/features/issues/move_spec.rb @@ -70,6 +70,7 @@ describe 'issue move to another project' do context 'user does not have permission to move the issue to a project', :js do let!(:private_project) { create(:project, :private) } let(:another_project) { create(:project) } + before do another_project.add_guest(user) end diff --git a/spec/features/issues/user_views_issues_spec.rb b/spec/features/issues/user_views_issues_spec.rb index b986991f38f..8f174472f49 100644 --- a/spec/features/issues/user_views_issues_spec.rb +++ b/spec/features/issues/user_views_issues_spec.rb @@ -6,6 +6,7 @@ describe "User views issues" do let!(:closed_issue) { create(:closed_issue, project: project) } let!(:open_issue1) { create(:issue, project: project) } let!(:open_issue2) { create(:issue, project: project) } + set(:user) { create(:user) } shared_examples "opens issue from list" do diff --git a/spec/features/merge_requests/user_sorts_merge_requests_spec.rb b/spec/features/merge_requests/user_sorts_merge_requests_spec.rb index ca3e24d7036..3c217786d43 100644 --- a/spec/features/merge_requests/user_sorts_merge_requests_spec.rb +++ b/spec/features/merge_requests/user_sorts_merge_requests_spec.rb @@ -9,6 +9,7 @@ describe 'User sorts merge requests' do let!(:merge_request2) do create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test') end + set(:user) { create(:user) } set(:group) { create(:group) } set(:group_member) { create(:group_member, :maintainer, user: user, group: group) } diff --git a/spec/features/merge_requests/user_views_open_merge_requests_spec.rb b/spec/features/merge_requests/user_views_open_merge_requests_spec.rb index cefac9690ce..932090bdbce 100644 --- a/spec/features/merge_requests/user_views_open_merge_requests_spec.rb +++ b/spec/features/merge_requests/user_views_open_merge_requests_spec.rb @@ -113,6 +113,7 @@ describe 'User views open merge requests' do context 'when project is internal' do let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) } + set(:project) { create(:project, :internal, :repository) } context 'when signed in' do diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index 4a1e8598131..29e9b0c313a 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -33,6 +33,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do let(:remember_me) { false } let(:user) { create(:omniauth_user, extern_uid: uid, provider: provider.to_s) } let(:two_factor_user) { create(:omniauth_user, :two_factor, extern_uid: uid, provider: provider.to_s) } + provider == :salesforce ? let(:additional_info) { { extra: { email_verified: true } } } : let(:additional_info) { {} } before do diff --git a/spec/features/participants_autocomplete_spec.rb b/spec/features/participants_autocomplete_spec.rb index a7bba124716..fdedd319116 100644 --- a/spec/features/participants_autocomplete_spec.rb +++ b/spec/features/participants_autocomplete_spec.rb @@ -34,6 +34,7 @@ describe 'Member autocomplete', :js do context 'adding a new note on a Issue' do let(:noteable) { create(:issue, author: author, project: project) } + before do visit project_issue_path(project, noteable) end @@ -47,6 +48,7 @@ describe 'Member autocomplete', :js do create(:merge_request, source_project: project, target_project: project, author: author) end + before do visit project_merge_request_path(project, noteable) end diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb index 7c8b2640e89..142aaaffb7d 100644 --- a/spec/features/projects/clusters/gcp_spec.rb +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -194,6 +194,7 @@ describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do context 'when third party offers are disabled' do let(:admin) { create(:admin) } + before do stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') sign_in(admin) diff --git a/spec/features/projects/files/user_edits_files_spec.rb b/spec/features/projects/files/user_edits_files_spec.rb index 374a7fb7936..cc428dce2a8 100644 --- a/spec/features/projects/files/user_edits_files_spec.rb +++ b/spec/features/projects/files/user_edits_files_spec.rb @@ -193,6 +193,7 @@ describe 'Projects > Files > User edits files', :js do context 'when the user already had a fork of the project', :js do let!(:forked_project) { fork_project(project2, user, namespace: user.namespace, repository: true) } + before do visit(project2_tree_path_root_ref) wait_for_requests diff --git a/spec/features/projects/snippets/create_snippet_spec.rb b/spec/features/projects/snippets/create_snippet_spec.rb index 684793ce116..ad65e04473c 100644 --- a/spec/features/projects/snippets/create_snippet_spec.rb +++ b/spec/features/projects/snippets/create_snippet_spec.rb @@ -18,6 +18,7 @@ describe 'Projects > Snippets > Create Snippet', :js do context 'when a user is authenticated' do before do + stub_feature_flags(snippets_vue: false) project.add_maintainer(user) sign_in(user) @@ -76,6 +77,10 @@ describe 'Projects > Snippets > Create Snippet', :js do end context 'when a user is not authenticated' do + before do + stub_feature_flags(snippets_vue: false) + end + it 'shows a public snippet on the index page but not the New snippet button' do snippet = create(:project_snippet, :public, project: project) diff --git a/spec/features/projects/snippets/show_spec.rb b/spec/features/projects/snippets/show_spec.rb index e448309356d..9be226c017f 100644 --- a/spec/features/projects/snippets/show_spec.rb +++ b/spec/features/projects/snippets/show_spec.rb @@ -8,6 +8,7 @@ describe 'Projects > Snippets > Project snippet', :js do let(:snippet) { create(:project_snippet, project: project, file_name: file_name, content: content) } before do + stub_feature_flags(snippets_vue: false) project.add_maintainer(user) sign_in(user) end diff --git a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb index 239d19d35d1..11707378996 100644 --- a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb +++ b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb @@ -8,6 +8,7 @@ describe 'Projects > Snippets > User comments on a snippet', :js do let(:user) { create(:user) } before do + stub_feature_flags(snippets_vue: false) project.add_maintainer(user) sign_in(user) diff --git a/spec/features/projects/snippets/user_deletes_snippet_spec.rb b/spec/features/projects/snippets/user_deletes_snippet_spec.rb index 1b56d7bf26d..7e337710e19 100644 --- a/spec/features/projects/snippets/user_deletes_snippet_spec.rb +++ b/spec/features/projects/snippets/user_deletes_snippet_spec.rb @@ -8,6 +8,7 @@ describe 'Projects > Snippets > User deletes a snippet' do let(:user) { create(:user) } before do + stub_feature_flags(snippets_vue: false) project.add_maintainer(user) sign_in(user) diff --git a/spec/features/projects/snippets/user_updates_snippet_spec.rb b/spec/features/projects/snippets/user_updates_snippet_spec.rb index c7ff4f89fd6..93a5b4a7262 100644 --- a/spec/features/projects/snippets/user_updates_snippet_spec.rb +++ b/spec/features/projects/snippets/user_updates_snippet_spec.rb @@ -8,6 +8,7 @@ describe 'Projects > Snippets > User updates a snippet' do let(:user) { create(:user) } before do + stub_feature_flags(snippets_vue: false) project.add_maintainer(user) sign_in(user) diff --git a/spec/features/reportable_note/snippets_spec.rb b/spec/features/reportable_note/snippets_spec.rb index c2c853cdb05..bd37675315f 100644 --- a/spec/features/reportable_note/snippets_spec.rb +++ b/spec/features/reportable_note/snippets_spec.rb @@ -7,6 +7,7 @@ describe 'Reportable note on snippets', :js do let(:project) { create(:project) } before do + stub_feature_flags(snippets_vue: false) project.add_maintainer(user) sign_in(user) end diff --git a/spec/features/security/group/internal_access_spec.rb b/spec/features/security/group/internal_access_spec.rb index a182b6b9d57..8dd15789cd1 100644 --- a/spec/features/security/group/internal_access_spec.rb +++ b/spec/features/security/group/internal_access_spec.rb @@ -53,6 +53,7 @@ describe 'Internal Group access' do describe 'GET /groups/:path/merge_requests' do let(:project) { create(:project, :internal, :repository, group: group) } + subject { merge_requests_group_path(group) } it { is_expected.to be_allowed_for(:admin) } diff --git a/spec/features/security/group/private_access_spec.rb b/spec/features/security/group/private_access_spec.rb index 5e3e9824aaa..0720302b03b 100644 --- a/spec/features/security/group/private_access_spec.rb +++ b/spec/features/security/group/private_access_spec.rb @@ -53,6 +53,7 @@ describe 'Private Group access' do describe 'GET /groups/:path/merge_requests' do let(:project) { create(:project, :private, :repository, group: group) } + subject { merge_requests_group_path(group) } it { is_expected.to be_allowed_for(:admin) } diff --git a/spec/features/security/group/public_access_spec.rb b/spec/features/security/group/public_access_spec.rb index efc84205980..0a18a0ff812 100644 --- a/spec/features/security/group/public_access_spec.rb +++ b/spec/features/security/group/public_access_spec.rb @@ -53,6 +53,7 @@ describe 'Public Group access' do describe 'GET /groups/:path/merge_requests' do let(:project) { create(:project, :public, :repository, group: group) } + subject { merge_requests_group_path(group) } it { is_expected.to be_allowed_for(:admin) } diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb index 20a320e5b92..5c74b566ef0 100644 --- a/spec/features/security/project/internal_access_spec.rb +++ b/spec/features/security/project/internal_access_spec.rb @@ -129,6 +129,7 @@ describe "Internal Project Access" do describe "GET /:project_path/blob" do let(:commit) { project.repository.commit } + subject { project_blob_path(project, File.join(commit.id, '.gitignore')) } it { is_expected.to be_allowed_for(:admin) } @@ -186,6 +187,7 @@ describe "Internal Project Access" do describe "GET /:project_path/issues/:id/edit" do let(:issue) { create(:issue, project: project) } + subject { edit_project_issue_path(project, issue) } it { is_expected.to be_allowed_for(:admin) } @@ -327,6 +329,7 @@ describe "Internal Project Access" do describe "GET /:project_path/pipelines/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } + subject { project_pipeline_path(project, pipeline) } it { is_expected.to be_allowed_for(:admin) } @@ -379,6 +382,7 @@ describe "Internal Project Access" do describe "GET /:project_path/builds/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } + subject { project_job_path(project, build.id) } context "when allowed for public and internal" do @@ -417,6 +421,7 @@ describe "Internal Project Access" do describe 'GET /:project_path/builds/:id/trace' do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } + subject { trace_project_job_path(project, build.id) } context 'when allowed for public and internal' do @@ -482,6 +487,7 @@ describe "Internal Project Access" do describe "GET /:project_path/-/environments/:id" do let(:environment) { create(:environment, project: project) } + subject { project_environment_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } @@ -497,6 +503,7 @@ describe "Internal Project Access" do describe "GET /:project_path/-/environments/:id/deployments" do let(:environment) { create(:environment, project: project) } + subject { project_environment_deployments_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb index 62f9a96305d..2404b7cc69d 100644 --- a/spec/features/security/project/private_access_spec.rb +++ b/spec/features/security/project/private_access_spec.rb @@ -129,6 +129,7 @@ describe "Private Project Access" do describe "GET /:project_path/blob" do let(:commit) { project.repository.commit } + subject { project_blob_path(project, File.join(commit.id, '.gitignore')) } it { is_expected.to be_allowed_for(:admin) } @@ -186,6 +187,7 @@ describe "Private Project Access" do describe "GET /:project_path/issues/:id/edit" do let(:issue) { create(:issue, project: project) } + subject { edit_project_issue_path(project, issue) } it { is_expected.to be_allowed_for(:admin) } @@ -311,6 +313,7 @@ describe "Private Project Access" do describe "GET /:project_path/pipelines/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } + subject { project_pipeline_path(project, pipeline) } it { is_expected.to be_allowed_for(:admin) } @@ -365,6 +368,7 @@ describe "Private Project Access" do describe "GET /:project_path/builds/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } + subject { project_job_path(project, build.id) } it { is_expected.to be_allowed_for(:admin) } @@ -398,6 +402,7 @@ describe "Private Project Access" do describe 'GET /:project_path/builds/:id/trace' do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } + subject { trace_project_job_path(project, build.id) } it { is_expected.to be_allowed_for(:admin) } @@ -443,6 +448,7 @@ describe "Private Project Access" do describe "GET /:project_path/-/environments/:id" do let(:environment) { create(:environment, project: project) } + subject { project_environment_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } @@ -458,6 +464,7 @@ describe "Private Project Access" do describe "GET /:project_path/-/environments/:id/deployments" do let(:environment) { create(:environment, project: project) } + subject { project_environment_deployments_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index 317c7bae084..8e07af61c8b 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -143,6 +143,7 @@ describe "Public Project Access" do describe "GET /:project_path/pipelines/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } + subject { project_pipeline_path(project, pipeline) } it { is_expected.to be_allowed_for(:admin) } @@ -195,6 +196,7 @@ describe "Public Project Access" do describe "GET /:project_path/builds/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } + subject { project_job_path(project, build.id) } context "when allowed for public" do @@ -233,6 +235,7 @@ describe "Public Project Access" do describe 'GET /:project_path/builds/:id/trace' do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } + subject { trace_project_job_path(project, build.id) } context 'when allowed for public' do @@ -298,6 +301,7 @@ describe "Public Project Access" do describe "GET /:project_path/-/environments/:id" do let(:environment) { create(:environment, project: project) } + subject { project_environment_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } @@ -313,6 +317,7 @@ describe "Public Project Access" do describe "GET /:project_path/-/environments/:id/deployments" do let(:environment) { create(:environment, project: project) } + subject { project_environment_deployments_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } @@ -399,6 +404,7 @@ describe "Public Project Access" do describe "GET /:project_path/issues/:id/edit" do let(:issue) { create(:issue, project: project) } + subject { edit_project_issue_path(project, issue) } it { is_expected.to be_allowed_for(:admin) } diff --git a/spec/features/snippets/explore_spec.rb b/spec/features/snippets/explore_spec.rb index 57e91fea709..2075742eafb 100644 --- a/spec/features/snippets/explore_spec.rb +++ b/spec/features/snippets/explore_spec.rb @@ -6,30 +6,59 @@ describe 'Explore Snippets' do let!(:public_snippet) { create(:personal_snippet, :public) } let!(:internal_snippet) { create(:personal_snippet, :internal) } let!(:private_snippet) { create(:personal_snippet, :private) } + let(:user) { nil } - it 'User should see snippets that are not private' do - sign_in create(:user) + before do + sign_in(user) if user visit explore_snippets_path - - expect(page).to have_content(public_snippet.title) - expect(page).to have_content(internal_snippet.title) - expect(page).not_to have_content(private_snippet.title) end - it 'External user should see only public snippets' do - sign_in create(:user, :external) - visit explore_snippets_path + context 'User' do + let(:user) { create(:user) } + + it 'see snippets that are not private' do + expect(page).to have_content(public_snippet.title) + expect(page).to have_content(internal_snippet.title) + expect(page).not_to have_content(private_snippet.title) + end - expect(page).to have_content(public_snippet.title) - expect(page).not_to have_content(internal_snippet.title) - expect(page).not_to have_content(private_snippet.title) + it 'shows new snippet button in header' do + parent_element = page.find('.page-title-controls') + expect(parent_element).to have_link('New snippet') + end end - it 'Not authenticated user should see only public snippets' do - visit explore_snippets_path + context 'External user' do + let(:user) { create(:user, :external) } + + it 'see only public snippets' do + expect(page).to have_content(public_snippet.title) + expect(page).not_to have_content(internal_snippet.title) + expect(page).not_to have_content(private_snippet.title) + end + + context 'without snippets' do + before do + Snippet.delete_all + end + + it 'hides new snippet button' do + expect(page).not_to have_link('New snippet') + end + end + + context 'with snippets' do + it 'hides new snippet button' do + expect(page).not_to have_link('New snippet') + end + end + end - expect(page).to have_content(public_snippet.title) - expect(page).not_to have_content(internal_snippet.title) - expect(page).not_to have_content(private_snippet.title) + context 'Not authenticated user' do + it 'see only public snippets' do + expect(page).to have_content(public_snippet.title) + expect(page).not_to have_content(internal_snippet.title) + expect(page).not_to have_content(private_snippet.title) + end end end diff --git a/spec/features/task_lists_spec.rb b/spec/features/task_lists_spec.rb index acffc4ce580..11429f16f42 100644 --- a/spec/features/task_lists_spec.rb +++ b/spec/features/task_lists_spec.rb @@ -146,6 +146,7 @@ describe 'Task Lists' do describe 'for Notes' do let!(:issue) { create(:issue, author: user, project: project) } + describe 'multiple tasks' do let!(:note) do create(:note, note: markdown, noteable: issue, diff --git a/spec/features/users/login_spec.rb b/spec/features/users/login_spec.rb index b7c54bb6de8..5f4f92e547c 100644 --- a/spec/features/users/login_spec.rb +++ b/spec/features/users/login_spec.rb @@ -406,6 +406,7 @@ describe 'Login' do describe 'with required two-factor authentication enabled' do let(:user) { create(:user) } + # TODO: otp_grace_period_started_at context 'global setting' do |