Commit 02d9f54f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'group-milestones-rspec' into 'master'

Move spinach group milestones test to RSpec

See merge request gitlab-org/gitlab-ce!17051
parents 677951e3 44ec3db4
Feature: Group Milestones
Background:
Given I sign in as "John Doe"
And "John Doe" is owner of group "Owned"
Scenario: I should see group "Owned" milestone index page with no milestones
When I visit group "Owned" page
And I click on group milestones
Then I should see group milestones index page has no milestones
Scenario: I should see group "Owned" milestone index page with milestones
Given Group has projects with milestones
When I visit group "Owned" page
And I click on group milestones
Then I should see group milestones index page with milestones
Scenario: I should see group "Owned" milestone show page
Given Group has projects with milestones
When I visit group "Owned" page
And I click on group milestones
And I click on one group milestone
Then I should see group milestone with descriptions and expiry date
And I should see group milestone with all issues and MRs assigned to that milestone
Scenario: Create group milestones
Given I visit group "Owned" milestones page
And I click new milestone button
And I fill milestone name
When I press create mileston button
Then group milestone should be created
Scenario: I should see Issues listed with labels
Given Group has projects with milestones
When I visit group "Owned" page
And I click on group milestones
And I click on one group milestone
Then I should see the "bug" label
And I should see the "feature" label
And I should see the project name in the Issue row
@javascript
Scenario: I should see the Labels tab
Given Group has projects with milestones
When I visit group "Owned" page
And I click on group milestones
And I click on one group milestone
And I click on the "Labels" tab
Then I should see the list of labels
class Spinach::Features::GroupMilestones < Spinach::FeatureSteps
include WaitForRequests
include SharedAuthentication
include SharedPaths
include SharedGroup
include SharedUser
step 'I click on group milestones' do
visit group_milestones_path('owned')
end
step 'I should see group milestones index page has no milestones' do
expect(page).to have_content('No milestones to show')
end
step 'Group has projects with milestones' do
group_milestone
end
step 'I should see group milestones index page with milestones' do
expect(page).to have_content('Version 7.2')
expect(page).to have_content('GL-113')
expect(page).to have_link('3 Issues', href: issues_group_path("owned", milestone_title: "Version 7.2"))
expect(page).to have_link('0 Merge Requests', href: merge_requests_group_path("owned", milestone_title: "GL-113"))
end
step 'I click on one group milestone' do
milestones = Milestone.where(title: 'GL-113')
@global_milestone = GlobalMilestone.new('GL-113', milestones)
click_link 'GL-113'
end
step 'I should see group milestone with descriptions and expiry date' do
expect(page).to have_content('expires on Aug 20, 2114')
end
step 'I should see group milestone with all issues and MRs assigned to that milestone' do
expect(page).to have_content('Milestone GL-113')
expect(page).to have_content('Issues 3 Open: 3 Closed: 0')
issue = Milestone.find_by(name: 'GL-113').issues.first
expect(page).to have_link(issue.title, href: project_issue_path(issue.project, issue))
end
step 'I fill milestone name' do
fill_in 'milestone_title', with: 'v2.9.0'
end
step 'I click new milestone button' do
page.within('.nav-controls') do
click_link "New milestone"
end
end
step 'I press create mileston button' do
click_button "Create milestone"
end
step 'group milestone should be created' do
group = Group.find_by(name: 'Owned')
expect(page).to have_content group.milestones.find_by_title('v2.9.0').title
end
step 'I should see the "bug" label' do
page.within('#tab-issues') do
expect(page).to have_content 'bug'
end
end
step 'I should see the "feature" label' do
page.within('#tab-issues') do
expect(page).to have_content 'bug'
end
end
step 'I should see the project name in the Issue row' do
page.within('#tab-issues') do
@global_milestone.projects.each do |project|
expect(page).to have_content project.name
end
end
end
step 'I click on the "Labels" tab' do
page.within('.content .nav-links') do
page.find(:xpath, "//a[@href='#tab-labels']").click
end
end
step 'I should see the list of labels' do
wait_for_requests
page.within('#tab-labels') do
expect(page).to have_content 'bug'
expect(page).to have_content 'feature'
end
end
private
def group_milestone
group = owned_group
%w(gitlabhq gitlab-ci cookbook-gitlab).each do |path|
project = create(:project, path: path, group: group)
milestone = create :milestone, title: "Version 7.2", project: project
create(:label, project: project, title: 'bug')
create(:label, project: project, title: 'feature')
create :issue,
project: project,
assignees: [current_user],
author: current_user,
milestone: milestone
milestone = create :milestone,
title: "GL-113",
project: project,
due_date: '2114-08-20',
description: 'Lorem Ipsum is simply dummy text'
issue = create :issue,
project: project,
assignees: [current_user],
author: current_user,
milestone: milestone
issue.labels << project.labels.find_by(title: 'bug')
issue.labels << project.labels.find_by(title: 'feature')
end
current_user.refresh_authorized_projects
end
end
require 'rails_helper' require 'rails_helper'
feature 'Group milestones', :js do feature 'Group milestones' do
let(:group) { create(:group) } let(:group) { create(:group) }
let!(:project) { create(:project_empty_repo, group: group) } let!(:project) { create(:project_empty_repo, group: group) }
let(:user) { create(:group_member, :master, user: create(:user), group: group ).user } let(:user) { create(:group_member, :master, user: create(:user), group: group ).user }
...@@ -13,7 +13,7 @@ feature 'Group milestones', :js do ...@@ -13,7 +13,7 @@ feature 'Group milestones', :js do
sign_in(user) sign_in(user)
end end
context 'create a milestone' do context 'create a milestone', :js do
before do before do
visit new_group_milestone_path(group) visit new_group_milestone_path(group)
end end
...@@ -61,55 +61,132 @@ feature 'Group milestones', :js do ...@@ -61,55 +61,132 @@ feature 'Group milestones', :js do
end end
context 'milestones list' do context 'milestones list' do
let!(:other_project) { create(:project_empty_repo, group: group) } context 'when no milestones' do
it 'renders no milestones text' do
let!(:active_project_milestone1) { create(:milestone, project: project, state: 'active', title: 'v1.0') } visit group_milestones_path(group)
let!(:active_project_milestone2) { create(:milestone, project: other_project, state: 'active', title: 'v1.0') } expect(page).to have_content('No milestones to show')
let!(:closed_project_milestone1) { create(:milestone, project: project, state: 'closed', title: 'v2.0') } end
let!(:closed_project_milestone2) { create(:milestone, project: other_project, state: 'closed', title: 'v2.0') }
let!(:active_group_milestone) { create(:milestone, group: group, state: 'active') }
let!(:closed_group_milestone) { create(:milestone, group: group, state: 'closed') }
before do
visit group_milestones_path(group)
end end
it 'counts milestones correctly' do context 'when milestones exists' do
expect(find('.top-area .active .badge').text).to eq("2") let!(:other_project) { create(:project_empty_repo, group: group) }
expect(find('.top-area .closed .badge').text).to eq("2")
expect(find('.top-area .all .badge').text).to eq("4") let!(:active_project_milestone1) do
end create(
:milestone,
project: project,
state: 'active',
title: 'v1.0',
due_date: '2114-08-20',
description: 'Lorem Ipsum is simply dummy text'
)
end
let!(:active_project_milestone2) { create(:milestone, project: other_project, state: 'active', title: 'v1.0') }
let!(:closed_project_milestone1) { create(:milestone, project: project, state: 'closed', title: 'v2.0') }
let!(:closed_project_milestone2) { create(:milestone, project: other_project, state: 'closed', title: 'v2.0') }
let!(:active_group_milestone) { create(:milestone, group: group, state: 'active', title: 'GL-113') }
let!(:closed_group_milestone) { create(:milestone, group: group, state: 'closed') }
let!(:issue) do
create :issue, project: project, assignees: [user], author: user, milestone: active_project_milestone1
end
it 'lists legacy group milestones and group milestones' do before do
legacy_milestone = GroupMilestone.build_collection(group, group.projects, { state: 'active' }).first visit group_milestones_path(group)
end
expect(page).to have_selector("#milestone_#{active_group_milestone.id}", count: 1) it 'counts milestones correctly' do
expect(page).to have_selector("#milestone_#{legacy_milestone.milestones.first.id}", count: 1) expect(find('.top-area .active .badge').text).to eq("2")
end expect(find('.top-area .closed .badge').text).to eq("2")
expect(find('.top-area .all .badge').text).to eq("4")
end
it 'updates milestone' do it 'lists legacy group milestones and group milestones' do
page.within(".milestones #milestone_#{active_group_milestone.id}") do legacy_milestone = GroupMilestone.build_collection(group, group.projects, { state: 'active' }).first
click_link('Edit')
expect(page).to have_selector("#milestone_#{active_group_milestone.id}", count: 1)
expect(page).to have_selector("#milestone_#{legacy_milestone.milestones.first.id}", count: 1)
end end
page.within('.milestone-form') do it 'updates milestone' do
fill_in 'milestone_title', with: 'new title' page.within(".milestones #milestone_#{active_group_milestone.id}") do
click_button('Update milestone') click_link('Edit')
end
page.within('.milestone-form') do
fill_in 'milestone_title', with: 'new title'
click_button('Update milestone')
end
expect(find('#content-body h2')).to have_content('new title')
end end
expect(find('#content-body h2')).to have_content('new title') it 'shows milestone detail and supports its edit' do
end page.within(".milestones #milestone_#{active_group_milestone.id}") do
click_link(active_group_milestone.title)
end
page.within('.detail-page-header') do
click_link('Edit')
end
it 'shows milestone detail and supports its edit' do expect(page).to have_selector('.milestone-form')
page.within(".milestones #milestone_#{active_group_milestone.id}") do
click_link(active_group_milestone.title)
end end
page.within('.detail-page-header') do it 'renders milestones' do
click_link('Edit') expect(page).to have_content('v1.0')
expect(page).to have_content('GL-113')
expect(page).to have_link(
'1 Issue',
href: issues_group_path(group, milestone_title: 'v1.0')
)
expect(page).to have_link(
'0 Merge Requests',
href: merge_requests_group_path(group, milestone_title: 'v1.0')
)
end end
expect(page).to have_selector('.milestone-form') it 'renders group milestone details' do
click_link 'v1.0'
expect(page).to have_content('expires on Aug 20, 2114')
expect(page).to have_content('v1.0')
expect(page).to have_content('Issues 1 Open: 1 Closed: 0')
expect(page).to have_link(issue.title, href: project_issue_path(issue.project, issue))
end
describe 'labels' do
before do
create(:label, project: project, title: 'bug') do |label|
issue.labels << label
end
create(:label, project: project, title: 'feature') do |label|
issue.labels << label
end
end
it 'renders labels' do
click_link 'v1.0'
page.within('#tab-issues') do
expect(page).to have_content 'bug'
expect(page).to have_content 'feature'
end
end
it 'renders labels list', :js do
click_link 'v1.0'
page.within('.content .nav-links') do
page.find(:xpath, "//a[@href='#tab-labels']").click
end
page.within('#tab-labels') do
expect(page).to have_content 'bug'
expect(page).to have_content 'feature'
end
end
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment