Commit 3f01ec2d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #1426 from NARKOZ/spinach

Cucumber => Spinach
parents 8674fba1 79eb5ab3
......@@ -106,6 +106,7 @@ group :development do
end
group :development, :test do
gem 'spinach-rails'
gem "rspec-rails"
gem "capybara"
gem "capybara-webkit"
......@@ -118,7 +119,7 @@ group :development, :test do
# Guard
gem 'guard-rspec'
gem 'guard-cucumber'
gem 'guard-spinach'
# Notification
gem 'rb-fsevent', :require => darwin_only('rb-fsevent')
......@@ -127,7 +128,6 @@ group :development, :test do
end
group :test do
gem 'cucumber-rails', :require => false
gem "simplecov", :require => false
gem "shoulda-matchers"
gem 'email_spec'
......
......@@ -132,16 +132,8 @@ GEM
execjs
coffee-script-source (1.3.3)
colored (1.2)
colorize (0.5.8)
crack (0.3.1)
cucumber (1.2.1)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.11.0)
json (>= 1.4.6)
cucumber-rails (1.3.0)
capybara (>= 1.1.2)
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
daemons (1.1.8)
database_cleaner (0.8.0)
devise (2.1.2)
......@@ -170,8 +162,7 @@ GEM
ffi (1.0.11)
foreman (0.47.0)
thor (>= 0.13.6)
gherkin (2.11.0)
json (>= 1.4.6)
gherkin-ruby (0.2.1)
git (1.2.5)
github-markup (0.7.4)
gitlab_meta (2.9)
......@@ -185,11 +176,11 @@ GEM
guard (1.3.2)
listen (>= 0.4.2)
thor (>= 0.14.6)
guard-cucumber (1.2.0)
cucumber (>= 1.2.0)
guard (>= 1.1.0)
guard-rspec (1.2.1)
guard (>= 1.1)
guard-spinach (0.0.2)
guard (>= 1.1)
spinach
haml (3.1.6)
haml-rails (0.3.4)
actionpack (~> 3.0)
......@@ -344,6 +335,13 @@ GEM
tilt (~> 1.3, >= 1.3.3)
six (0.2.0)
slop (2.4.4)
spinach (0.5.2)
colorize
gherkin-ruby (~> 0.2.0)
spinach-rails (0.1.8)
capybara (~> 1)
railties (>= 3)
spinach (>= 0.4)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
......@@ -394,7 +392,6 @@ DEPENDENCIES
chosen-rails
coffee-rails (= 3.2.2)
colored
cucumber-rails
database_cleaner
devise (~> 2.1.0)
draper
......@@ -410,8 +407,8 @@ DEPENDENCIES
grape (~> 0.2.1)
grit!
growl
guard-cucumber
guard-rspec
guard-spinach
haml-rails
headless
httparty
......@@ -442,6 +439,7 @@ DEPENDENCIES
shoulda-matchers
simplecov
six
spinach-rails
sqlite3
stamp
therubyracer
......
......@@ -13,18 +13,14 @@ guard 'rspec', :version => 2 do
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
guard 'cucumber' do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
guard 'spinach' do
watch(%r|^features/(.*)\.feature|)
watch(%r|^features/steps/(.*)([^/]+)\.rb|) do |m|
"features/#{m[1]}#{m[2]}.feature"
end
end
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
Feature: Dashboard
Background:
Given I signin as a user
Background:
Given I sign in as a user
And I own project "Shop"
And project "Shop" has push event
And I visit dashboard page
And I visit dashboard page
Scenario: I should see projects list
Then I should see "New Project" link
......@@ -25,4 +25,3 @@ Feature: Dashboard
And user with name "John Doe" left project "Shop"
When I visit dashboard page
Then I should see "John Doe left project Shop" event
Feature: Dashboard Issues
Background:
Given I signin as a user
Background:
Given I sign in as a user
And I have assigned issues
And I visit dashboard issues page
And I visit dashboard issues page
Scenario: I should see issues list
Then I should see issues assigned to me
Feature: Dashboard MR
Background:
Given I signin as a user
Feature: Dashboard Merge Requests
Background:
Given I sign in as a user
And I have authored merge requests
And I visit dashboard merge requests page
And I visit dashboard merge requests page
Scenario: I should see projects list
Then I should see my merge requests
Feature: Dashboard Search
Background:
Given I signin as a user
Background:
Given I sign in as a user
And I own project "Shop"
And I visit dashboard search page
And I visit dashboard search page
Scenario: I should see project i'm looking for
Scenario: I should see project I am looking for
Given I search for "Sho"
Then I should see "Shop" project link
Feature: Profile
Background:
Given I signin as a user
Background:
Given I sign in as a user
Scenario: I look at my profile
Given I visit profile page
......
Feature: SSH Keys
Background:
Given I signin as a user
And I have ssh keys:
| title |
| ssh-rsa Work |
| ssh-rsa Home |
Feature: Profile SSH Keys
Background:
Given I sign in as a user
And I have ssh key "ssh-rsa Work"
And I visit profile keys page
Scenario: I should see SSH keys
Scenario: I should see ssh keys
Then I should see my ssh keys
Scenario: Add new ssh key
......
Feature: Browse branches
Background:
Given I signin as a user
Feature: Project Browse branches
Background:
Given I sign in as a user
And I own project "Shop"
And project "Shop" has protected branches
Given I visit project branches page
......@@ -16,8 +16,11 @@ Feature: Browse branches
Given I click link "Protected"
Then I should see "Shop" protected branches list
Scenario: I can download project by branch
# @wip
# Scenario: I can download project by branch
Scenario: I can view protected branches
# @wip
# Scenario: I can view protected branches
Scenario: I can manage protected branches
# @wip
# Scenario: I can manage protected branches
Feature: Comment commit
Background:
Given I signin as a user
Feature: Project Comment commit
Background:
Given I sign in as a user
And I own project "Shop"
Given I visit project commit page
......
Feature: Browse commits
Background:
Given I signin as a user
Feature: Project Browse commits
Background:
Given I sign in as a user
And I own project "Shop"
Given I visit project commits page
......@@ -18,5 +18,4 @@ Feature: Browse commits
Scenario: I compare refs
Given I visit compare refs page
And I fill compare fields with refs
And I see compared refs
And I see compared refs
Feature: Browse tags
Background:
Given I signin as a user
Feature: Project Browse tags
Background:
Given I sign in as a user
And I own project "Shop"
Given I visit project tags page
Scenario: I can see all git tags
Then I should see "Shop" all tags list
Scenario: I can download project by tag
# @wip
# Scenario: I can download project by tag
......@@ -4,7 +4,7 @@ Feature: Create Project
Should be able to create a new one
Scenario: User create a project
Given I signin as a user
Given I sign in as a user
When I visit new project page
And fill project form with valid data
Then I should see project page
......
Feature: Issues
Feature: Project Issues
Background:
Given I signin as a user
Given I sign in as a user
And I own project "Shop"
And project "Shop" have "Release 0.4" open issue
And project "Shop" have "Release 0.3" closed issue
......@@ -79,4 +79,3 @@ Feature: Issues
When I select first assignee from "Shop" project
And I click link "New Issue"
Then I should see first assignee from "Shop" as selected assignee
Feature: Labels
Feature: Project Labels
Background:
Given I signin as a user
Given I sign in as a user
And I own project "Shop"
And project "Shop" have issues tags:
| name |
| bug |
| feature |
Given I visit project "Shop" labels page
And project "Shop" have issues tags: "bug", "feature"
Given I visit project "Shop" labels page
Scenario: I should see active milestones
Then I should see label "bug"
......
Feature: Milestones
Feature: Project Milestones
Background:
Given I signin as a user
Given I sign in as a user
And I own project "Shop"
And project "Shop" has milestone "v2.2"
Given I visit project "Shop" milestones page
Given I visit project "Shop" milestones page
Scenario: I should see active milestones
Then I should see milestone "v2.2"
......
Feature: Merge Requests
Feature: Project Merge Requests
Background:
Given I signin as a user
Given I sign in 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
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
......
@javascript
Feature: Project Network Graph
Background:
Given I signin as a user
Given I sign in as a user
And I own project "Shop"
And I visit project "Shop" network page
@javascript
Scenario: I should see project network
Then page should have network graph
Feature: Projects
Background:
Given I signin as a user
And I own project "Shop"
And I visit project "Shop" page
# @wip
# Scenario: I should see project activity
# @wip
# Scenario: I edit project
# @wip
# Scenario: I visit attachments
Feature: Browse git repo
Background:
Given I signin as a user
Feature: Project Browse files
Background:
Given I sign in as a user
And I own project "Shop"
Given I visit project source page
......@@ -12,12 +12,10 @@ Feature: Browse git repo
Then I should see files from repository for "8470d70"
Scenario: I browse file content
Given I click on file from repo
Given I click on "Gemfile" file in repo
Then I should see it content
Scenario: I browse raw file
Given I visit blob file from repo
And I click on raw button
Given I visit blob file from repo
And I click link "raw"
Then I should see raw file content
Feature: Browse git repo
Background:
Given I signin as a user
Feature: Project Browse git repo
Background:
Given I sign in as a user
And I own project "Shop"
Given I visit project source page
Scenario: I blame file
Given I click on file from repo
Given I click on "Gemfile" file in repo
And I click blame button
Then I should see git file blame
Then I should see git file blame
Feature: Project Team management
Background:
Given I signin as a user
Background:
Given I sign in as a user
And I own project "Shop"
And gitlab user "Mike"
And gitlab user "Sam"
And gitlab user "Mike"
And gitlab user "Sam"
And "Sam" is "Shop" developer
And I visit project "Shop" team page
And I visit project "Shop" team page
Scenario: See all team members
Then I should be able to see myself in team
......@@ -20,7 +20,7 @@ Feature: Project Team management
Scenario: Update user access
Given I should see "Sam" in team list as "Developer"
And I change "Sam" role to "Reporter"
Then I visit project "Shop" team page
Then I visit project "Shop" team page
And I should see "Sam" in team list as "Reporter"
Scenario: View team member profile
......@@ -30,6 +30,5 @@ Feature: Project Team management
Scenario: Cancel team member
Given I click link "Sam"
And I click link "Remove from team"
Then I visit project "Shop" team page
Then I visit project "Shop" team page
And I should not see "Sam" in team list
@javascript
Feature: Project Wall
In order to use Project Wall
A user
Should be able to read & write messages
A user should be able to read and write messages
Background:
Given I signin as a user
Given I sign in as a user
And I own project "Shop"
And I visit project "Shop" wall page
And I visit project "Shop" wall page
@javascript
Scenario: Write comment
Given I write new comment "my special test message"
Then I should see project wall note "my special test message"
Then I visit project "Shop" wall page
Then I visit project "Shop" wall page
And I should see project wall note "my special test message"
Feature: Wiki
Background:
Given I signin as a user
Feature: Project Wiki
Background:
Given I sign in as a user
And I own project "Shop"
Given I visit project wiki page
......
Feature: Project
Background:
Given I signin as a user
And I own project "Shop"
And I visit project "Shop" page
Scenario: I should see project activity
Scenario: I edit project
Scenario: I visit attachments
include LoginHelpers
Given /^I signin as a user$/ do
login_as :user
end
When /^I click link "(.*?)"$/ do |link|
click_link link
end
When /^I click button "(.*?)"$/ do |button|
click_button button
end
When /^I fill in "(.*?)" with "(.*?)"$/ do |field, value|
fill_in field, :with => value
end
Given /^show me page$/ do
save_and_open_page
end
Then /^I should see "(.*?)" link$/ do |arg1|
page.should have_link(arg1)
end
Then /^I should see "(.*?)" project link$/ do |arg1|
page.should have_link(arg1)
end
Then /^I should see project "(.*?)" activity feed$/ do |arg1|
project = Project.find_by_name(arg1)
page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}"
end
Given /^project "(.*?)" has push event$/ do |arg1|
@project = Project.find_by_name(arg1)
data = {
:before => "0000000000000000000000000000000000000000",
:after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
:ref => "refs/heads/new_design",
:user_id => @user.id,
:user_name => @user.name,
:repository => {
:name => @project.name,
:url => "localhost/rubinius",
:description => "",
:homepage => "localhost/rubinius",
:private => true
}
}
@event = Event.create(
:project => @project,
:action => Event::Pushed,
:data => data,
:author_id => @user.id
)
end
Then /^I should see last push widget$/ do
page.should have_content "Your pushed to branch new_design"
page.should have_link "Create Merge Request"
end
Then /^I click "(.*?)" link$/ do |arg1|
click_link arg1 #Create Merge Request"
end
Then /^I see prefilled new Merge Request page$/ do
current_path.should == new_project_merge_request_path(@project)
find("#merge_request_source_branch").value.should == "new_design"
find("#merge_request_target_branch").value.should == "master"
find("#merge_request_title").value.should == "New Design"
end
Given /^I visit dashboard search page$/ do
visit search_path
end
Given /^I search for "(.*?)"$/ do |arg1|
fill_in "dashboard_search", :with => arg1
click_button "Search"
end
Then /^I should see issues assigned to me$/ do
issues = @user.issues
issues.each do |issue|
page.should have_content(issue.title[0..10])
page.should have_content(issue.project.name)
end
end
Then /^I should see my merge requests$/ do
merge_requests = @user.merge_requests
merge_requests.each do |mr|
page.should have_content(mr.title[0..10])
page.should have_content(mr.project.name)
end
end
Given /^I have assigned issues$/ do
project = Factory :project
project.add_access(@user, :read, :write)
issue1 = Factory :issue,
:author => @user,
:assignee => @user,
:project => project
issue2 = Factory :issue,
:author => @user,
:assignee => @user,
:project => project
end
Given /^I have authored merge requests$/ do
project1 = Factory :project
project2 = Factory :project
project1.add_access(@user, :read, :write)
project2.add_access(@user, :read, :write)
merge_request1 = Factory :merge_request,
:author => @user,
:project => project1
merge_request2 = Factory :merge_request,
:author => @user,
:project => project2
end
Given /^user with name "(.*?)" joined project "(.*?)"$/ do |user_name, project_name|
user = Factory.create(:user, {name: user_name})
project = Project.find_by_name project_name
Event.create(
project: project,
author_id: user.id,
action: Event::Joined
)
end
Given /^user with name "(.*?)" left project "(.*?)"$/ do |user_name, project_name|
user = User.find_by_name user_name
project = Project.find_by_name project_name
Event.create(
project: project,
author_id: user.id,
action: Event::Left
)
end
Then /^I should see "(.*?)" event$/ do |event_text|
page.should have_content(event_text)
end
Given /^I visit profile keys page$/ do
visit keys_path
end
Then /^I should see my ssh keys$/ do
@user.keys.each do |key|
page.should have_content(key.title)
end
end
Given /^I have ssh keys:$/ do |table|
table.hashes.each do |row|
Factory :key, :user => @user, :title => row[:title], :key => "jfKLJDFKSFJSHFJ#{row[:title]}"
end
end
Given /^I submit new ssh key "(.*?)"$/ do |arg1|
fill_in "key_title", :with => arg1
fill_in "key_key", :with => "ssh-rsa publickey234="
click_button "Save"
end
Then /^I should see new ssh key "(.*?)"$/ do |arg1|
key = Key.find_by_title(arg1)
page.should have_content(key.title)
page.should have_content(key.key)
current_path.should == key_path(key)
end
Then /^I should not see "(.*?)" ssh key$/ do |arg1|
within "#keys-table" do
page.should_not have_content(arg1)
end
end
Then /^I should see my profile info$/ do
page.should have_content "Profile"
page.should have_content @user.name
page.should have_content @user.email
end
Then /^I change my password$/ do
fill_in "user_password", :with => "222333"
fill_in "user_password_confirmation", :with => "222333"
click_button "Save"
end
Then /^I should be redirected to sign in page$/ do
current_path.should == new_user_session_path
end
Then /^I reset my token$/ do
@old_token = @user.private_token
click_button "Reset"
end
Then /^I should see new token$/ do
find("#token").value.should_not == @old_token
find("#token").value.should == @user.reload.private_token
end
Then /^I change my contact info$/ do
fill_in "user_skype", :with => "testskype"
fill_in "user_linkedin", :with => "testlinkedin"
fill_in "user_twitter", :with => "testtwitter"
click_button "Save"
@user.reload
end
Then /^I should see new contact info$/ do
@user.skype.should == 'testskype'
@user.linkedin.should == 'testlinkedin'
@user.twitter.should == 'testtwitter'
end
Then /^I should see files from repository$/ do
page.should have_content("app")
page.should have_content("History")
page.should have_content("Gemfile")
end
Then /^I should see files from repository for "(.*?)"$/ do |arg1|
current_path.should == tree_project_ref_path(@project, arg1)
page.should have_content("app")
page.should have_content("History")
page.should have_content("Gemfile")
end
Given /^I click on file from repo$/ do
click_link "Gemfile"
end
Then /^I should see it content$/ do
page.should have_content("rubygems.org")
end
Given /^I click on raw button$/ do
click_link "raw"
end
Then /^I should see raw file content$/ do
page.source.should == ValidCommit::BLOB_FILE
end
Given /^I click blame button$/ do
click_link "blame"
end
Then /^I should see git file blame$/ do
page.should have_content("rubygems.org")
page.should have_content("Dmitriy Zaporozhets")
page.should have_content("bc3735004cb Moving to rails 3.2")
end
Then /^I see project commits$/ do
current_path.should == project_commits_path(@project)
commit = @project.commit
page.should have_content(@project.name)
page.should have_content(commit.message)
page.should have_content(commit.id.to_s[0..5])
end
Given /^I click atom feed link$/ do
click_link "Feed"
end
Then /^I see commits atom feed$/ do
commit = CommitDecorator.decorate(@project.commit)
page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "Recent commits to #{@project.name}")
page.body.should have_selector("author email", :text => commit.author_email)
page.body.should have_selector("entry summary", :text => commit.description)
end
Then /^I see commit info$/ do
page.should have_content ValidCommit::MESSAGE
page.should have_content "Showing 1 changed file"
end
Given /^I fill compare fields with refs$/ do
fill_in "from", :with => "master"
fill_in "to", :with => "stable"
click_button "Compare"
end
Given /^I see compared refs$/ do
page.should have_content "Commits (27)"
page.should have_content "Compare View"
page.should have_content "Showing 73 changed files"
end
Then /^I should see "(.*?)" recent branches list$/ do |arg1|
page.should have_content("Branches")
page.should have_content("master")
end
Then /^I should see "(.*?)" all branches list$/ do |arg1|
page.should have_content("Branches")
page.should have_content("master")
end
Then /^I should see "(.*?)" all tags list$/ do |arg1|
page.should have_content("Tags")
page.should have_content("v1.2.1")
end
Then /^I should see "(.*?)" protected branches list$/ do |arg1|
within "table" do
page.should have_content "stable"
page.should_not have_content "master"
end
end
Given /^project "(.*?)" has protected branches$/ do |arg1|
project = Project.find_by_name(arg1)
project.protected_branches.create(:name => "stable")
end
Given /^project "(.*?)" have "(.*?)" open issue$/ do |arg1, arg2|
project = Project.find_by_name(arg1)
Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first)
end
Given /^project "(.*?)" have "(.*?)" closed issue$/ do |arg1, arg2|
project = Project.find_by_name(arg1)
Factory.create(:issue, :title => arg2, :project => project, :author => project.users.first, :closed => true)
end
Given /^I should see "(.*?)" in issues$/ do |arg1|
page.should have_content arg1
end
Given /^I should not see "(.*?)" in issues$/ do |arg1|
page.should_not have_content arg1
end
Then /^I should see issue "(.*?)"$/ do |arg1|
issue = Issue.find_by_title(arg1)
page.should have_content issue.title
page.should have_content issue.author_name
page.should have_content issue.project.name
end
Given /^I submit new issue "(.*?)"$/ do |arg1|
fill_in "issue_title", with: arg1
click_button "Submit new issue"
end
Given /^project "(.*?)" have issues tags:$/ do |arg1, table|
project = Project.find_by_name(arg1)
table.hashes.each do |hash|
Factory :issue,
project: project,
label_list: [hash[:name]]
end
end
Given /^I visit project "(.*?)" labels page$/ do |arg1|
visit project_labels_path(Project.find_by_name(arg1))
end
Then /^I should see label "(.*?)"$/ do |arg1|
within ".labels-table" do
page.should have_content arg1
end
end
Given /^I fill in issue search with "(.*?)"$/ do |arg1|
# Because fill_in, with: "" triggers nothing
# we need to trigger a keyup event
if arg1 == ''
page.execute_script("$('.issue_search').val('').keyup();");
end
fill_in 'issue_search', with: arg1
end
When /^I select milestone "(.*?)"$/ do |milestone_title|
select milestone_title, from: "milestone_id"
end
Then /^I should see selected milestone with title "(.*?)"$/ do |milestone_title|
issues_milestone_selector = "#issue_milestone_id_chzn/a"
wait_until{ page.has_content?("Details") }
page.find(issues_milestone_selector).should have_content(milestone_title)
end
When /^I select first assignee from "(.*?)" project$/ do |project_name|
project = Project.find_by_name project_name
first_assignee = project.users.first
select first_assignee.name, from: "assignee_id"
end
Then /^I should see first assignee from "(.*?)" as selected assignee$/ do |project_name|
issues_assignee_selector = "#issue_assignee_id_chzn/a"
wait_until{ page.has_content?("Details") }
project = Project.find_by_name project_name
assignee_name = project.users.first.name
page.find(issues_assignee_selector).should have_content(assignee_name)
end
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
Then /^I should see "(.*?)" in merge requests$/ do |arg1|
page.should have_content arg1
end
Then /^I should not see "(.*?)" in merge requests$/ do |arg1|
page.should_not have_content arg1
end
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
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 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
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
Given /^gitlab user "(.*?)"$/ do |arg1|
Factory :user, :name => arg1
end
Given /^"(.*?)" is "(.*?)" developer$/ do |arg1, arg2|
user = User.find_by_name(arg1)
project = Project.find_by_name(arg2)
project.add_access(user, :write)
end
Then /^I should be able to see myself in team$/ do
page.should have_content(@user.name)
page.should have_content(@user.email)
end
Then /^I should see "(.*?)" in team list$/ do |arg1|
user = User.find_by_name(arg1)
page.should have_content(user.name)
page.should have_content(user.email)
end
Given /^I select "(.*?)" as "(.*?)"$/ do |arg1, arg2|
user = User.find_by_name(arg1)
within "#new_team_member" do
select user.name, :from => "user_ids"
select arg2, :from => "project_access"
end
click_button "Save"
end
Then /^I should see "(.*?)" in team list as "(.*?)"$/ do |arg1, arg2|
user = User.find_by_name(arg1)
role_id = find(".user_#{user.id} #team_member_project_access").value
role_id.should == UsersProject.access_roles[arg2].to_s
end
Given /^I change "(.*?)" role to "(.*?)"$/ do |arg1, arg2|
user = User.find_by_name(arg1)
within ".user_#{user.id}" do
select arg2, :from => "team_member_project_access"
end
end
Then /^I should see "(.*?)" team profile$/ do |arg1|
user = User.find_by_name(arg1)
page.should have_content(user.name)
page.should have_content(user.email)
page.should have_content("To team list")
end
Then /^I should not see "(.*?)" in team list$/ do |arg1|
user = User.find_by_name(arg1)
page.should_not have_content(user.name)
page.should_not have_content(user.email)
end
Given /^I create Wiki page$/ do
fill_in "Title", :with => 'Test title'
fill_in "Content", :with => '[link test](test)'
click_on "Save"
end
Then /^I should see newly created wiki page$/ do
page.should have_content("Test title")
page.should have_content("link test")
click_link "link test"
page.should have_content("Editing page")
end
When /^I visit new project page$/ do
visit new_project_path
end
When /^fill project form with valid data$/ do
fill_in 'project_name', :with => 'NewProject'
fill_in 'project_code', :with => 'NPR'
fill_in 'project_path', :with => 'newproject'
click_button "Create project"
end
Then /^I should see project page$/ do
current_path.should == project_path(Project.last)
page.should have_content('NewProject')
end
Then /^I should see empty project instuctions$/ do
page.should have_content("git init")
page.should have_content("git remote")
page.should have_content(Project.last.url_to_repo)
end
Given /^I own project "(.*?)"$/ do |arg1|
@project = Factory :project, :name => arg1
@project.add_access(@user, :admin)
end
Given /^I visit project "(.*?)" wall page$/ do |arg1|
project = Project.find_by_name(arg1)
visit wall_project_path(project)
end
Then /^I should see project wall note "(.*?)"$/ do |arg1|
page.should have_content arg1
end
Given /^project "(.*?)" has comment "(.*?)"$/ do |arg1, arg2|
project = Project.find_by_name(arg1)
project.notes.create(:note => arg1, :author => project.users.first)
end
Given /^I write new comment "(.*?)"$/ do |arg1|
fill_in "note_note", :with => arg1
click_button "Add Comment"
end
Given /^I visit project "(.*?)" page$/ do |arg1|
project = Project.find_by_name(arg1)
visit project_path(project)
end
Given /^I visit project "(.*?)" network page$/ do |arg1|
project = Project.find_by_name(arg1)
# Stub out find_all to speed this up (10 commits vs. 650)
commits = Grit::Commit.find_all(project.repo, nil, {max_count: 10})
Grit::Commit.stub(:find_all).and_return(commits)
visit graph_project_path(project)
end
Given /^page should have network graph$/ do
page.should have_content "Project Network Graph"
within ".graph" do
page.should have_content "master"
page.should have_content "scss_refactor..."
end
end
Given /^I leave a comment like "(.*?)"$/ do |arg1|
fill_in "note_note", :with => arg1
click_button "Add Comment"
end
Then /^I should see comment "(.*?)"$/ do |arg1|
page.should have_content(arg1)
end
Given /^I visit project "(.*?)" issues page$/ do |arg1|
visit project_issues_path(Project.find_by_name(arg1))
end
Given /^I visit issue page "(.*?)"$/ do |arg1|
issue = Issue.find_by_title(arg1)
visit project_issue_path(issue.project, issue)
end
Given /^I visit project "(.*?)" merge requests page$/ do |arg1|
visit project_merge_requests_path(Project.find_by_name(arg1))
end
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 visit project "(.*?)" milestones page$/ do |arg1|
@project = Project.find_by_name(arg1)
visit project_milestones_path(@project)
end
Given /^I visit project commits page$/ do
visit project_commits_path(@project)
end
Given /^I visit compare refs page$/ do
visit compare_project_commits_path(@project)
end
Given /^I visit project branches page$/ do
visit branches_project_repository_path(@project)
end
Given /^I visit project commit page$/ do
visit project_commit_path(@project, ValidCommit::ID)
end
Given /^I visit project tags page$/ do
visit tags_project_repository_path(@project)
end
Given /^I click on commit link$/ do
visit project_commit_path(@project, ValidCommit::ID)
end
Given /^I visit project source page$/ do
visit tree_project_ref_path(@project, @project.root_ref)
end
Given /^I visit project source page for "(.*?)"$/ do |arg1|
visit tree_project_ref_path(@project, arg1)
end
Given /^I visit blob file from repo$/ do
visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH)
end
Given /^I visit project "(.*?)" team page$/ do |arg1|
visit team_project_path(Project.find_by_name(arg1))
end
Given /^I visit project wiki page$/ do
visit project_wiki_path(@project, :index)
end
Given /^I visit profile page$/ do
visit profile_path
end
Given /^I visit profile token page$/ do
visit profile_token_path
end
Given /^I visit profile password page$/ do
visit profile_password_path
end
Given /^I visit dashboard page$/ do
visit dashboard_path
end
Given /^I visit dashboard issues page$/ do
visit dashboard_issues_path
end
Given /^I visit dashboard merge requests page$/ do
visit dashboard_merge_requests_path
end
class Dashboard < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
Then 'I should see "New Project" link' do
page.should have_link "New Project"
end
Then 'I should see "Shop" project link' do
page.should have_link "Shop"
end
Then 'I should see project "Shop" activity feed' do
project = Project.find_by_name("Shop")
page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}"
end
Then 'I should see last push widget' do
page.should have_content "Your pushed to branch new_design"
page.should have_link "Create Merge Request"
end
And 'I click "Create Merge Request" link' do
click_link "Create Merge Request"
end
Then 'I see prefilled new Merge Request page' do
current_path.should == new_project_merge_request_path(@project)
find("#merge_request_source_branch").value.should == "new_design"
find("#merge_request_target_branch").value.should == "master"
find("#merge_request_title").value.should == "New Design"
end
Given 'user with name "John Doe" joined project "Shop"' do
user = Factory.create(:user, {name: "John Doe"})
project = Project.find_by_name "Shop"
Event.create(
project: project,
author_id: user.id,
action: Event::Joined
)
end
Then 'I should see "John Doe joined project Shop" event' do
page.should have_content "John Doe joined project Shop"
end
And 'user with name "John Doe" left project "Shop"' do
user = User.find_by_name "John Doe"
project = Project.find_by_name "Shop"
Event.create(
project: project,
author_id: user.id,
action: Event::Left
)
end
Then 'I should see "John Doe left project Shop" event' do
page.should have_content "John Doe left project Shop"
end
And 'I own project "Shop"' do
@project = Factory :project, :name => 'Shop'
@project.add_access(@user, :admin)
end
And 'project "Shop" has push event' do
@project = Project.find_by_name("Shop")
data = {
:before => "0000000000000000000000000000000000000000",
:after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
:ref => "refs/heads/new_design",
:user_id => @user.id,
:user_name => @user.name,
:repository => {
:name => @project.name,
:url => "localhost/rubinius",
:description => "",
:homepage => "localhost/rubinius",
:private => true
}
}
@event = Event.create(
:project => @project,
:action => Event::Pushed,
:data => data,
:author_id => @user.id
)
end
end
class DashboardIssues < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
Then 'I should see issues assigned to me' do
issues = @user.issues
issues.each do |issue|
page.should have_content(issue.title[0..10])
page.should have_content(issue.project.name)
end
end
And 'I have assigned issues' do
project = Factory :project
project.add_access(@user, :read, :write)
2.times { Factory :issue, :author => @user, :assignee => @user, :project => project }
end
end
class DashboardMergeRequests < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
Then 'I should see my merge requests' do
merge_requests = @user.merge_requests
merge_requests.each do |mr|
page.should have_content(mr.title[0..10])
page.should have_content(mr.project.name)
end
end
And 'I have authored merge requests' do
project1 = Factory :project
project2 = Factory :project
project1.add_access(@user, :read, :write)
project2.add_access(@user, :read, :write)
merge_request1 = Factory :merge_request, :author => @user, :project => project1
merge_request2 = Factory :merge_request, :author => @user, :project => project2
end
end
class DashboardSearch < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
Given 'I search for "Sho"' do
fill_in "dashboard_search", :with => "Sho"
click_button "Search"
end
Then 'I should see "Shop" project link' do
page.should have_link "Shop"
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
end
class Profile < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
Then 'I should see my profile info' do
page.should have_content "Profile"
page.should have_content @user.name
page.should have_content @user.email
end
Then 'I change my contact info' do
fill_in "user_skype", :with => "testskype"
fill_in "user_linkedin", :with => "testlinkedin"
fill_in "user_twitter", :with => "testtwitter"
click_button "Save"
@user.reload
end
And 'I should see new contact info' do
@user.skype.should == 'testskype'
@user.linkedin.should == 'testlinkedin'
@user.twitter.should == 'testtwitter'
end
Then 'I change my password' do
fill_in "user_password", :with => "222333"
fill_in "user_password_confirmation", :with => "222333"
click_button "Save"
end
And 'I should be redirected to sign in page' do
current_path.should == new_user_session_path
end
Then 'I reset my token' do
@old_token = @user.private_token
click_button "Reset"
end
And 'I should see new token' do
find("#token").value.should_not == @old_token
find("#token").value.should == @user.reload.private_token
end
end
class ProfileSshKeys < Spinach::FeatureSteps
include SharedAuthentication
Then 'I should see my ssh keys' do
@user.keys.each do |key|
page.should have_content(key.title)
end
end
Given 'I click link "Add new"' do
click_link "Add new"
end
And 'I submit new ssh key "Laptop"' do
fill_in "key_title", :with => "Laptop"
fill_in "key_key", :with => "ssh-rsa publickey234="
click_button "Save"
end
Then 'I should see new ssh key "Laptop"' do
key = Key.find_by_title("Laptop")
page.should have_content(key.title)
page.should have_content(key.key)
current_path.should == key_path(key)
end
Given 'I click link "Work"' do
click_link "Work"
end
And 'I click link "Remove"' do
click_link "Remove"
end
Then 'I visit profile keys page' do
visit keys_path
end
And 'I should not see "Work" ssh key' do
within "#keys-table" do
page.should_not have_content "Work"
end
end
And 'I have ssh key "ssh-rsa Work"' do
Factory :key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work"
end
end
class CreateProject < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
And 'fill project form with valid data' do
fill_in 'project_name', :with => 'NewProject'
fill_in 'project_code', :with => 'NPR'
fill_in 'project_path', :with => 'newproject'
click_button "Create project"
end
Then 'I should see project page' do
current_path.should == project_path(Project.last)
page.should have_content "NewProject"
end
And 'I should see empty project instuctions' do
page.should have_content "git init"
page.should have_content "git remote"
page.should have_content Project.last.url_to_repo
end
end
class Projects < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
end
class ProjectBrowseBranches < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
Then 'I should see "Shop" recent branches list' do
page.should have_content "Branches"
page.should have_content "master"
end
Given 'I click link "All"' do
click_link "All"
end
Then 'I should see "Shop" all branches list' do
page.should have_content "Branches"
page.should have_content "master"
end
Given 'I click link "Protected"' do
click_link "Protected"
end
Then 'I should see "Shop" protected branches list' do
within "table" do
page.should have_content "stable"
page.should_not have_content "master"
end
end
And 'project "Shop" has protected branches' do
project = Project.find_by_name("Shop")
project.protected_branches.create(:name => "stable")
end
end
class ProjectBrowseCommits < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
Then 'I see project commits' do
current_path.should == project_commits_path(@project)
commit = @project.commit
page.should have_content(@project.name)
page.should have_content(commit.message)
page.should have_content(commit.id.to_s[0..5])
end
Given 'I click atom feed link' do
click_link "Feed"
end
Then 'I see commits atom feed' do
commit = CommitDecorator.decorate(@project.commit)
page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "Recent commits to #{@project.name}")
page.body.should have_selector("author email", :text => commit.author_email)
page.body.should have_selector("entry summary", :text => commit.description)
end
Given 'I click on commit link' do
visit project_commit_path(@project, ValidCommit::ID)
end
Then 'I see commit info' do
page.should have_content ValidCommit::MESSAGE
page.should have_content "Showing 1 changed file"
end
And 'I fill compare fields with refs' do
fill_in "from", :with => "master"
fill_in "to", :with => "stable"
click_button "Compare"
end
And 'I see compared refs' do
page.should have_content "Commits (27)"
page.should have_content "Compare View"
page.should have_content "Showing 73 changed files"
end
end
class ProjectBrowseFiles < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
Then 'I should see files from repository' do
page.should have_content "app"
page.should have_content "History"
page.should have_content "Gemfile"
end
Then 'I should see files from repository for "8470d70"' do
current_path.should == tree_project_ref_path(@project, "8470d70")
page.should have_content "app"
page.should have_content "History"
page.should have_content "Gemfile"
end
Given 'I click on "Gemfile" file in repo' do
click_link "Gemfile"
end
Then 'I should see it content' do
page.should have_content "rubygems.org"
end
And 'I click link "raw"' do
click_link "raw"
end
Then 'I should see raw file content' do
page.source.should == ValidCommit::BLOB_FILE
end
end
class ProjectBrowseGitRepo < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
Given 'I click on "Gemfile" file in repo' do
click_link "Gemfile"
end
And 'I click blame button' do
click_link "blame"
end
Then 'I should see git file blame' do
page.should have_content "rubygems.org"
page.should have_content "Dmitriy Zaporozhets"
page.should have_content "bc3735004cb Moving to rails 3.2"
end
end
class ProjectBrowseTags < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
Then 'I should see "Shop" all tags list' do
page.should have_content "Tags"
page.should have_content "v1.2.1"
end
end
class ProjectCommentCommit < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedNote
include SharedPaths
end
class ProjectIssues < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedNote
include SharedPaths
Given 'I should see "Release 0.4" in issues' do
page.should have_content "Release 0.4"
end
And 'I should not see "Release 0.3" in issues' do
page.should_not have_content "Release 0.3"
end
Given 'I click link "Closed"' do
click_link "Closed"
end
Then 'I should see "Release 0.3" in issues' do
page.should have_content "Release 0.3"
end
And 'I should not see "Release 0.4" in issues' do
page.should_not have_content "Release 0.4"
end
Given 'I click link "All"' do
click_link "All"
end
Given 'I click link "Release 0.4"' do
click_link "Release 0.4"
end
Then 'I should see issue "Release 0.4"' do
page.should have_content "Release 0.4"
end
Given 'I click link "New Issue"' do
click_link "New Issue"
end
And 'I submit new issue "500 error on profile"' do
fill_in "issue_title", :with => "500 error on profile"
click_button "Submit new issue"
end
Given 'I click link "500 error on profile"' do
click_link "500 error on profile"
end
Then 'I should see issue "500 error on profile"' do
issue = Issue.find_by_title("500 error on profile")
page.should have_content issue.title
page.should have_content issue.author_name
page.should have_content issue.project.name
end
Given 'I fill in issue search with "Release"' do
fill_in 'issue_search', with: "Release"
end
Given 'I fill in issue search with "Bug"' do
fill_in 'issue_search', with: "Bug"
end
And 'I fill in issue search with "0.3"' do
fill_in 'issue_search', with: "0.3"
end
And 'I fill in issue search with "Something"' do
fill_in 'issue_search', with: "Something"
end
And 'I fill in issue search with ""' do
page.execute_script("$('.issue_search').val('').keyup();");
fill_in 'issue_search', with: ""
end
Given 'project "Shop" has milestone "v2.2"' do
project = Project.find_by_name("Shop")
milestone = Factory :milestone, :title => "v2.2", :project => project
3.times { Factory :issue, :project => project, :milestone => milestone }
end
And 'project "Shop" has milestone "v3.0"' do
project = Project.find_by_name("Shop")
milestone = Factory :milestone, :title => "v3.0", :project => project
3.times { Factory :issue, :project => project, :milestone => milestone }
end
When 'I select milestone "v3.0"' do
select "v3.0", from: "milestone_id"
end
Then 'I should see selected milestone with title "v3.0"' do
issues_milestone_selector = "#issue_milestone_id_chzn/a"
wait_until { page.has_content?("Details") }
page.find(issues_milestone_selector).should have_content("v3.0")
end
When 'I select first assignee from "Shop" project' do
project = Project.find_by_name "Shop"
first_assignee = project.users.first
select first_assignee.name, from: "assignee_id"
end
Then 'I should see first assignee from "Shop" as selected assignee' do
issues_assignee_selector = "#issue_assignee_id_chzn/a"
wait_until { page.has_content?("Details") }
project = Project.find_by_name "Shop"
assignee_name = project.users.first.name
page.find(issues_assignee_selector).should have_content(assignee_name)
end
And 'project "Shop" have "Release 0.4" open issue' do
project = Project.find_by_name("Shop")
Factory.create(:issue,
:title => "Release 0.4",
:project => project,
:author => project.users.first)
end
And 'project "Shop" have "Release 0.3" closed issue' do
project = Project.find_by_name("Shop")
Factory.create(:issue,
:title => "Release 0.3",
:project => project,
:author => project.users.first,
:closed => true)
end
end
class ProjectLabels < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
Then 'I should see label "bug"' do
within ".labels-table" do
page.should have_content "bug"
end
end
And 'I should see label "feature"' do
within ".labels-table" do
page.should have_content "feature"
end
end
And 'project "Shop" have issues tags: "bug", "feature"' do
project = Project.find_by_name("Shop")
['bug', 'feature'].each do |label|
Factory :issue, project: project, label_list: label
end
end
end
class ProjectMergeRequests < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedNote
include SharedPaths
Then 'I should see "Bug NS-04" in merge requests' do
page.should have_content "Bug NS-04"
end
And 'I should not see "Feature NS-03" in merge requests' do
page.should_not have_content "Feature NS-03"
end
Given 'I click link "Closed"' do
click_link "Closed"
end
Then 'I should see "Feature NS-03" in merge requests' do
page.should have_content "Feature NS-03"
end
And 'I should not see "Bug NS-04" in merge requests' do
page.should_not have_content "Bug NS-04"
end
Given 'I click link "All"' do
click_link "All"
end
Given 'I click link "Bug NS-04"' do
click_link "Bug NS-04"
end
Then 'I should see merge request "Bug NS-04"' do
page.should have_content "Bug NS-04"
end
And 'I click link "Close"' do
click_link "Close"
end
Then 'I should see closed merge request "Bug NS-04"' do
mr = MergeRequest.find_by_title("Bug NS-04")
mr.closed.should be_true
page.should have_content "Closed by"
end
Given 'I click link "New Merge Request"' do
click_link "New Merge Request"
end
And 'I submit new merge request "Wiki Feature"' do
fill_in "merge_request_title", :with => "Wiki Feature"
select "master", :from => "merge_request_source_branch"
select "stable", :from => "merge_request_target_branch"
click_button "Save"
end
Then 'I should see merge request "Wiki Feature"' do
page.should have_content "Wiki Feature"
end
And 'project "Shop" have "Bug NS-04" open merge request' do
project = Project.find_by_name("Shop")
Factory.create(:merge_request,
:title => "Bug NS-04",
:project => project,
:author => project.users.first)
end
And 'project "Shop" have "Feature NS-03" closed merge request' do
project = Project.find_by_name("Shop")
Factory.create(:merge_request,
:title => "Feature NS-03",
:project => project,
:author => project.users.first,
:closed => true)
end
end
class ProjectMilestones < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
Then 'I should see milestone "v2.2"' do
milestone = @project.milestones.find_by_title("v2.2")
page.should have_content(milestone.title[0..10])
page.should have_content(milestone.expires_at)
page.should have_content("Browse Issues")
end
Given 'I click link "v2.2"' do
click_link "v2.2"
end
Given 'I click link "New Milestone"' do
click_link "New Milestone"
end
And 'I submit new milestone "v2.3"' do
fill_in "milestone_title", :with => "v2.3"
click_button "Create milestone"
end
Then 'I should see milestone "v2.3"' do
milestone = @project.milestones.find_by_title("v2.3")
page.should have_content(milestone.title[0..10])
page.should have_content(milestone.expires_at)
page.should have_content("Browse Issues")
end
And 'project "Shop" has milestone "v2.2"' do
project = Project.find_by_name("Shop")
milestone = Factory :milestone, :title => "v2.2", :project => project
3.times { Factory :issue, :project => project, :milestone => milestone }
end
end
class ProjectNetworkGraph < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
Then 'page should have network graph' do
page.should have_content "Project Network Graph"
within ".graph" do
page.should have_content "master"
page.should have_content "scss_refactor..."
end
end
And 'I visit project "Shop" network page' do
project = Project.find_by_name("Shop")
# Stub out find_all to speed this up (10 commits vs. 650)
commits = Grit::Commit.find_all(project.repo, nil, {max_count: 10})
Grit::Commit.stub(:find_all).and_return(commits)
visit graph_project_path(project)
end
end
class ProjectTeamManagement < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
Then 'I should be able to see myself in team' do
page.should have_content(@user.name)
page.should have_content(@user.email)
end
And 'I should see "Sam" in team list' do
user = User.find_by_name("Sam")
page.should have_content(user.name)
page.should have_content(user.email)
end
Given 'I click link "New Team Member"' do
click_link "New Team Member"
end
And 'I select "Mike" as "Reporter"' do
user = User.find_by_name("Mike")
within "#new_team_member" do
select user.name, :from => "user_ids"
select "Reporter", :from => "project_access"
end
click_button "Save"
end
Then 'I should see "Mike" in team list as "Reporter"' do
user = User.find_by_name("Mike")
role_id = find(".user_#{user.id} #team_member_project_access").value
role_id.should == UsersProject.access_roles["Reporter"].to_s
end
Given 'I should see "Sam" in team list as "Developer"' do
user = User.find_by_name("Sam")
role_id = find(".user_#{user.id} #team_member_project_access").value
role_id.should == UsersProject.access_roles["Developer"].to_s
end
And 'I change "Sam" role to "Reporter"' do
user = User.find_by_name("Sam")
within ".user_#{user.id}" do
select "Reporter", :from => "team_member_project_access"
end
end
And 'I should see "Sam" in team list as "Reporter"' do
user = User.find_by_name("Sam")
role_id = find(".user_#{user.id} #team_member_project_access").value
role_id.should == UsersProject.access_roles["Reporter"].to_s
end
Given 'I click link "Sam"' do
click_link "Sam"
end
Then 'I should see "Sam" team profile' do
user = User.find_by_name("Sam")
page.should have_content(user.name)
page.should have_content(user.email)
page.should have_content("To team list")
end
And 'I click link "Remove from team"' do
click_link "Remove from team"
end
And 'I should not see "Sam" in team list' do
user = User.find_by_name("Sam")
page.should_not have_content(user.name)
page.should_not have_content(user.email)
end
And 'gitlab user "Mike"' do
Factory :user, :name => "Mike"
end
And 'gitlab user "Sam"' do
Factory :user, :name => "Sam"
end
And '"Sam" is "Shop" developer' do
user = User.find_by_name("Sam")
project = Project.find_by_name("Shop")
project.add_access(user, :write)
end
end
class ProjectWall < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedNote
include SharedPaths
end
class ProjectWiki < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedNote
include SharedPaths
Given 'I create Wiki page' do
fill_in "Title", :with => 'Test title'
fill_in "Content", :with => '[link test](test)'
click_on "Save"
end
Then 'I should see newly created wiki page' do
page.should have_content "Test title"
page.should have_content "link test"
click_link "link test"
page.should have_content "Editing page"
end
end
require Rails.root.join('spec', 'support', 'login_helpers')
module SharedAuthentication
include Spinach::DSL
include LoginHelpers
Given 'I sign in as a user' do
login_as :user
end
end
module SharedNote
include Spinach::DSL
Given 'I leave a comment like "XML attached"' do
fill_in "note_note", :with => "XML attached"
click_button "Add Comment"
end
Then 'I should see comment "XML attached"' do
page.should have_content "XML attached"
end
Given 'I write new comment "my special test message"' do
fill_in "note_note", :with => "my special test message"
click_button "Add Comment"
end
Then 'I should see project wall note "my special test message"' do
page.should have_content "my special test message"
end
end
module SharedPaths
include Spinach::DSL
And 'I visit dashboard search page' do
visit search_path
end
And 'I visit dashboard merge requests page' do
visit dashboard_merge_requests_path
end
And 'I visit dashboard issues page' do
visit dashboard_issues_path
end
When 'I visit dashboard page' do
visit dashboard_path
end
Given 'I visit profile page' do
visit profile_path
end
Given 'I visit profile password page' do
visit profile_password_path
end
Given 'I visit profile token page' do
visit profile_token_path
end
When 'I visit new project page' do
visit new_project_path
end
And 'I visit project "Shop" page' do
project = Project.find_by_name("Shop")
visit project_path(project)
end
Given 'I visit project branches page' do
visit branches_project_repository_path(@project)
end
Given 'I visit compare refs page' do
visit compare_project_commits_path(@project)
end
Given 'I visit project commits page' do
visit project_commits_path(@project)
end
Given 'I visit project source page' do
visit tree_project_ref_path(@project, @project.root_ref)
end
Given 'I visit blob file from repo' do
visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH)
end
Given 'I visit project source page for "8470d70"' do
visit tree_project_ref_path(@project, "8470d70")
end
Given 'I visit project tags page' do
visit tags_project_repository_path(@project)
end
Given 'I visit project commit page' do
visit project_commit_path(@project, ValidCommit::ID)
end
And 'I visit project "Shop" issues page' do
visit project_issues_path(Project.find_by_name("Shop"))
end
Given 'I visit issue page "Release 0.4"' do
issue = Issue.find_by_title("Release 0.4")
visit project_issue_path(issue.project, issue)
end
Given 'I visit project "Shop" labels page' do
visit project_labels_path(Project.find_by_name("Shop"))
end
Given 'I visit merge request page "Bug NS-04"' do
mr = MergeRequest.find_by_title("Bug NS-04")
visit project_merge_request_path(mr.project, mr)
end
And 'I visit project "Shop" merge requests page' do
visit project_merge_requests_path(Project.find_by_name("Shop"))
end
Given 'I visit project "Shop" milestones page' do
@project = Project.find_by_name("Shop")
visit project_milestones_path(@project)
end
Then 'I visit project "Shop" team page' do
visit team_project_path(Project.find_by_name("Shop"))
end
Then 'I visit project "Shop" wall page' do
project = Project.find_by_name("Shop")
visit wall_project_path(project)
end
Given 'I visit project wiki page' do
visit project_wiki_path(@project, :index)
end
end
module SharedProject
include Spinach::DSL
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
end
unless ENV['CI']
require 'simplecov'
SimpleCov.start 'rails'
end
require 'cucumber/rails'
require 'webmock/cucumber'
WebMock.allow_net_connect!
require Rails.root.join 'spec/support/gitolite_stub'
require Rails.root.join 'spec/support/stubbed_repository'
require Rails.root.join 'spec/support/login_helpers'
require Rails.root.join 'spec/support/valid_commit'
ENV['RAILS_ENV'] = 'test'
require './config/environment'
Capybara.default_selector = :css
Capybara.javascript_driver = :webkit
require 'rspec'
require 'database_cleaner'
require 'spinach/capybara'
# By default, any exception happening in your Rails application will bubble up
# to Cucumber so that your scenario will fail. This is a different from how
# your application behaves in the production environment, where an error page will
# be rendered instead.
#
# Sometimes we want to override this default behaviour and allow Rails to rescue
# exceptions and display an error page (just like when the app is running in production).
# Typical scenarios where you want to do this is when you test your error pages.
# There are two ways to allow Rails to rescue exceptions:
#
# 1) Tag your scenario (or feature) with @allow-rescue
#
# 2) Set the value below to true. Beware that doing this globally is not
# recommended as it will mask a lot of errors for you!
#
ActionController::Base.allow_rescue = false
# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
%w(gitolite_stub stubbed_repository valid_commit).each do |f|
require Rails.root.join('spec', 'support', f)
end
Cucumber::Rails::Database.javascript_strategy = :truncation
Dir["#{Rails.root}/features/steps/shared/*.rb"].each {|file| require file}
require 'headless'
include GitoliteStub
headless = Headless.new
headless.start
WebMock.allow_net_connect!
Capybara.javascript_driver = :webkit
require 'cucumber/rspec/doubles'
DatabaseCleaner.strategy = :truncation
Spinach.hooks.before_scenario { DatabaseCleaner.start }
Spinach.hooks.after_scenario { DatabaseCleaner.clean }
include GitoliteStub
Spinach.hooks.before_run do
RSpec::Mocks::setup self
Before do
stub_gitolite!
end
World(FactoryGirl::Syntax::Methods)
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
begin
require 'cucumber/rake/task'
namespace :cucumber do
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
t.fork = true # You may get faster startup if you set this to false
t.profile = 'default'
end
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
t.profile = 'wip'
end
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
t.binary = vendored_cucumber_bin
t.fork = true # You may get faster startup if you set this to false
t.profile = 'rerun'
end
desc 'Run all features'
task :all => [:ok, :wip]
task :statsetup do
require 'rails/code_statistics'
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
end
end
desc 'Alias for cucumber:ok'
task :cucumber => 'cucumber:ok'
task :default => :cucumber
task :features => :cucumber do
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
end
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
task 'db:test:prepare' do
end
task :stats => 'cucumber:statsetup'
rescue LoadError
desc 'cucumber rake task not available (cucumber not installed)'
task :cucumber do
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
end
end
end
namespace :gitlab do
desc "GITLAB | Run both cucumber & rspec"
task :test => ['cucumber', 'spec']
desc "GITLAB | Run both spinach and rspec"
task :test => ['spinach', 'spec']
end
task :travis do
["cucumber", "rspec spec"].each do |cmd|
["spinach", "rspec spec"].each do |cmd|
puts "Starting to run #{cmd}..."
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
raise "#{cmd} failed!" unless $?.exitstatus == 0
......
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
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