2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-03-23 06:39:58 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Dashboard > Milestones' do
|
2016-03-23 06:39:58 -04:00
|
|
|
describe 'as anonymous user' do
|
|
|
|
before do
|
|
|
|
visit dashboard_milestones_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is redirected to sign-in page' do
|
|
|
|
expect(current_path).to eq new_user_session_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'as logged-in user' do
|
|
|
|
let(:user) { create(:user) }
|
2018-08-26 05:04:58 -04:00
|
|
|
let(:group) { create(:group) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
2016-03-23 06:39:58 -04:00
|
|
|
let!(:milestone) { create(:milestone, project: project) }
|
2018-08-26 05:04:58 -04:00
|
|
|
let!(:milestone2) { create(:milestone, group: group) }
|
2018-09-10 20:37:21 -04:00
|
|
|
|
2016-03-23 06:39:58 -04:00
|
|
|
before do
|
2018-09-10 20:37:21 -04:00
|
|
|
group.add_developer(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-03-23 06:39:58 -04:00
|
|
|
visit dashboard_milestones_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sees milestones' do
|
|
|
|
expect(current_path).to eq dashboard_milestones_path
|
|
|
|
expect(page).to have_content(milestone.title)
|
2018-08-26 05:04:58 -04:00
|
|
|
expect(page).to have_content(group.name)
|
2021-04-05 17:09:19 -04:00
|
|
|
expect(first('.milestone')).to have_content('Merge requests')
|
2016-03-23 06:39:58 -04:00
|
|
|
end
|
2021-09-07 11:11:06 -04:00
|
|
|
|
|
|
|
describe 'new milestones dropdown', :js do
|
|
|
|
it 'takes user to a new milestone page', :js do
|
|
|
|
find('.new-project-item-select-button').click
|
|
|
|
|
|
|
|
page.within('.select2-results') do
|
|
|
|
first('.select2-result-label').click
|
|
|
|
end
|
|
|
|
|
|
|
|
find('.new-project-item-link').click
|
|
|
|
|
|
|
|
expect(current_path).to eq(new_group_milestone_path(group))
|
|
|
|
end
|
|
|
|
end
|
2016-03-23 06:39:58 -04:00
|
|
|
end
|
2019-12-03 13:06:49 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
expect(current_path).to eq dashboard_milestones_path
|
|
|
|
expect(page).to have_content(milestone.title)
|
|
|
|
expect(first('.milestone')).to have_no_content('Merge Requests')
|
|
|
|
end
|
|
|
|
end
|
2016-03-23 06:39:58 -04:00
|
|
|
end
|