Commit 79eb5ab3 authored by Nihad Abbasov's avatar Nihad Abbasov

refactor feature steps

parent ef4e9c24
......@@ -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
......
@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
......
class Dashboard < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
Then 'I should see "New Project" link' do
page.should have_link "New Project"
end
......@@ -38,10 +41,6 @@ class Dashboard < Spinach::FeatureSteps
)
end
When 'I visit dashboard page' do
visit dashboard_path
end
Then 'I should see "John Doe joined project Shop" event' do
page.should have_content "John Doe joined project Shop"
end
......@@ -60,10 +59,6 @@ class Dashboard < Spinach::FeatureSteps
page.should have_content "John Doe left project Shop"
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => 'Shop'
@project.add_access(@user, :admin)
......
class DashboardIssues < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
Then 'I should see issues assigned to me' do
issues = @user.issues
issues.each do |issue|
......@@ -7,26 +10,10 @@ class DashboardIssues < Spinach::FeatureSteps
end
end
Given 'I sign in as a user' do
login_as :user
end
And '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
And 'I visit dashboard issues page' do
visit dashboard_issues_path
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|
......@@ -7,10 +10,6 @@ class DashboardMergeRequests < Spinach::FeatureSteps
end
end
Given 'I sign in as a user' do
login_as :user
end
And 'I have authored merge requests' do
project1 = Factory :project
project2 = Factory :project
......@@ -18,16 +17,7 @@ class DashboardMergeRequests < Spinach::FeatureSteps
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
And 'I visit dashboard merge requests page' do
visit dashboard_merge_requests_path
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"
......@@ -8,16 +11,8 @@ class DashboardSearch < Spinach::FeatureSteps
page.should have_link "Shop"
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
And 'I visit dashboard search page' do
visit search_path
end
end
class Profile < Spinach::FeatureSteps
Given 'I visit profile page' do
visit profile_path
end
include SharedAuthentication
include SharedPaths
Then 'I should see my profile info' do
page.should have_content "Profile"
......@@ -23,10 +22,6 @@ class Profile < Spinach::FeatureSteps
@user.twitter.should == 'testtwitter'
end
Given 'I visit profile password page' do
visit profile_password_path
end
Then 'I change my password' do
fill_in "user_password", :with => "222333"
fill_in "user_password_confirmation", :with => "222333"
......@@ -37,10 +32,6 @@ class Profile < Spinach::FeatureSteps
current_path.should == new_user_session_path
end
Given 'I visit profile token page' do
visit profile_token_path
end
Then 'I reset my token' do
@old_token = @user.private_token
click_button "Reset"
......@@ -50,8 +41,4 @@ class Profile < Spinach::FeatureSteps
find("#token").value.should_not == @old_token
find("#token").value.should == @user.reload.private_token
end
Given 'I sign in as a user' do
login_as :user
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)
......@@ -40,10 +42,6 @@ class ProfileSshKeys < Spinach::FeatureSteps
end
end
Given 'I sign in as a user' do
login_as :user
end
And 'I have ssh key "ssh-rsa Work"' do
Factory :key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work"
end
......
class CreateProject < Spinach::FeatureSteps
Given 'I signin as a user' do
login_as :user
end
When 'I visit new project page' do
visit new_project_path
end
include SharedAuthentication
include SharedPaths
And 'fill project form with valid data' do
fill_in 'project_name', :with => 'NewProject'
......@@ -16,7 +11,7 @@ class CreateProject < Spinach::FeatureSteps
Then 'I should see project page' do
current_path.should == project_path(Project.last)
page.should have_content('NewProject')
page.should have_content "NewProject"
end
And 'I should see empty project instuctions' do
......
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"
......@@ -24,21 +28,8 @@ class ProjectBrowseBranches < Spinach::FeatureSteps
end
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
And 'project "Shop" has protected branches' do
project = Project.find_by_name("Shop")
project.protected_branches.create(:name => "stable")
end
Given 'I visit project branches page' do
visit branches_project_repository_path(@project)
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)
......@@ -29,10 +33,6 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
page.should have_content "Showing 1 changed file"
end
Given 'I visit compare refs page' do
visit compare_project_commits_path(@project)
end
And 'I fill compare fields with refs' do
fill_in "from", :with => "master"
fill_in "to", :with => "stable"
......@@ -44,17 +44,4 @@ class ProjectBrowseCommits < Spinach::FeatureSteps
page.should have_content "Compare View"
page.should have_content "Showing 73 changed files"
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
Given 'I visit project commits page' do
visit project_commits_path(@project)
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
Given 'I visit project source page for "8470d70"' do
visit tree_project_ref_path(@project, "8470d70")
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"
......@@ -24,10 +24,6 @@ class ProjectBrowseFiles < Spinach::FeatureSteps
page.should have_content "rubygems.org"
end
Given 'I visit blob file from repo' do
visit tree_project_ref_path(@project, ValidCommit::ID, :path => ValidCommit::BLOB_FILE_PATH)
end
And 'I click link "raw"' do
click_link "raw"
end
......@@ -35,17 +31,4 @@ class ProjectBrowseFiles < Spinach::FeatureSteps
Then 'I should see raw file content' do
page.source.should == ValidCommit::BLOB_FILE
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
Given 'I visit project source page' do
visit tree_project_ref_path(@project, @project.root_ref)
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
......@@ -12,17 +16,4 @@ class ProjectBrowseGitRepo < Spinach::FeatureSteps
page.should have_content "Dmitriy Zaporozhets"
page.should have_content "bc3735004cb Moving to rails 3.2"
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
Given 'I visit project source page' do
visit tree_project_ref_path(@project, @project.root_ref)
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
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
Given 'I visit project tags page' do
visit tags_project_repository_path(@project)
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
......@@ -51,20 +56,6 @@ class ProjectIssues < Spinach::FeatureSteps
page.should have_content issue.project.name
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
And '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 fill in issue search with "Release"' do
fill_in 'issue_search', with: "Release"
end
......@@ -90,22 +81,14 @@ class ProjectIssues < Spinach::FeatureSteps
project = Project.find_by_name("Shop")
milestone = Factory :milestone, :title => "v2.2", :project => project
3.times do
issue = Factory :issue, :project => project, :milestone => milestone
end
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 do
issue = Factory :issue, :project => project, :milestone => milestone
end
end
And 'I visit project "Shop" issues page' do
visit project_issues_path(Project.find_by_name("Shop"))
3.times { Factory :issue, :project => project, :milestone => milestone }
end
When 'I select milestone "v3.0"' do
......@@ -132,15 +115,6 @@ class ProjectIssues < Spinach::FeatureSteps
page.find(issues_assignee_selector).should have_content(assignee_name)
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
And 'project "Shop" have "Release 0.4" open issue' do
project = Project.find_by_name("Shop")
Factory.create(:issue,
......
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"
......@@ -11,23 +15,10 @@ class ProjectLabels < Spinach::FeatureSteps
end
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
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
Given 'I visit project "Shop" labels page' do
visit project_labels_path(Project.find_by_name("Shop"))
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
......@@ -56,29 +61,6 @@ class ProjectMergeRequests < Spinach::FeatureSteps
page.should have_content "Wiki Feature"
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 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 sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
And 'project "Shop" have "Bug NS-04" open merge request' do
project = Project.find_by_name("Shop")
Factory.create(:merge_request,
......@@ -95,8 +77,4 @@ class ProjectMergeRequests < Spinach::FeatureSteps
:author => project.users.first,
:closed => true)
end
And 'I visit project "Shop" merge requests page' do
visit project_merge_requests_path(Project.find_by_name("Shop"))
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])
......@@ -26,26 +30,10 @@ class ProjectMilestones < Spinach::FeatureSteps
page.should have_content("Browse Issues")
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
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 do
issue = Factory :issue, :project => project, :milestone => milestone
end
end
Given 'I visit project "Shop" milestones page' do
@project = Project.find_by_name("Shop")
visit project_milestones_path(@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
......@@ -7,15 +10,6 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
end
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
And 'I visit project "Shop" network page' do
project = Project.find_by_name("Shop")
......
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)
......@@ -42,10 +46,6 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end
end
Then 'I visit project "Shop" team page' do
visit team_project_path(Project.find_by_name("Shop"))
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
......@@ -73,15 +73,6 @@ class ProjectTeamManagement < Spinach::FeatureSteps
page.should_not have_content(user.email)
end
Given 'I sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
And 'gitlab user "Mike"' do
Factory :user, :name => "Mike"
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)'
......@@ -12,26 +17,4 @@ class ProjectWiki < Spinach::FeatureSteps
click_link "link test"
page.should have_content "Editing page"
end
And '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 sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
Given 'I visit project wiki page' do
visit project_wiki_path(@project, :index)
end
end
class ProjectCommentCommit < Spinach::FeatureSteps
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 sign in as a user' do
login_as :user
end
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
Given 'I visit project commit page' do
visit project_commit_path(@project, ValidCommit::ID)
end
end