Commit bb75052a authored by Nihad Abbasov's avatar Nihad Abbasov

get rid of cucumber step definitions

parent 9f25657a
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
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