Commit a8ce107c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Cucumber feature -> Merge Request

parent ac9cec74
Feature: Merge Requests
Background:
Given I signin as a user
And I own project "Shop"
And project "Shop" have "Bug NS-04" open merge request
And project "Shop" have "Feature NS-03" closed merge request
And I visit project "Shop" merge requests page
Scenario: I should see open merge requests
Then I should see "Bug NS-04" in merge requests
And I should not see "Feature NS-03" in merge requests
Scenario: I should see closed merge requests
Given I click link "Closed"
Then I should see "Feature NS-03" in merge requests
And I should not see "Bug NS-04" in merge requests
Scenario: I should see all merge requests
Given I click link "All"
Then I should see "Feature NS-03" in merge requests
And I should see "Bug NS-04" in merge requests
Scenario: I visit merge request page
Given I click link "Bug NS-04"
Then I should see merge request "Bug NS-04"
Scenario: I close merge request page
Given I click link "Bug NS-04"
And I click link "Close"
Then I should see closed merge request "Bug NS-04"
Scenario: I submit new unassigned merge request
Given I click link "New Merge Request"
And I submit new merge request "Wiki Feature"
Then I should see merge request "Wiki Feature"
@javascript
Scenario: I comment merge request
Given I visit merge request page "Bug NS-04"
And I leave a comment like "XML attached"
Then I should see comment "XML attached"
Given /^project "(.*?)" has milestone "(.*?)"$/ do |arg1, arg2|
Given /^project "(.*?)" have "(.*?)" open merge request$/ do |arg1, arg2|
project = Project.find_by_name(arg1)
Factory.create(:merge_request, :title => arg2, :project => project, :author => project.users.first)
end
Given /^project "(.*?)" have "(.*?)" closed merge request$/ do |arg1, arg2|
project = Project.find_by_name(arg1)
Factory.create(:merge_request, :title => arg2, :project => project, :author => project.users.first, :closed => true)
end
milestone = Factory :milestone,
:title => arg2,
:project => project
Given /^I visit project "(.*?)" merge requests page$/ do |arg1|
visit project_merge_requests_path(Project.find_by_name(arg1))
end
Then /^I should see "(.*?)" in merge requests$/ do |arg1|
page.should have_content arg1
end
3.times do |i|
issue = Factory :issue,
:project => project,
:milestone => milestone
end
Then /^I should not see "(.*?)" in merge requests$/ do |arg1|
page.should_not have_content arg1
end
Given /^I visit project "(.*?)" milestones page$/ do |arg1|
@project = Project.find_by_name(arg1)
visit project_milestones_path(@project)
Then /^I should see merge request "(.*?)"$/ do |arg1|
merge_request = MergeRequest.find_by_title(arg1)
page.should have_content(merge_request.title[0..10])
page.should have_content(merge_request.target_branch)
page.should have_content(merge_request.source_branch)
end
Then /^I should see active milestones$/ do
milestone = @project.milestones.first
page.should have_content(milestone.title[0..10])
page.should have_content(milestone.expires_at)
page.should have_content("Browse Issues")
Given /^I submit new merge request "(.*?)"$/ do |arg1|
fill_in "merge_request_title", :with => arg1
select "master", :from => "merge_request_source_branch"
select "stable", :from => "merge_request_target_branch"
click_button "Save"
end
Then /^I should see milestone "(.*?)"$/ do |arg1|
milestone = @project.milestones.find_by_title(arg1)
page.should have_content(milestone.title[0..10])
page.should have_content(milestone.expires_at)
page.should have_content("Browse Issues")
Given /^I visit merge request page "(.*?)"$/ do |arg1|
mr = MergeRequest.find_by_title(arg1)
visit project_merge_request_path(mr.project, mr)
end
Given /^I submit new milestone "(.*?)"$/ do |arg1|
fill_in "milestone_title", :with => arg1
click_button "Create milestone"
Then /^I should see closed merge request "(.*?)"$/ do |arg1|
mr = MergeRequest.find_by_title(arg1)
mr.closed.should be_true
page.should have_content "Closed by"
end
Given /^project "(.*?)" has milestone "(.*?)"$/ do |arg1, arg2|
project = Project.find_by_name(arg1)
milestone = Factory :milestone,
:title => arg2,
:project => project
3.times do |i|
issue = Factory :issue,
:project => project,
:milestone => milestone
end
end
Given /^I visit project "(.*?)" milestones page$/ do |arg1|
@project = Project.find_by_name(arg1)
visit project_milestones_path(@project)
end
Then /^I should see active milestones$/ do
milestone = @project.milestones.first
page.should have_content(milestone.title[0..10])
page.should have_content(milestone.expires_at)
page.should have_content("Browse Issues")
end
Then /^I should see milestone "(.*?)"$/ do |arg1|
milestone = @project.milestones.find_by_title(arg1)
page.should have_content(milestone.title[0..10])
page.should have_content(milestone.expires_at)
page.should have_content("Browse Issues")
end
Given /^I submit new milestone "(.*?)"$/ do |arg1|
fill_in "milestone_title", :with => arg1
click_button "Create milestone"
end
require 'spec_helper'
describe "MergeRequests" do
let(:project) { Factory :project }
before do
login_as :user
project.add_access(@user, :read, :write)
@merge_request = Factory :merge_request,
:author => @user,
:assignee => @user,
:project => project
end
describe "GET /merge_requests" do
before do
visit project_merge_requests_path(project)
end
subject { page }
it { should have_content(@merge_request.title[0..10]) }
it { should have_content(@merge_request.target_branch) }
it { should have_content(@merge_request.source_branch) }
it { should have_content(@merge_request.assignee.name) }
end
describe "GET /merge_request/:id" do
before do
visit project_merge_request_path(project, @merge_request)
end
subject { page }
it { should have_content(@merge_request.title[0..10]) }
it { should have_content(@merge_request.target_branch) }
it { should have_content(@merge_request.source_branch) }
it { should have_content(@merge_request.assignee.name) }
describe "Close merge request" do
before { click_link "Close" }
it { should have_content(@merge_request.title[0..10]) }
it "Show page should inform user that merge request closed" do
page.should have_content "Closed"
end
end
end
describe "GET /merge_requests/new" do
before do
visit new_project_merge_request_path(project)
fill_in "merge_request_title", :with => "Merge Request Title"
select "master", :from => "merge_request_source_branch"
select "stable", :from => "merge_request_target_branch"
select @user.name, :from => "merge_request_assignee_id"
click_button "Save"
end
it { current_path.should == project_merge_request_path(project, project.merge_requests.last) }
it "should create merge request" do
page.should have_content "Close"
page.should have_content @user.name
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