Skip to content

Commit 2f6603e

Browse files
committed
A bit of spinach tests
1 parent ab344f3 commit 2f6603e

File tree

11 files changed

+116
-95
lines changed

11 files changed

+116
-95
lines changed

features/admin/logs.feature

Whitespace-only changes.

features/admin/projects.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Feature: Admin Projects
2+
Background:
3+
Given I sign in as an admin
4+
And there are projects in system
5+
6+
Scenario: Projects list
7+
When I visit admin projects page
8+
Then I should see all projects
9+
10+
Scenario: Projects show
11+
When I visit admin projects page
12+
And I click on first project
13+
Then I should see project details

features/admin/users.feature

Whitespace-only changes.

features/project/project.feature

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
Feature: Projects
22
Background:
3-
Given I signin as a user
3+
Given I sign in as a user
44
And I own project "Shop"
5+
And project "Shop" has push event
56
And I visit project "Shop" page
67

7-
# @wip
8-
# Scenario: I should see project activity
8+
Scenario: I should see project activity
9+
When I visit project "Shop" page
10+
Then I should see project "Shop" activity feed
911

10-
# @wip
11-
# Scenario: I edit project
12+
Scenario: I visit edit project
13+
When I visit edit project "Shop" page
14+
Then I should see project settings
15+
16+
Scenario: I edit project
17+
When I visit edit project "Shop" page
18+
And change project settings
19+
And I save project
20+
Then I should see project with new settings
1221

1322
# @wip
1423
# Scenario: I visit attachments
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class AdminProjects < Spinach::FeatureSteps
2+
include SharedAuthentication
3+
include SharedPaths
4+
include SharedAdmin
5+
6+
And 'I should see all projects' do
7+
Project.all.each do |p|
8+
page.should have_content p.name_with_namespace
9+
end
10+
end
11+
12+
And 'I click on first project' do
13+
click_link Project.first.name_with_namespace
14+
end
15+
16+
Then 'I should see project details' do
17+
project = Project.first
18+
current_path.should == admin_project_path(project)
19+
20+
page.should have_content(project.name_with_namespace)
21+
page.should have_content(project.creator.name)
22+
page.should have_content('Add new team member')
23+
end
24+
end

features/steps/dashboard/dashboard.rb

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class Dashboard < Spinach::FeatureSteps
22
include SharedAuthentication
33
include SharedPaths
4+
include SharedProject
45

56
Then 'I should see "New Project" link' do
67
page.should have_link "New Project"
@@ -10,11 +11,6 @@ class Dashboard < Spinach::FeatureSteps
1011
page.should have_link "Shop"
1112
end
1213

13-
Then 'I should see project "Shop" activity feed' do
14-
project = Project.find_by_name("Shop")
15-
page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}"
16-
end
17-
1814
Then 'I should see last push widget' do
1915
page.should have_content "You pushed to new_design"
2016
page.should have_link "Create Merge Request"
@@ -59,11 +55,6 @@ class Dashboard < Spinach::FeatureSteps
5955
page.should have_content "John Doe left project at Shop"
6056
end
6157

62-
And 'I own project "Shop"' do
63-
@project = create :project, name: 'Shop'
64-
@project.team << [@user, :master]
65-
end
66-
6758
And 'I have group with projects' do
6859
@group = create(:group)
6960
@project = create(:project, group: @group)
@@ -72,32 +63,6 @@ class Dashboard < Spinach::FeatureSteps
7263
@project.team << [current_user, :master]
7364
end
7465

75-
And 'project "Shop" has push event' do
76-
@project = Project.find_by_name("Shop")
77-
78-
data = {
79-
before: "0000000000000000000000000000000000000000",
80-
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
81-
ref: "refs/heads/new_design",
82-
user_id: @user.id,
83-
user_name: @user.name,
84-
repository: {
85-
name: @project.name,
86-
url: "localhost/rubinius",
87-
description: "",
88-
homepage: "localhost/rubinius",
89-
private: true
90-
}
91-
}
92-
93-
@event = Event.create(
94-
project: @project,
95-
action: Event::Pushed,
96-
data: data,
97-
author_id: @user.id
98-
)
99-
end
100-
10166
Then 'I should see groups list' do
10267
Group.all.each do |group|
10368
page.should have_link group.name
@@ -112,5 +77,4 @@ class Dashboard < Spinach::FeatureSteps
11277
Then 'I should see 1 project at group list' do
11378
page.find('span.last_activity/span').should have_content('1')
11479
end
115-
11680
end

features/steps/project/project.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,17 @@ class Projects < Spinach::FeatureSteps
22
include SharedAuthentication
33
include SharedProject
44
include SharedPaths
5+
6+
And 'change project settings' do
7+
fill_in 'project_name', with: 'NewName'
8+
uncheck 'project_issues_enabled'
9+
end
10+
11+
And 'I save project' do
12+
click_button 'Save'
13+
end
14+
15+
Then 'I should see project with new settings' do
16+
find_field('project_name').value.should == 'NewName'
17+
end
518
end

features/steps/shared/admin.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module SharedAdmin
2+
include Spinach::DSL
3+
4+
And 'there are projects in system' do
5+
2.times { create(:project) }
6+
end
7+
end
8+

features/steps/shared/paths.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ module SharedPaths
165165
visit project_path(project)
166166
end
167167

168+
When 'I visit edit project "Shop" page' do
169+
project = Project.find_by_name("Shop")
170+
visit edit_project_path(project)
171+
end
172+
168173
Given 'I visit project branches page' do
169174
visit branches_project_repository_path(@project)
170175
end

features/steps/shared/project.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,44 @@ module SharedProject
1313
@project.team << [@user, :master]
1414
end
1515

16+
And 'project "Shop" has push event' do
17+
@project = Project.find_by_name("Shop")
18+
19+
data = {
20+
before: "0000000000000000000000000000000000000000",
21+
after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
22+
ref: "refs/heads/new_design",
23+
user_id: @user.id,
24+
user_name: @user.name,
25+
repository: {
26+
name: @project.name,
27+
url: "localhost/rubinius",
28+
description: "",
29+
homepage: "localhost/rubinius",
30+
private: true
31+
}
32+
}
33+
34+
@event = Event.create(
35+
project: @project,
36+
action: Event::Pushed,
37+
data: data,
38+
author_id: @user.id
39+
)
40+
end
41+
42+
Then 'I should see project "Shop" activity feed' do
43+
project = Project.find_by_name("Shop")
44+
page.should have_content "#{@user.name} pushed new branch new_design at #{project.name}"
45+
end
46+
47+
Then 'I should see project settings' do
48+
current_path.should == edit_project_path(@project)
49+
page.should have_content("Project name is")
50+
page.should have_content("Advanced settings:")
51+
page.should have_content("Features:")
52+
end
53+
1654
def current_project
1755
@project ||= Project.first
1856
end

0 commit comments

Comments
 (0)