headstart 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README.rdoc +117 -0
- data/Rakefile +95 -0
- data/VERSION +1 -0
- data/app/controllers/headstart/confirmations_controller.rb +76 -0
- data/app/controllers/headstart/impersonations_controller.rb +44 -0
- data/app/controllers/headstart/passwords_controller.rb +93 -0
- data/app/controllers/headstart/sessions_controller.rb +76 -0
- data/app/controllers/headstart/users_controller.rb +85 -0
- data/app/models/deliver_change_password_job.rb +19 -0
- data/app/models/deliver_welcome_job.rb +17 -0
- data/app/models/generic_mailer.rb +31 -0
- data/app/models/headstart_mailer.rb +28 -0
- data/app/models/impersonation.rb +26 -0
- data/app/models/mimi_mailer.rb +30 -0
- data/app/views/generic_mailer/change_password.html.erb +9 -0
- data/app/views/generic_mailer/confirmation.html.erb +5 -0
- data/app/views/generic_mailer/welcome.html.erb +1 -0
- data/app/views/impersonations/index.html.erb +5 -0
- data/app/views/passwords/edit.html.erb +23 -0
- data/app/views/passwords/new.html.erb +15 -0
- data/app/views/sessions/new.html.erb +48 -0
- data/app/views/users/_form.html.erb +21 -0
- data/app/views/users/edit.html.erb +6 -0
- data/app/views/users/new.html.erb +6 -0
- data/app/views/users/show.html.erb +8 -0
- data/generators/headstart/USAGE +1 -0
- data/generators/headstart/headstart_generator.rb +86 -0
- data/generators/headstart/lib/insert_commands.rb +33 -0
- data/generators/headstart/lib/rake_commands.rb +22 -0
- data/generators/headstart/templates/README +20 -0
- data/generators/headstart/templates/app/controllers/sessions_controller.rb +6 -0
- data/generators/headstart/templates/app/views/sessions/index.html.erb +1 -0
- data/generators/headstart/templates/application.html.erb +75 -0
- data/generators/headstart/templates/factories.rb +23 -0
- data/generators/headstart/templates/headstart.rb +25 -0
- data/generators/headstart/templates/headstart.yml +45 -0
- data/generators/headstart/templates/layout.css +353 -0
- data/generators/headstart/templates/migrations/create_users.rb +26 -0
- data/generators/headstart/templates/migrations/update_users.rb +44 -0
- data/generators/headstart/templates/report.css +69 -0
- data/generators/headstart/templates/reset.css +1 -0
- data/generators/headstart/templates/style.css +31 -0
- data/generators/headstart/templates/text.css +1 -0
- data/generators/headstart/templates/user.rb +3 -0
- data/generators/headstart/templates/xd_receiver.html +10 -0
- data/generators/headstart/templates/xd_receiver_ssl.html +10 -0
- data/generators/headstart_admin/USAGE +1 -0
- data/generators/headstart_admin/headstart_admin_generator.rb +32 -0
- data/generators/headstart_admin/lib/insert_commands.rb +33 -0
- data/generators/headstart_admin/templates/README +16 -0
- data/generators/headstart_admin/templates/app/controllers/admin/admin_controller.rb +17 -0
- data/generators/headstart_admin/templates/app/controllers/admin/users_controller.rb +52 -0
- data/generators/headstart_admin/templates/app/views/admin/admin/index.html.erb +2 -0
- data/generators/headstart_admin/templates/app/views/admin/users/_form.html.erb +25 -0
- data/generators/headstart_admin/templates/app/views/admin/users/edit.html.erb +6 -0
- data/generators/headstart_admin/templates/app/views/admin/users/index.html.erb +7 -0
- data/generators/headstart_admin/templates/app/views/admin/users/new.html.erb +6 -0
- data/generators/headstart_admin/templates/app/views/admin/users/show.html.erb +10 -0
- data/generators/headstart_admin/templates/test/integration/admin/users_test.rb +201 -0
- data/generators/headstart_tests/USAGE +1 -0
- data/generators/headstart_tests/headstart_tests_generator.rb +21 -0
- data/generators/headstart_tests/templates/README +58 -0
- data/generators/headstart_tests/templates/test/integration/edit_profile_test.rb +35 -0
- data/generators/headstart_tests/templates/test/integration/facebook_test.rb +61 -0
- data/generators/headstart_tests/templates/test/integration/impersonation_test.rb +39 -0
- data/generators/headstart_tests/templates/test/integration/password_reset_test.rb +128 -0
- data/generators/headstart_tests/templates/test/integration/sign_in_test.rb +66 -0
- data/generators/headstart_tests/templates/test/integration/sign_out_test.rb +28 -0
- data/generators/headstart_tests/templates/test/integration/sign_up_test.rb +47 -0
- data/lib/headstart/authentication.rb +138 -0
- data/lib/headstart/configuration.rb +34 -0
- data/lib/headstart/extensions/errors.rb +6 -0
- data/lib/headstart/extensions/rescue.rb +5 -0
- data/lib/headstart/routes.rb +67 -0
- data/lib/headstart/user.rb +279 -0
- data/lib/headstart.rb +7 -0
- data/rails/init.rb +4 -0
- data/shoulda_macros/headstart.rb +244 -0
- data/test/controllers/passwords_controller_test.rb +184 -0
- data/test/controllers/sessions_controller_test.rb +129 -0
- data/test/controllers/users_controller_test.rb +57 -0
- data/test/models/headstart_mailer_test.rb +52 -0
- data/test/models/impersonation_test.rb +25 -0
- data/test/models/user_test.rb +213 -0
- data/test/rails_root/app/controllers/accounts_controller.rb +10 -0
- data/test/rails_root/app/controllers/application_controller.rb +6 -0
- data/test/rails_root/app/helpers/application_helper.rb +5 -0
- data/test/rails_root/app/helpers/confirmations_helper.rb +2 -0
- data/test/rails_root/app/helpers/passwords_helper.rb +2 -0
- data/test/rails_root/config/boot.rb +110 -0
- data/test/rails_root/config/environment.rb +22 -0
- data/test/rails_root/config/environments/development.rb +19 -0
- data/test/rails_root/config/environments/production.rb +1 -0
- data/test/rails_root/config/environments/test.rb +37 -0
- data/test/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails_root/config/initializers/requires.rb +13 -0
- data/test/rails_root/config/initializers/time_formats.rb +4 -0
- data/test/rails_root/config/routes.rb +9 -0
- data/test/rails_root/public/dispatch.rb +10 -0
- data/test/rails_root/script/create_project.rb +52 -0
- data/test/rails_root/test/functional/accounts_controller_test.rb +23 -0
- data/test/test_helper.rb +21 -0
- metadata +232 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class UserTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
# signing up
|
|
6
|
+
|
|
7
|
+
context "When signing up" do
|
|
8
|
+
should_validate_presence_of :email, :password
|
|
9
|
+
should_allow_values_for :email, "foo@example.com"
|
|
10
|
+
should_not_allow_values_for :email, "foo"
|
|
11
|
+
should_not_allow_values_for :email, "example.com"
|
|
12
|
+
|
|
13
|
+
should "require password confirmation on create" do
|
|
14
|
+
user = Factory.build(:user, :password => 'blah',
|
|
15
|
+
:password_confirmation => 'boogidy')
|
|
16
|
+
assert ! user.save
|
|
17
|
+
assert user.errors.on(:password)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
should "require non blank password confirmation on create" do
|
|
21
|
+
user = Factory.build(:user, :password => 'blah',
|
|
22
|
+
:password_confirmation => '')
|
|
23
|
+
assert ! user.save
|
|
24
|
+
assert user.errors.on(:password)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
should "initialize salt" do
|
|
28
|
+
assert_not_nil Factory(:user).salt
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
should "initialize confirmation token" do
|
|
32
|
+
assert_not_nil Factory(:user)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context "encrypt password" do
|
|
36
|
+
setup do
|
|
37
|
+
@salt = "salt"
|
|
38
|
+
@user = Factory.build(:user, :salt => @salt)
|
|
39
|
+
def @user.initialize_salt; end
|
|
40
|
+
@user.save!
|
|
41
|
+
@password = @user.password
|
|
42
|
+
|
|
43
|
+
@user.send(:encrypt, @password)
|
|
44
|
+
@expected = Digest::SHA1.hexdigest("--#{@salt}--#{@password}--")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
should "create an encrypted password using SHA1 encryption" do
|
|
48
|
+
assert_equal @expected, @user.encrypted_password
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
should "store email in exact case" do
|
|
53
|
+
user = Factory(:user, :email => "John.Doe@example.com")
|
|
54
|
+
assert_equal "John.Doe@example.com", user.email
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context "When multiple users have signed up" do
|
|
59
|
+
setup { Factory(:user) }
|
|
60
|
+
should_validate_uniqueness_of :email
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# authenticating
|
|
64
|
+
|
|
65
|
+
context "A user" do
|
|
66
|
+
setup do
|
|
67
|
+
@user = Factory(:user)
|
|
68
|
+
@password = @user.password
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
should "authenticate with good credentials" do
|
|
72
|
+
assert ::User.authenticate(@user.email, @password)
|
|
73
|
+
assert @user.authenticated?(@password)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
should "not authenticate with bad credentials" do
|
|
77
|
+
assert ! ::User.authenticate(@user.email, 'bad_password')
|
|
78
|
+
assert ! @user.authenticated?('bad_password')
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# resetting remember token
|
|
83
|
+
|
|
84
|
+
context "When resetting authentication with reset_remember_token!" do
|
|
85
|
+
setup do
|
|
86
|
+
@user = Factory(:user)
|
|
87
|
+
@user.remember_token = "old-token"
|
|
88
|
+
@user.reset_remember_token!
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
should "change the remember token" do
|
|
92
|
+
assert_not_equal "old-token", @user.remember_token
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# updating password
|
|
97
|
+
|
|
98
|
+
context "An email confirmed user" do
|
|
99
|
+
setup do
|
|
100
|
+
@user = Factory(:user)
|
|
101
|
+
@old_encrypted_password = @user.encrypted_password
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
context "who updates password with confirmation" do
|
|
105
|
+
setup do
|
|
106
|
+
@user.update_password("new_password", "new_password")
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
should "change encrypted password" do
|
|
110
|
+
assert_not_equal @user.encrypted_password,
|
|
111
|
+
@old_encrypted_password
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
should "not generate the same remember token for users with the same password at the same time" do
|
|
117
|
+
Time.stubs(:now => Time.now)
|
|
118
|
+
password = 'secret'
|
|
119
|
+
first_user = Factory(:user,
|
|
120
|
+
:password => password,
|
|
121
|
+
:password_confirmation => password)
|
|
122
|
+
second_user = Factory(:user,
|
|
123
|
+
:password => password,
|
|
124
|
+
:password_confirmation => password)
|
|
125
|
+
|
|
126
|
+
assert_not_equal first_user.remember_token, second_user.remember_token
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# recovering forgotten password
|
|
130
|
+
|
|
131
|
+
context "An email confirmed user" do
|
|
132
|
+
setup do
|
|
133
|
+
@user = Factory(:user)
|
|
134
|
+
@old_encrypted_password = @user.encrypted_password
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
context "who requests password reminder" do
|
|
138
|
+
setup do
|
|
139
|
+
assert_nil @user.password_reset_token
|
|
140
|
+
@user.forgot_password!
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
should "generate password reset token" do
|
|
144
|
+
assert_not_nil @user.password_reset_token
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
context "and then updates password" do
|
|
148
|
+
context 'with confirmation' do
|
|
149
|
+
setup do
|
|
150
|
+
@user.update_password("new_password", "new_password")
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
should "change encrypted password" do
|
|
154
|
+
assert_not_equal @user.encrypted_password,
|
|
155
|
+
@old_encrypted_password
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
should "clear password reset token" do
|
|
159
|
+
assert_nil @user.password_reset_token
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
context 'without confirmation' do
|
|
164
|
+
setup do
|
|
165
|
+
@user.update_password("new_password", "")
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
should "not change encrypted password" do
|
|
169
|
+
assert_equal @user.encrypted_password,
|
|
170
|
+
@old_encrypted_password
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
should "not clear password reset token" do
|
|
174
|
+
assert_not_nil @user.password_reset_token
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# optional email/password fields
|
|
183
|
+
context "a user with an optional email" do
|
|
184
|
+
setup do
|
|
185
|
+
@user = User.new
|
|
186
|
+
class << @user
|
|
187
|
+
def email_optional?
|
|
188
|
+
true
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
subject { @user }
|
|
194
|
+
|
|
195
|
+
should_allow_values_for :email, nil, ""
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
context "a user with an optional password" do
|
|
199
|
+
setup do
|
|
200
|
+
@user = User.new
|
|
201
|
+
class << @user
|
|
202
|
+
def password_optional?
|
|
203
|
+
true
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
subject { @user }
|
|
209
|
+
|
|
210
|
+
should_allow_values_for :password, nil, ""
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Don't change this file!
|
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
|
3
|
+
|
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
|
5
|
+
|
|
6
|
+
module Rails
|
|
7
|
+
class << self
|
|
8
|
+
def boot!
|
|
9
|
+
unless booted?
|
|
10
|
+
preinitialize
|
|
11
|
+
pick_boot.run
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def booted?
|
|
16
|
+
defined? Rails::Initializer
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def pick_boot
|
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def vendor_rails?
|
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def preinitialize
|
|
28
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def preinitializer_path
|
|
32
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class Boot
|
|
37
|
+
def run
|
|
38
|
+
load_initializer
|
|
39
|
+
Rails::Initializer.run(:set_load_path)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class VendorBoot < Boot
|
|
44
|
+
def load_initializer
|
|
45
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
|
46
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
|
47
|
+
Rails::GemDependency.add_frozen_gem_path
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class GemBoot < Boot
|
|
52
|
+
def load_initializer
|
|
53
|
+
self.class.load_rubygems
|
|
54
|
+
load_rails_gem
|
|
55
|
+
require 'initializer'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def load_rails_gem
|
|
59
|
+
if version = self.class.gem_version
|
|
60
|
+
gem 'rails', version
|
|
61
|
+
else
|
|
62
|
+
gem 'rails'
|
|
63
|
+
end
|
|
64
|
+
rescue Gem::LoadError => load_error
|
|
65
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
|
66
|
+
exit 1
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class << self
|
|
70
|
+
def rubygems_version
|
|
71
|
+
Gem::RubyGemsVersion rescue nil
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def gem_version
|
|
75
|
+
if defined? RAILS_GEM_VERSION
|
|
76
|
+
RAILS_GEM_VERSION
|
|
77
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
|
78
|
+
ENV['RAILS_GEM_VERSION']
|
|
79
|
+
else
|
|
80
|
+
parse_gem_version(read_environment_rb)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def load_rubygems
|
|
85
|
+
require 'rubygems'
|
|
86
|
+
min_version = '1.3.1'
|
|
87
|
+
unless rubygems_version >= min_version
|
|
88
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
|
89
|
+
exit 1
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
rescue LoadError
|
|
93
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
|
94
|
+
exit 1
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def parse_gem_version(text)
|
|
98
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
private
|
|
102
|
+
def read_environment_rb
|
|
103
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# All that for this:
|
|
110
|
+
Rails.boot!
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
|
2
|
+
require 'digest/md5'
|
|
3
|
+
|
|
4
|
+
Rails::Initializer.run do |config|
|
|
5
|
+
config.load_paths += Dir.glob(File.join(RAILS_ROOT, 'vendor', 'gems', '*', 'lib'))
|
|
6
|
+
config.action_controller.session = {
|
|
7
|
+
:session_key => "_blue_light_special_session",
|
|
8
|
+
:secret => ['blue_light_special', 'random', 'words', 'here'].map {|k| Digest::MD5.hexdigest(k) }.join
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
config.gem "justinfrench-formtastic",
|
|
12
|
+
:lib => 'formtastic',
|
|
13
|
+
:source => 'http://gems.github.com'
|
|
14
|
+
|
|
15
|
+
config.gem "mini_fb",
|
|
16
|
+
:version => '=0.2.2'
|
|
17
|
+
|
|
18
|
+
config.gem "delayed_job",
|
|
19
|
+
:version => '=1.8.4'
|
|
20
|
+
|
|
21
|
+
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
|
22
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
|
2
|
+
|
|
3
|
+
# In the development environment your application's code is reloaded on
|
|
4
|
+
# every request. This slows down response time but is perfect for development
|
|
5
|
+
# since you don't have to restart the webserver when you make code changes.
|
|
6
|
+
config.cache_classes = false
|
|
7
|
+
|
|
8
|
+
# Log error messages when you accidentally call methods on nil.
|
|
9
|
+
config.whiny_nils = true
|
|
10
|
+
|
|
11
|
+
# Show full error reports and disable caching
|
|
12
|
+
config.action_controller.consider_all_requests_local = true
|
|
13
|
+
config.action_controller.perform_caching = false
|
|
14
|
+
config.action_view.debug_rjs = true
|
|
15
|
+
|
|
16
|
+
# Don't care if the mailer can't send
|
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
|
18
|
+
|
|
19
|
+
HOST = "localhost"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
HOST = "http://example.com"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
|
2
|
+
|
|
3
|
+
# The test environment is used exclusively to run your application's
|
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
|
7
|
+
config.cache_classes = true
|
|
8
|
+
|
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
|
10
|
+
config.whiny_nils = true
|
|
11
|
+
|
|
12
|
+
# Show full error reports and disable caching
|
|
13
|
+
config.action_controller.consider_all_requests_local = true
|
|
14
|
+
config.action_controller.perform_caching = false
|
|
15
|
+
|
|
16
|
+
# Disable request forgery protection in test environment
|
|
17
|
+
config.action_controller.allow_forgery_protection = false
|
|
18
|
+
|
|
19
|
+
# Tell ActionMailer not to deliver emails to the real world.
|
|
20
|
+
# The :test delivery method accumulates sent emails in the
|
|
21
|
+
# ActionMailer::Base.deliveries array.
|
|
22
|
+
config.action_mailer.delivery_method = :test
|
|
23
|
+
|
|
24
|
+
config.gem 'shoulda',
|
|
25
|
+
:source => "http://gemcutter.org",
|
|
26
|
+
:version => '>= 2.9.1'
|
|
27
|
+
config.gem 'factory_girl',
|
|
28
|
+
:source => "http://gemcutter.org",
|
|
29
|
+
:version => '>= 1.2.3'
|
|
30
|
+
|
|
31
|
+
config.gem 'webrat',
|
|
32
|
+
:lib => false,
|
|
33
|
+
:version => '>= 0.6.0'
|
|
34
|
+
|
|
35
|
+
config.gem 'fakeweb',
|
|
36
|
+
:source => "http://gemcutter.org",
|
|
37
|
+
:version => '>= 1.2.8'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Add new inflection rules using the following format
|
|
4
|
+
# (all these examples are active by default):
|
|
5
|
+
# Inflector.inflections do |inflect|
|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
|
8
|
+
# inflect.irregular 'person', 'people'
|
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
|
10
|
+
# end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Dir[File.join(RAILS_ROOT, 'lib', 'extensions', '*.rb')].each do |f|
|
|
2
|
+
require f
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Dir[File.join(RAILS_ROOT, 'lib', '*.rb')].each do |f|
|
|
6
|
+
require f
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Rails 2 doesn't like mocks
|
|
10
|
+
|
|
11
|
+
Dir[File.join(RAILS_ROOT, 'test', 'mocks', RAILS_ENV, '*.rb')].each do |f|
|
|
12
|
+
require f
|
|
13
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/opt/local/bin/ruby
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
|
|
4
|
+
|
|
5
|
+
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
|
|
6
|
+
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
|
|
7
|
+
require "dispatcher"
|
|
8
|
+
|
|
9
|
+
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
|
|
10
|
+
Dispatcher.dispatch
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'activesupport'
|
|
4
|
+
require 'pathname'
|
|
5
|
+
|
|
6
|
+
project_name = ARGV[0]
|
|
7
|
+
fail("Usage: #{File.basename(__FILE__)} new_project_name") unless project_name
|
|
8
|
+
fail("Project name must only contain [a-z0-9_]") unless project_name =~ /^[a-z0-9_]+$/
|
|
9
|
+
|
|
10
|
+
base_directory = Pathname.new(File.join(File.dirname(__FILE__), '..', '..')).realpath
|
|
11
|
+
project_directory = base_directory + project_name
|
|
12
|
+
fail("Project directory (#{project_directory}) already exists") if project_directory.exist?
|
|
13
|
+
|
|
14
|
+
template_url = "git@github.com:thoughtbot/rails-template.git"
|
|
15
|
+
changeme = "CHANGEME"
|
|
16
|
+
|
|
17
|
+
def run(cmd)
|
|
18
|
+
puts "Running '#{cmd}'"
|
|
19
|
+
out = `#{cmd}`
|
|
20
|
+
if $? != 0
|
|
21
|
+
fail "Command #{cmd} failed: #$?\n#{out}"
|
|
22
|
+
end
|
|
23
|
+
out
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def search_and_replace(file, search, replace)
|
|
27
|
+
if File.file?(file)
|
|
28
|
+
contents = File.read(file)
|
|
29
|
+
if contents[search]
|
|
30
|
+
puts "Replacing #{search} with #{replace} in #{file}"
|
|
31
|
+
contents.gsub!(search, replace)
|
|
32
|
+
File.open(file, "w") { |f| f << contents }
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
run("mkdir #{project_directory}")
|
|
38
|
+
Dir.chdir(project_directory) or fail("Couldn't change to #{project_directory}")
|
|
39
|
+
run("git init")
|
|
40
|
+
run("git remote add template #{template_url}")
|
|
41
|
+
run("git pull template master")
|
|
42
|
+
|
|
43
|
+
Dir.glob("#{project_directory}/**/*").each do |file|
|
|
44
|
+
search_and_replace(file, changeme, project_name)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
run("git commit -a -m 'Initial commit'")
|
|
48
|
+
|
|
49
|
+
puts
|
|
50
|
+
puts "Now login to github and add a new project named '#{project_name.humanize.titleize}'"
|
|
51
|
+
|
|
52
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class AccountsControllerTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
context "when signed out" do
|
|
6
|
+
setup { sign_out }
|
|
7
|
+
should_deny_access_on :get, :edit
|
|
8
|
+
should_deny_access_on :put, :update
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
context "on POST to create" do
|
|
12
|
+
setup do
|
|
13
|
+
post :create
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
should_deny_access
|
|
17
|
+
|
|
18
|
+
should "not store location" do
|
|
19
|
+
assert session[:return_to].nil?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) +
|
|
3
|
+
"/rails_root/config/environment")
|
|
4
|
+
require 'test_help'
|
|
5
|
+
|
|
6
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/..')
|
|
7
|
+
require 'headstart'
|
|
8
|
+
|
|
9
|
+
begin
|
|
10
|
+
require 'redgreen'
|
|
11
|
+
rescue LoadError
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
require File.join(File.dirname(__FILE__), '..', 'shoulda_macros', 'headstart')
|
|
15
|
+
|
|
16
|
+
class ActiveSupport::TestCase
|
|
17
|
+
self.use_transactional_fixtures = true
|
|
18
|
+
self.use_instantiated_fixtures = false
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
FakeWeb.allow_net_connect = false
|