active_application 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +7 -0
- data/Guardfile +29 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +7 -0
- data/active_application.gemspec +42 -0
- data/app/assets/javascripts/active_application/base.js +4 -0
- data/app/assets/stylesheets/active_application/base.css +5 -0
- data/app/assets/stylesheets/active_application/layout.css +17 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +28 -0
- data/app/controllers/active_application/public_controller.rb +5 -0
- data/app/controllers/active_application/resource_controller.rb +23 -0
- data/app/controllers/active_application/user_resource_controller.rb +14 -0
- data/app/helpers/active_application/base_helper.rb +7 -0
- data/app/helpers/active_application/bootstrap_helper.rb +8 -0
- data/app/helpers/active_application/layout_helper.rb +23 -0
- data/app/helpers/simple_resource/custom_helper.rb +41 -0
- data/app/models/active_application/user.rb +12 -0
- data/app/views/active_application/public/404.html.erb +7 -0
- data/app/views/active_application/public/index.html.erb +0 -0
- data/app/views/devise/passwords/edit.html.erb +11 -0
- data/app/views/devise/passwords/new.html.erb +9 -0
- data/app/views/devise/registrations/edit.html.erb +39 -0
- data/app/views/devise/registrations/new.html.erb +11 -0
- data/app/views/devise/sessions/new.html.erb +10 -0
- data/app/views/kaminari/_first_page.html.erb +7 -0
- data/app/views/kaminari/_gap.html.erb +1 -0
- data/app/views/kaminari/_last_page.html.erb +7 -0
- data/app/views/kaminari/_next_page.html.erb +7 -0
- data/app/views/kaminari/_page.html.erb +7 -0
- data/app/views/kaminari/_paginator.html.erb +17 -0
- data/app/views/kaminari/_prev_page.html.erb +7 -0
- data/app/views/layouts/application.html.erb +47 -0
- data/app/views/simple_resource/base/_collection.html.erb +26 -0
- data/config/routes.rb +0 -0
- data/lib/active_application/engine.rb +31 -0
- data/lib/active_application/routes.rb +32 -0
- data/lib/active_application/version.rb +3 -0
- data/lib/active_application.rb +16 -0
- data/lib/generators/active_application/cancan/cancan_generator.rb +15 -0
- data/lib/generators/active_application/cancan/templates/ability.rb +10 -0
- data/lib/generators/active_application/devise/devise_generator.rb +46 -0
- data/lib/generators/active_application/install/install_generator.rb +21 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/milestones_controller.rb +3 -0
- data/spec/dummy/app/controllers/projects_controller.rb +2 -0
- data/spec/dummy/app/controllers/tasks_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/ability.rb +11 -0
- data/spec/dummy/app/models/milestone.rb +6 -0
- data/spec/dummy/app/models/project.rb +8 -0
- data/spec/dummy/app/models/task.rb +4 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/views/layouts/_menu.html.erb +3 -0
- data/spec/dummy/app/views/projects/_actions.html.erb +3 -0
- data/spec/dummy/config/application.rb +65 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +232 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/devise.en.yml +58 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +12 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20121018181406_devise_create_users.rb +46 -0
- data/spec/dummy/db/migrate/20121018214335_create_projects.rb +12 -0
- data/spec/dummy/db/migrate/20121019000703_create_milestones.rb +12 -0
- data/spec/dummy/db/migrate/20121019001551_create_tasks.rb +13 -0
- data/spec/dummy/db/schema.rb +70 -0
- data/spec/dummy/db/seeds.rb +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/users.rb +6 -0
- data/spec/features/users/forgot_password_spec.rb +138 -0
- data/spec/features/users/sign_up_confirmation_spec.rb +51 -0
- data/spec/features/visitors/sign_up_spec.rb +114 -0
- data/spec/helpers/base_helper_spec.rb +9 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/support/helpers.rb +9 -0
- metadata +563 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
class DeviseCreateUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table(:users) do |t|
|
4
|
+
## Database authenticatable
|
5
|
+
t.string :email, :null => false, :default => ""
|
6
|
+
t.string :encrypted_password, :null => false, :default => ""
|
7
|
+
|
8
|
+
## Recoverable
|
9
|
+
t.string :reset_password_token
|
10
|
+
t.datetime :reset_password_sent_at
|
11
|
+
|
12
|
+
## Rememberable
|
13
|
+
t.datetime :remember_created_at
|
14
|
+
|
15
|
+
## Trackable
|
16
|
+
t.integer :sign_in_count, :default => 0
|
17
|
+
t.datetime :current_sign_in_at
|
18
|
+
t.datetime :last_sign_in_at
|
19
|
+
t.string :current_sign_in_ip
|
20
|
+
t.string :last_sign_in_ip
|
21
|
+
|
22
|
+
## Confirmable
|
23
|
+
t.string :confirmation_token
|
24
|
+
t.datetime :confirmed_at
|
25
|
+
t.datetime :confirmation_sent_at
|
26
|
+
t.string :unconfirmed_email # Only if using reconfirmable
|
27
|
+
|
28
|
+
## Lockable
|
29
|
+
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
30
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
31
|
+
# t.datetime :locked_at
|
32
|
+
|
33
|
+
## Token authenticatable
|
34
|
+
# t.string :authentication_token
|
35
|
+
|
36
|
+
|
37
|
+
t.timestamps
|
38
|
+
end
|
39
|
+
|
40
|
+
add_index :users, :email, :unique => true
|
41
|
+
add_index :users, :reset_password_token, :unique => true
|
42
|
+
add_index :users, :confirmation_token, :unique => true
|
43
|
+
# add_index :users, :unlock_token, :unique => true
|
44
|
+
# add_index :users, :authentication_token, :unique => true
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 20121019001551) do
|
15
|
+
|
16
|
+
create_table "milestones", :force => true do |t|
|
17
|
+
t.integer "project_id"
|
18
|
+
t.text "summary"
|
19
|
+
t.datetime "deadline_at"
|
20
|
+
t.datetime "created_at", :null => false
|
21
|
+
t.datetime "updated_at", :null => false
|
22
|
+
end
|
23
|
+
|
24
|
+
add_index "milestones", ["project_id"], :name => "index_milestones_on_project_id"
|
25
|
+
|
26
|
+
create_table "projects", :force => true do |t|
|
27
|
+
t.integer "user_id"
|
28
|
+
t.string "name"
|
29
|
+
t.text "summary"
|
30
|
+
t.datetime "created_at", :null => false
|
31
|
+
t.datetime "updated_at", :null => false
|
32
|
+
end
|
33
|
+
|
34
|
+
add_index "projects", ["user_id"], :name => "index_projects_on_user_id"
|
35
|
+
|
36
|
+
create_table "tasks", :force => true do |t|
|
37
|
+
t.integer "milestone_id"
|
38
|
+
t.string "title"
|
39
|
+
t.text "summary"
|
40
|
+
t.datetime "completed_at"
|
41
|
+
t.datetime "created_at", :null => false
|
42
|
+
t.datetime "updated_at", :null => false
|
43
|
+
end
|
44
|
+
|
45
|
+
add_index "tasks", ["milestone_id"], :name => "index_tasks_on_milestone_id"
|
46
|
+
|
47
|
+
create_table "users", :force => true do |t|
|
48
|
+
t.string "email", :default => "", :null => false
|
49
|
+
t.string "encrypted_password", :default => "", :null => false
|
50
|
+
t.string "reset_password_token"
|
51
|
+
t.datetime "reset_password_sent_at"
|
52
|
+
t.datetime "remember_created_at"
|
53
|
+
t.integer "sign_in_count", :default => 0
|
54
|
+
t.datetime "current_sign_in_at"
|
55
|
+
t.datetime "last_sign_in_at"
|
56
|
+
t.string "current_sign_in_ip"
|
57
|
+
t.string "last_sign_in_ip"
|
58
|
+
t.string "confirmation_token"
|
59
|
+
t.datetime "confirmed_at"
|
60
|
+
t.datetime "confirmation_sent_at"
|
61
|
+
t.string "unconfirmed_email"
|
62
|
+
t.datetime "created_at", :null => false
|
63
|
+
t.datetime "updated_at", :null => false
|
64
|
+
end
|
65
|
+
|
66
|
+
add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
|
67
|
+
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
68
|
+
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
69
|
+
|
70
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Forgot password feature" do
|
4
|
+
let(:user) { FactoryGirl.create :user }
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
visit "/"
|
8
|
+
click_link "Sign in"
|
9
|
+
click_link "Forgot Your Password?"
|
10
|
+
fill_in "Email", with: user.email
|
11
|
+
click_button "Send me reset password instructions"
|
12
|
+
page.should have_content "You will receive an email with instructions about how to reset your password in a few minutes."
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "reset password instructions email" do
|
16
|
+
let(:mail) { ActionMailer::Base.deliveries.last }
|
17
|
+
let(:registered_user) { User.where(email: user.email).first }
|
18
|
+
|
19
|
+
it "has a correct subject" do
|
20
|
+
mail.subject.should eq("Reset password instructions")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has a correct recipient address" do
|
24
|
+
mail.to.should eq([user.email])
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has a correct from address" do
|
28
|
+
mail.from.should eq(["info@example.com"])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "includes a confirmation link" do
|
32
|
+
mail.body.should include(
|
33
|
+
"http://example.com/reset/" +
|
34
|
+
registered_user.reset_password_token
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "visiting the reset password url" do
|
40
|
+
before :each do
|
41
|
+
reset_password_url =
|
42
|
+
"http://example.com/reset/" +
|
43
|
+
User.where(email: user.email).first.reset_password_token
|
44
|
+
visit reset_password_url
|
45
|
+
end
|
46
|
+
|
47
|
+
it "has a correct title" do
|
48
|
+
page.html.should have_xpath "//title", text: "Change Your Password"
|
49
|
+
end
|
50
|
+
|
51
|
+
it "has a correct heading" do
|
52
|
+
page.should have_css "h1", text: "Change Your Password"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "has a password field" do
|
56
|
+
page.should have_field "user_password"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "has a password confirmation field" do
|
60
|
+
page.should have_field "user_password_confirmation"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "has a change my password button" do
|
64
|
+
page.should have_button "Change My Password"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "resetting the password" do
|
69
|
+
before :each do
|
70
|
+
reset_password_url =
|
71
|
+
"http://example.com/reset/" +
|
72
|
+
User.where(email: user.email).first.reset_password_token
|
73
|
+
visit reset_password_url
|
74
|
+
end
|
75
|
+
|
76
|
+
context "with correct details" do
|
77
|
+
before :each do
|
78
|
+
fill_in "user_password", with: "newpassword"
|
79
|
+
fill_in "user_password_confirmation", with: "newpassword"
|
80
|
+
click_button "Change My Password"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should redirect to root page" do
|
84
|
+
page.current_path.should eq("/")
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should display an alert" do
|
88
|
+
page.should have_content "Your password was changed successfully. You are now signed in."
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "with empty fields" do
|
93
|
+
before :each do
|
94
|
+
click_button "Change My Password"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should not redirect" do
|
98
|
+
page.current_path.should eq("/reset")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should display an error message" do
|
102
|
+
page.should have_content "can't be blank"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "with unmatching passwords" do
|
107
|
+
before :each do
|
108
|
+
fill_in "user_password", with: "newpassword"
|
109
|
+
fill_in "user_password_confirmation", with: "notnewpassword"
|
110
|
+
click_button "Change My Password"
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should not redirect" do
|
114
|
+
page.current_path.should eq("/reset")
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should display an error message" do
|
118
|
+
page.should have_content "doesn't match confirmation"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context "with too short password" do
|
123
|
+
before :each do
|
124
|
+
fill_in "user_password", with: "new45"
|
125
|
+
fill_in "user_password_confirmation", with: "new45"
|
126
|
+
click_button "Change My Password"
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should not redirect" do
|
130
|
+
page.current_path.should eq("/reset")
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should display an error message" do
|
134
|
+
page.should have_content "is too short"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Sign up confirmation feature" do
|
4
|
+
let(:user) { FactoryGirl.build :user }
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
visit "/"
|
8
|
+
click_link "Sign up"
|
9
|
+
fill_in "Email", with: user.email
|
10
|
+
fill_in "user_password", with: user.password
|
11
|
+
fill_in "Password confirmation", with: user.password
|
12
|
+
click_button "Sign up"
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "confirmation email" do
|
16
|
+
let(:confirmation_email) { ActionMailer::Base.deliveries.last }
|
17
|
+
let(:registered_user) { User.where(email: user.email).first }
|
18
|
+
|
19
|
+
it "has a correct subject" do
|
20
|
+
confirmation_email.subject.should eq("Confirmation instructions")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "has a correct recipient address" do
|
24
|
+
confirmation_email.to.should eq([user.email])
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has a correct from address" do
|
28
|
+
confirmation_email.from.should eq(["info@example.com"])
|
29
|
+
end
|
30
|
+
|
31
|
+
it "includes a confirmation link" do
|
32
|
+
confirmation_email.body.should include(
|
33
|
+
"http://example.com/confirm/" +
|
34
|
+
registered_user.confirmation_token
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "visiting the confirmation url" do
|
40
|
+
before :each do
|
41
|
+
confirmation_url =
|
42
|
+
"http://example.com/confirm/" +
|
43
|
+
User.where(email: user.email).first.confirmation_token
|
44
|
+
visit confirmation_url
|
45
|
+
end
|
46
|
+
|
47
|
+
it "displays a success message" do
|
48
|
+
page.should have_content "Your account was successfully confirmed"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Sign up feature" do
|
4
|
+
let(:user) { FactoryGirl.build :user }
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
visit "/"
|
8
|
+
click_link "Sign up"
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "sign up page" do
|
12
|
+
it "has an email field" do
|
13
|
+
page.should have_field "Email"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "has a password field" do
|
17
|
+
page.should have_field "Password"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "has a password confirmation field" do
|
21
|
+
page.should have_field "Password confirmation"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "has a 'Sign up' button" do
|
25
|
+
page.should have_button "Sign up"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "signing up" do
|
30
|
+
before :each do
|
31
|
+
fill_in "Email", with: user.email
|
32
|
+
fill_in "user_password", with: user.password
|
33
|
+
fill_in "Password confirmation", with: user.password
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with correct details" do
|
37
|
+
before :each do
|
38
|
+
click_button "Sign up"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "redirects to root page" do
|
42
|
+
page.current_path.should == "/"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "displays confirmation sent message" do
|
46
|
+
page.should have_content "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
|
47
|
+
end
|
48
|
+
|
49
|
+
it "does not sign in automatically" do
|
50
|
+
page.should have_link "Sign in"
|
51
|
+
page.should_not have_link "Sign out"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "without email" do
|
56
|
+
before :each do
|
57
|
+
fill_in "Email", with: ""
|
58
|
+
click_button "Sign up"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "displays error message" do
|
62
|
+
page.should have_content "can't be blank"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "with an existing email" do
|
67
|
+
let(:existing_user) { FactoryGirl.create :user }
|
68
|
+
|
69
|
+
before :each do
|
70
|
+
fill_in "Email", with: existing_user.email
|
71
|
+
click_button "Sign up"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "displays error message" do
|
75
|
+
page.should have_content "has already been taken"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "without password" do
|
80
|
+
before :each do
|
81
|
+
fill_in "user_password", with: ""
|
82
|
+
fill_in "Password confirmation", with: ""
|
83
|
+
click_button "Sign up"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "displays error message" do
|
87
|
+
page.should have_content "can't be blank"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "with invalid password confirmation" do
|
92
|
+
before :each do
|
93
|
+
fill_in "Password confirmation", with: "somethingelse"
|
94
|
+
click_button "Sign up"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "displays error message" do
|
98
|
+
page.should have_content "doesn't match confirmation"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context "with too short password" do
|
103
|
+
before :each do
|
104
|
+
fill_in "user_password", with: "foo45"
|
105
|
+
fill_in "Password confirmation", with: "foo45"
|
106
|
+
click_button "Sign up"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "displays error message" do
|
110
|
+
page.should have_content "is too short"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "spork"
|
3
|
+
|
4
|
+
Spork.prefork do
|
5
|
+
ENV["RAILS_ENV"] ||= "test"
|
6
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
7
|
+
require "rspec/rails"
|
8
|
+
require "rspec/autorun"
|
9
|
+
require "capybara/rails"
|
10
|
+
require "database_cleaner"
|
11
|
+
require "forgery"
|
12
|
+
|
13
|
+
Dir[Rails.root.join("../support/**/*.rb")].each {|f| require f}
|
14
|
+
DatabaseCleaner.strategy = :truncation
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.fail_fast = true
|
18
|
+
config.use_transactional_fixtures = false
|
19
|
+
config.infer_base_class_for_anonymous_controllers = false
|
20
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
21
|
+
config.run_all_when_everything_filtered = true
|
22
|
+
config.filter_run :focus
|
23
|
+
config.order = "random"
|
24
|
+
|
25
|
+
config.before :each do
|
26
|
+
DatabaseCleaner.start
|
27
|
+
end
|
28
|
+
|
29
|
+
config.after :each do
|
30
|
+
DatabaseCleaner.clean
|
31
|
+
end
|
32
|
+
|
33
|
+
config.include Helpers
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Spork.each_run do
|
38
|
+
require "factory_girl_rails"
|
39
|
+
FactoryGirl.reload
|
40
|
+
end
|