diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-03 21:08:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-03 21:08:19 +0300 |
commit | d83bbccfcd07ddab93be73959e3b149b75831e28 (patch) | |
tree | d8156497696dd1951f6556307cb3689952933eed /spec/features/milestones | |
parent | a99d0fa6922be88307b1c80330a257c55c5d8270 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/milestones')
-rw-r--r-- | spec/features/milestones/user_creates_milestone_spec.rb | 99 |
1 files changed, 85 insertions, 14 deletions
diff --git a/spec/features/milestones/user_creates_milestone_spec.rb b/spec/features/milestones/user_creates_milestone_spec.rb index dd377aa4a26..1ab231632fb 100644 --- a/spec/features/milestones/user_creates_milestone_spec.rb +++ b/spec/features/milestones/user_creates_milestone_spec.rb @@ -3,29 +3,100 @@ require 'spec_helper' RSpec.describe "User creates milestone", :js do - let_it_be(:user) { create(:user) } - let_it_be(:project) { create(:project) } + let_it_be(:developer) { create(:user) } + let_it_be(:inherited_guest) { create(:user) } + let_it_be(:inherited_developer) { create(:user) } + let_it_be(:group) { create(:group, :public) } + + shared_examples 'creates milestone' do + specify do + title = "v2.3" + + fill_in("Title", with: title) + fill_in("Description", with: "# Description header") + click_button("Create milestone") + + expect(page).to have_content(title) + .and have_content("Issues") + .and have_header_with_correct_id_and_link(1, "Description header", "description-header") + + visit(activity_project_path(project)) + + expect(page).to have_content("#{user.name} #{user.to_reference} opened milestone") + end + end + + shared_examples 'renders not found' do + specify do + expect(page).to have_title('Not Found') + expect(page).to have_content('Page Not Found') + end + end + + before_all do + group.add_guest(inherited_guest) + group.add_developer(inherited_developer) + end before do - project.add_developer(user) sign_in(user) - visit(new_project_milestone_path(project)) end - it "creates milestone" do - title = "v2.3" + context 'when project is public' do + let_it_be(:project) { create(:project, :public, group: group) } + + context 'and issues and merge requests are private' do + before_all do + project.project_feature.update!( + issues_access_level: ProjectFeature::PRIVATE, + merge_requests_access_level: ProjectFeature::PRIVATE + ) + end + + context 'when user is an inherited member from the group' do + context 'and user is a guest' do + let(:user) { inherited_guest } + + it_behaves_like 'renders not found' + end + + context 'and user is a developer' do + let(:user) { inherited_developer } + + it_behaves_like 'creates milestone' + end + end + end + end + + context 'when project is private' do + let_it_be(:project) { create(:project, :private, group: group) } + + context 'and user is a direct project member' do + before_all do + project.add_developer(developer) + end + + context 'when user is a developer' do + let(:user) { developer } + + it_behaves_like 'creates milestone' + end + end - fill_in("Title", with: title) - fill_in("Description", with: "# Description header") - click_button("Create milestone") + context 'and user is an inherited member from the group' do + context 'when user is a guest' do + let(:user) { inherited_guest } - expect(page).to have_content(title) - .and have_content("Issues") - .and have_header_with_correct_id_and_link(1, "Description header", "description-header") + it_behaves_like 'renders not found' + end - visit(activity_project_path(project)) + context 'when user is a developer' do + let(:user) { inherited_developer } - expect(page).to have_content("#{user.name} #{user.to_reference} opened milestone") + it_behaves_like 'creates milestone' + end + end end end |