add spinach steps for project issues and source features

This commit is contained in:
Nihad Abbasov 2012-09-10 05:34:01 -07:00
parent 080bd12e16
commit 698500dd78
11 changed files with 345 additions and 26 deletions

View file

@ -1,6 +1,6 @@
Feature: Issues Feature: Project Issues
Background: Background:
Given I signin as a user Given I sign in as a user
And I own project "Shop" And I own project "Shop"
And project "Shop" have "Release 0.4" open issue And project "Shop" have "Release 0.4" open issue
And project "Shop" have "Release 0.3" closed issue And project "Shop" have "Release 0.3" closed issue
@ -79,4 +79,3 @@ Feature: Issues
When I select first assignee from "Shop" project When I select first assignee from "Shop" project
And I click link "New Issue" And I click link "New Issue"
Then I should see first assignee from "Shop" as selected assignee Then I should see first assignee from "Shop" as selected assignee

View file

@ -1,12 +1,9 @@
Feature: Labels Feature: Project Labels
Background: Background:
Given I signin as a user Given I sign in as a user
And I own project "Shop" And I own project "Shop"
And project "Shop" have issues tags: And project "Shop" have issues tags: "bug", "feature"
| name | Given I visit project "Shop" labels page
| bug |
| feature |
Given I visit project "Shop" labels page
Scenario: I should see active milestones Scenario: I should see active milestones
Then I should see label "bug" Then I should see label "bug"

View file

@ -1,9 +1,9 @@
Feature: Milestones Feature: Project Milestones
Background: Background:
Given I signin as a user Given I sign in as a user
And I own project "Shop" And I own project "Shop"
And project "Shop" has milestone "v2.2" 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 Scenario: I should see active milestones
Then I should see milestone "v2.2" Then I should see milestone "v2.2"

View file

@ -1,6 +1,6 @@
Feature: Browse git repo Feature: Project Browse files
Background: Background:
Given I signin as a user Given I sign in as a user
And I own project "Shop" And I own project "Shop"
Given I visit project source page Given I visit project source page
@ -12,12 +12,10 @@ Feature: Browse git repo
Then I should see files from repository for "8470d70" Then I should see files from repository for "8470d70"
Scenario: I browse file content 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 Then I should see it content
Scenario: I browse raw file Scenario: I browse raw file
Given I visit blob file from repo Given I visit blob file from repo
And I click on raw button And I click link "raw"
Then I should see raw file content Then I should see raw file content

View file

@ -1,10 +1,10 @@
Feature: Browse git repo Feature: Project Browse git repo
Background: Background:
Given I signin as a user Given I sign in as a user
And I own project "Shop" And I own project "Shop"
Given I visit project source page Given I visit project source page
Scenario: I blame file Scenario: I blame file
Given I click on file from repo Given I click on "Gemfile" file in repo
And I click blame button And I click blame button
Then I should see git file blame Then I should see git file blame

View file

@ -0,0 +1,51 @@
class ProjectBrowseFiles < Spinach::FeatureSteps
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"
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
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
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

View file

@ -0,0 +1,28 @@
class ProjectBrowseGitRepo < Spinach::FeatureSteps
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
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

View file

@ -0,0 +1,160 @@
class ProjectIssues < Spinach::FeatureSteps
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 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
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 do
issue = Factory :issue, :project => project, :milestone => milestone
end
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"))
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
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,
: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

View file

@ -0,0 +1,33 @@
class ProjectLabels < Spinach::FeatureSteps
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
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

View file

@ -0,0 +1,51 @@
class ProjectMilestones < Spinach::FeatureSteps
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
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)
end
end

View file

@ -3,6 +3,7 @@ require './config/environment'
require 'rspec' require 'rspec'
require 'database_cleaner' require 'database_cleaner'
require 'spinach/capybara'
%w(gitolite_stub login_helpers stubbed_repository valid_commit).each do |f| %w(gitolite_stub login_helpers stubbed_repository valid_commit).each do |f|
require Rails.root.join('spec', 'support', f) require Rails.root.join('spec', 'support', f)
@ -12,6 +13,7 @@ include LoginHelpers
include GitoliteStub include GitoliteStub
WebMock.allow_net_connect! WebMock.allow_net_connect!
Capybara.javascript_driver = :webkit
DatabaseCleaner.strategy = :truncation DatabaseCleaner.strategy = :truncation
Spinach.hooks.before_scenario { DatabaseCleaner.start } Spinach.hooks.before_scenario { DatabaseCleaner.start }