A bit of spinach tests

This commit is contained in:
Dmitriy Zaporozhets 2013-01-09 08:14:05 +03:00
parent ab344f31b6
commit 2f6603e581
11 changed files with 116 additions and 95 deletions

View file

View file

@ -0,0 +1,13 @@
Feature: Admin Projects
Background:
Given I sign in as an admin
And there are projects in system
Scenario: Projects list
When I visit admin projects page
Then I should see all projects
Scenario: Projects show
When I visit admin projects page
And I click on first project
Then I should see project details

View file

View file

@ -1,14 +1,23 @@
Feature: Projects Feature: Projects
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 push event
And I visit project "Shop" page And I visit project "Shop" page
# @wip Scenario: I should see project activity
# Scenario: I should see project activity When I visit project "Shop" page
Then I should see project "Shop" activity feed
# @wip Scenario: I visit edit project
# Scenario: I edit project When I visit edit project "Shop" page
Then I should see project settings
Scenario: I edit project
When I visit edit project "Shop" page
And change project settings
And I save project
Then I should see project with new settings
# @wip # @wip
# Scenario: I visit attachments # Scenario: I visit attachments

View file

@ -0,0 +1,24 @@
class AdminProjects < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedAdmin
And 'I should see all projects' do
Project.all.each do |p|
page.should have_content p.name_with_namespace
end
end
And 'I click on first project' do
click_link Project.first.name_with_namespace
end
Then 'I should see project details' do
project = Project.first
current_path.should == admin_project_path(project)
page.should have_content(project.name_with_namespace)
page.should have_content(project.creator.name)
page.should have_content('Add new team member')
end
end

View file

@ -1,6 +1,7 @@
class Dashboard < Spinach::FeatureSteps class Dashboard < Spinach::FeatureSteps
include SharedAuthentication include SharedAuthentication
include SharedPaths include SharedPaths
include SharedProject
Then 'I should see "New Project" link' do Then 'I should see "New Project" link' do
page.should have_link "New Project" page.should have_link "New Project"
@ -10,11 +11,6 @@ class Dashboard < Spinach::FeatureSteps
page.should have_link "Shop" page.should have_link "Shop"
end 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 Then 'I should see last push widget' do
page.should have_content "You pushed to new_design" page.should have_content "You pushed to new_design"
page.should have_link "Create Merge Request" page.should have_link "Create Merge Request"
@ -59,11 +55,6 @@ class Dashboard < Spinach::FeatureSteps
page.should have_content "John Doe left project at Shop" page.should have_content "John Doe left project at Shop"
end end
And 'I own project "Shop"' do
@project = create :project, name: 'Shop'
@project.team << [@user, :master]
end
And 'I have group with projects' do And 'I have group with projects' do
@group = create(:group) @group = create(:group)
@project = create(:project, group: @group) @project = create(:project, group: @group)
@ -72,32 +63,6 @@ class Dashboard < Spinach::FeatureSteps
@project.team << [current_user, :master] @project.team << [current_user, :master]
end 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
Then 'I should see groups list' do Then 'I should see groups list' do
Group.all.each do |group| Group.all.each do |group|
page.should have_link group.name page.should have_link group.name
@ -112,5 +77,4 @@ class Dashboard < Spinach::FeatureSteps
Then 'I should see 1 project at group list' do Then 'I should see 1 project at group list' do
page.find('span.last_activity/span').should have_content('1') page.find('span.last_activity/span').should have_content('1')
end end
end end

View file

@ -2,4 +2,17 @@ class Projects < Spinach::FeatureSteps
include SharedAuthentication include SharedAuthentication
include SharedProject include SharedProject
include SharedPaths include SharedPaths
And 'change project settings' do
fill_in 'project_name', with: 'NewName'
uncheck 'project_issues_enabled'
end
And 'I save project' do
click_button 'Save'
end
Then 'I should see project with new settings' do
find_field('project_name').value.should == 'NewName'
end
end end

View file

@ -0,0 +1,8 @@
module SharedAdmin
include Spinach::DSL
And 'there are projects in system' do
2.times { create(:project) }
end
end

View file

@ -165,6 +165,11 @@ module SharedPaths
visit project_path(project) visit project_path(project)
end end
When 'I visit edit project "Shop" page' do
project = Project.find_by_name("Shop")
visit edit_project_path(project)
end
Given 'I visit project branches page' do Given 'I visit project branches page' do
visit branches_project_repository_path(@project) visit branches_project_repository_path(@project)
end end

View file

@ -13,6 +13,44 @@ module SharedProject
@project.team << [@user, :master] @project.team << [@user, :master]
end 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
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 project settings' do
current_path.should == edit_project_path(@project)
page.should have_content("Project name is")
page.should have_content("Advanced settings:")
page.should have_content("Features:")
end
def current_project def current_project
@project ||= Project.first @project ||= Project.first
end end

View file

@ -3,59 +3,6 @@ require 'spec_helper'
describe "Projects" do describe "Projects" do
before { login_as :user } before { login_as :user }
describe "GET /projects/show" do
before do
@project = create(:project, namespace: @user.namespace)
@project.team << [@user, :reporter]
visit project_path(@project)
end
it "should be correct path" do
current_path.should == project_path(@project)
end
end
describe "GET /projects/:id/edit" do
before do
@project = create(:project)
@project.team << [@user, :master]
visit edit_project_path(@project)
end
it "should be correct path" do
current_path.should == edit_project_path(@project)
end
it "should have labels for new project" do
page.should have_content("Project name is")
page.should have_content("Advanced settings:")
page.should have_content("Features:")
end
end
describe "PUT /projects/:id" do
before do
@project = create(:project, namespace: @user.namespace)
@project.team << [@user, :master]
visit edit_project_path(@project)
fill_in 'project_name', with: 'Awesome'
click_button "Save"
@project = @project.reload
end
it "should be correct path" do
current_path.should == edit_project_path(@project)
end
it "should show project" do
page.should have_content("Awesome")
end
end
describe "DELETE /projects/:id" do describe "DELETE /projects/:id" do
before do before do
@project = create(:project, namespace: @user.namespace) @project = create(:project, namespace: @user.namespace)