Skip to content

Commit 94c20a0

Browse files
committed
Added account creation and program page tests
1 parent f18d01c commit 94c20a0

10 files changed

Lines changed: 97 additions & 5 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ end
5151
group :test do
5252
gem "mocha"
5353
gem "database_cleaner"
54+
gem "launchy"
5455
end

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ GEM
4444
activesupport (= 3.1.0)
4545
activesupport (3.1.0)
4646
multi_json (~> 1.0)
47+
addressable (2.2.6)
4748
arel (2.2.1)
4849
bcrypt-ruby (3.0.1)
4950
bson (1.5.2)
@@ -112,6 +113,8 @@ GEM
112113
thor (~> 0.14)
113114
json (1.6.4)
114115
kgio (2.7.2)
116+
launchy (2.0.5)
117+
addressable (~> 2.2.6)
115118
mail (2.3.0)
116119
i18n (>= 0.4.0)
117120
mime-types (~> 1.16)
@@ -244,6 +247,7 @@ DEPENDENCIES
244247
jnunemaker-validatable (>= 1.8.4)
245248
jquery-rails
246249
json
250+
launchy
247251
mm-devise (>= 1.2)
248252
mocha
249253
mongo_mapper

app/views/users/_form.html.haml

Whitespace-only changes.

app/views/users/show.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
%h4= resource.about
1919
%hr
2020
%p
21-
= link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource)
21+
= link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource), :class => "user-programs"
2222
%p
2323
Following:
2424
=link_to resource.following.count, resource_path(resource) + "/following"

features/programs.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Feature: Access Programs
2+
3+
As a user of the site, I want to access users' programs
4+
5+
Scenario: View a featured program
6+
Given there is a featured program
7+
Then I should be able to view a highlighted program
8+
9+
Scenario: View my programs
10+
Given a logged in user
11+
And I have uploaded a program
12+
Then I should be able to view my programs
13+
14+
Scenario: View another user's programs
15+
Given a user has uploaded a program
16+
Then I should be able to view their programs

features/signup.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Feature: Sign up for an account
2+
3+
As a new Hackety user, I want to create a new account and log in with it
4+
5+
Scenario: Create an account via the signup form
6+
When I register a new account
7+
Then I should be logged in with my new account
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Given /^there is a featured program$/ do
2+
@program = Program.create!(:author_username => "username",
3+
:slug => "slug",
4+
:title => "My Featured Program",
5+
:featured => true)
6+
end
7+
8+
Then /^I should be able to view a highlighted program$/ do
9+
visit programs_path
10+
within "#featured" do
11+
page.should have_content("My Featured Program")
12+
end
13+
end
14+
15+
def upload_program(user)
16+
@program = Program.create!(:author_username => user.username,
17+
:slug => "slug",
18+
:title => "#{user.username}'s program")
19+
end
20+
21+
Given /^I have uploaded a program$/ do
22+
upload_program(@user)
23+
end
24+
25+
Given /^a user has uploaded a program$/ do
26+
@user = User.create!(:username => "some_user",
27+
:password => "password",
28+
:password_confirmation => "password",
29+
:email => "some_user@example.com")
30+
upload_program(@user)
31+
end
32+
33+
def visit_user_programs_page
34+
visit user_path(@user)
35+
within ".about-user" do
36+
find(".user-programs").click()
37+
end
38+
page.should have_content(@program.title.titleize)
39+
end
40+
41+
Then /^I should be able to view my programs$/ do
42+
visit_user_programs_page
43+
end
44+
45+
Then /^I should be able to view their programs$/ do
46+
visit_user_programs_page
47+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
When /^I register a new account$/ do
2+
@user_info = {:username => "username", :password => "password", :email => "test@example.com"}
3+
4+
visit new_user_registration_path
5+
6+
fill_in("Username", :with => @user_info[:username])
7+
fill_in("Email", :with => @user_info[:email])
8+
fill_in("Password", :with => @user_info[:password])
9+
fill_in("Password confirmation", :with => @user_info[:password])
10+
11+
click_button "Sign up"
12+
end
13+
14+
When /^I should be logged in with my new account$/ do
15+
page.should have_content("You have signed up successfully")
16+
page.should have_content(@user_info[:username])
17+
end

features/step_definitions/user_steps.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def login_user
33
email: "test_user@example.com",
44
password: "foobar",
55
password_confirmation: "foobar")
6-
visit('/login')
6+
visit login_path
77
fill_in("Username", :with => @user.username)
88
fill_in("Password", :with => @user.password)
99
click_button("Sign in")

features/users.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Feature: Manage account
2-
2+
33
As a user of this site, I can view and update my profile
44

55
Background: The user is logged in
@@ -8,8 +8,8 @@ Feature: Manage account
88
Scenario: View my profile
99
When I go to look at my profile page
1010
Then it should have the right information
11-
11+
1212
Scenario: Edit my profile
1313
When I edit my profile
1414
Then I should be notified that my profile was updated
15-
And I should see my changes reflected on my profile page
15+
And I should see my changes reflected on my profile page

0 commit comments

Comments
 (0)