2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'Dashboard > Milestones', feature_category: :team_planning do
|
2016-06-02 11:05:42 +05:30
|
|
|
describe 'as anonymous user' do
|
|
|
|
before do
|
|
|
|
visit dashboard_milestones_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is redirected to sign-in page' do
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_current_path new_user_session_path, ignore_query: true
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'as logged-in user' do
|
|
|
|
let(:user) { create(:user) }
|
2018-11-20 20:47:30 +05:30
|
|
|
let(:group) { create(:group) }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
2016-06-02 11:05:42 +05:30
|
|
|
let!(:milestone) { create(:milestone, project: project) }
|
2018-11-20 20:47:30 +05:30
|
|
|
let!(:milestone2) { create(:milestone, group: group) }
|
2018-12-05 23:21:45 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
before do
|
2018-12-05 23:21:45 +05:30
|
|
|
group.add_developer(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
2016-06-02 11:05:42 +05:30
|
|
|
visit dashboard_milestones_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sees milestones' do
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_current_path dashboard_milestones_path, ignore_query: true
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(page).to have_content(milestone.title)
|
2018-11-20 20:47:30 +05:30
|
|
|
expect(page).to have_content(group.name)
|
2021-04-29 21:17:54 +05:30
|
|
|
expect(first('.milestone')).to have_content('Merge requests')
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
|
|
|
|
describe 'new milestones dropdown', :js do
|
|
|
|
it 'takes user to a new milestone page', :js do
|
2022-01-26 12:08:38 +05:30
|
|
|
click_button 'Toggle project select'
|
2019-09-30 21:07:59 +05:30
|
|
|
|
|
|
|
page.within('.select2-results') do
|
|
|
|
first('.select2-result-label').click
|
|
|
|
end
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
a_el = find('.js-new-project-item-link')
|
|
|
|
|
|
|
|
expect(a_el).to have_content('New Milestone in ')
|
|
|
|
expect(a_el).to have_no_content('New New Milestone in ')
|
|
|
|
|
|
|
|
a_el.click
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_current_path(new_group_milestone_path(group), ignore_query: true)
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
describe 'with merge requests disabled' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:project, :merge_requests_disabled, namespace: user.namespace) }
|
|
|
|
let!(:milestone) { create(:milestone, project: project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_developer(user)
|
|
|
|
sign_in(user)
|
|
|
|
visit dashboard_milestones_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not see milestones' do
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_current_path dashboard_milestones_path, ignore_query: true
|
2020-01-01 13:55:28 +05:30
|
|
|
expect(page).to have_content(milestone.title)
|
|
|
|
expect(first('.milestone')).to have_no_content('Merge Requests')
|
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|