muck-users 0.1.8 → 0.1.9
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/README.rdoc +6 -1
- data/VERSION +1 -1
- data/app/controllers/muck/users_controller.rb +29 -10
- data/app/helpers/muck_users_helper.rb +14 -0
- data/app/models/user_mailer.rb +1 -1
- data/app/views/password_resets/new.html.erb +1 -1
- data/app/views/user_mailer/welcome_notification.text.html.erb +2 -1
- data/app/views/user_mailer/welcome_notification.text.plain.erb +3 -1
- data/app/views/users/_recover_password_via_email_link.html.erb +1 -0
- data/app/views/users/_signup_form.html.erb +29 -0
- data/app/views/users/_signup_form_javascript.html.erb +18 -0
- data/app/views/users/new.html.erb +2 -46
- data/app/views/users/welcome.html.erb +2 -1
- data/lib/muck_users.rb +1 -0
- data/locales/en.yml +7 -4
- data/muck-users.gemspec +7 -2
- data/pkg/muck-users-0.1.8.gem +0 -0
- data/rdoc/created.rid +1 -1
- data/rdoc/files/README_rdoc.html +30 -10
- data/rdoc/files/lib/active_record/acts/muck_user_rb.html +1 -1
- data/test/rails_root/public/stylesheets/styles.css +1 -1
- data/test/rails_root/test/functional/users_controller_test.rb +44 -0
- data/test/rails_root/test/shoulda_macros/controller.rb +14 -0
- metadata +7 -2
data/README.rdoc
CHANGED
@@ -39,7 +39,12 @@ Inside of global_config.yml add the following changing the emails to match your
|
|
39
39
|
|
40
40
|
== Usage
|
41
41
|
|
42
|
-
|
42
|
+
There are a couple of routes that muck-users will look for:
|
43
|
+
|
44
|
+
Route to the site home page:
|
45
|
+
map.root '', :controller => 'default', :action => 'index'
|
46
|
+
|
47
|
+
Route to a public user page (this could also go to home etc. if needed)
|
43
48
|
map.public_user_path '/profiles/:id', :controller => 'profiles', :action => 'show'
|
44
49
|
This is the path that a user will be redirected to if they attempt to access another user's dashboard page.
|
45
50
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.9
|
@@ -62,6 +62,7 @@ class Muck::UsersController < ApplicationController
|
|
62
62
|
if GlobalConfig.automatically_login_after_account_create
|
63
63
|
if @user.save
|
64
64
|
@user.activate!
|
65
|
+
UserSession.create(@user)
|
65
66
|
@user.deliver_welcome_email
|
66
67
|
flash[:notice] = t('muck.users.thanks_sign_up')
|
67
68
|
after_create_response(true, signup_complete_path(@user))
|
@@ -79,7 +80,7 @@ class Muck::UsersController < ApplicationController
|
|
79
80
|
end
|
80
81
|
end
|
81
82
|
else
|
82
|
-
if @user.save_without_session_maintenance
|
83
|
+
if @user.save_without_session_maintenance
|
83
84
|
@user.deliver_activation_instructions!
|
84
85
|
flash[:notice] = t('muck.users.thanks_sign_up_check')
|
85
86
|
after_create_response(true, signup_complete_activation_required_path(@user))
|
@@ -132,23 +133,38 @@ class Muck::UsersController < ApplicationController
|
|
132
133
|
end
|
133
134
|
|
134
135
|
def is_email_available
|
135
|
-
|
136
|
-
#recover_password_prompt = link_to(t('muck.users.recover_password_prompt'), reset_password_path)
|
137
|
-
recover_password_prompt = ''
|
138
|
-
result = t('muck.users.email_not_available', :reset_password_help => recover_password_prompt)
|
139
|
-
|
140
|
-
if params[:user_email] && params[:user_email].length <= 0
|
136
|
+
if params[:user_email].nil?
|
141
137
|
result = ''
|
138
|
+
elsif params[:user_email].empty?
|
139
|
+
result = t('muck.users.email_empty')
|
142
140
|
elsif !User.email_exists?(params[:user_email])
|
143
|
-
|
141
|
+
valid, errors = valid_email?(params[:user_email])
|
142
|
+
if valid
|
143
|
+
result = t('muck.users.email_available')
|
144
|
+
else
|
145
|
+
result = t('muck.users.email_invalid')
|
146
|
+
end
|
147
|
+
else
|
148
|
+
recover_password_prompt = render_to_string :partial => 'users/recover_password_via_email_link', :locals => { :email => params[:user_email] }
|
149
|
+
result = t('muck.users.email_not_available', :reset_password_help => recover_password_prompt)
|
144
150
|
end
|
145
151
|
respond_to do |format|
|
146
|
-
format.html { render :text => result}
|
152
|
+
format.html { render :text => result }
|
147
153
|
end
|
148
154
|
end
|
149
155
|
|
150
156
|
protected
|
151
157
|
|
158
|
+
def valid_email?(email)
|
159
|
+
user = User.new(:email => email)
|
160
|
+
user.valid?
|
161
|
+
if user.errors[:email]
|
162
|
+
[false, user.errors[:email]]
|
163
|
+
else
|
164
|
+
[true, '']
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
152
168
|
def standard_response(template)
|
153
169
|
respond_to do |format|
|
154
170
|
format.html { render :template => "users/#{template}" }
|
@@ -170,6 +186,7 @@ class Muck::UsersController < ApplicationController
|
|
170
186
|
end
|
171
187
|
end
|
172
188
|
|
189
|
+
# override redirect by adding :redirect_to as a hidden field in your form or as a url param
|
173
190
|
def after_update_response(success)
|
174
191
|
if success
|
175
192
|
respond_to do |format|
|
@@ -188,11 +205,13 @@ class Muck::UsersController < ApplicationController
|
|
188
205
|
end
|
189
206
|
end
|
190
207
|
|
208
|
+
# override redirect by adding :redirect_to as a hidden field in your form or as a url param
|
191
209
|
def after_destroy_response
|
192
210
|
respond_to do |format|
|
193
211
|
format.html do
|
212
|
+
flash[:notice] = t('muck.users.login_out_success')
|
194
213
|
get_redirect_to do
|
195
|
-
redirect_to(
|
214
|
+
redirect_to(login_url)
|
196
215
|
end
|
197
216
|
end
|
198
217
|
format.xml { head :ok }
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module MuckUsersHelper
|
2
|
+
|
3
|
+
# Render a basic user registration form
|
4
|
+
def signup_form(user, redirect_to = nil)
|
5
|
+
render :partial => 'users/signup_form', :locals => { :user => user, :redirect_to => redirect_to}
|
6
|
+
end
|
7
|
+
|
8
|
+
# Sign up javascript is not required but will add script to the sign up form which will make ajax calls
|
9
|
+
# that indicate to the user whether or not the login and email they choose have already been taken.
|
10
|
+
def signup_form_javascript
|
11
|
+
render :partial => 'users/signup_form_javascript'
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/app/models/user_mailer.rb
CHANGED
@@ -46,7 +46,7 @@ class UserMailer < ActionMailer::Base
|
|
46
46
|
protected
|
47
47
|
def setup_email(user)
|
48
48
|
recipients user.email
|
49
|
-
from "#{GlobalConfig.application_name} <#{GlobalConfig.
|
49
|
+
from "#{GlobalConfig.application_name} <#{GlobalConfig.from_email_name}>"
|
50
50
|
sent_on Time.now
|
51
51
|
end
|
52
52
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<%= output_errors(t('muck.users.reset_password'), {:class => 'help-box'}) %>
|
4
4
|
<% custom_form_for :reset_password, :url => password_resets_path do |f| -%>
|
5
5
|
<p><%= t('muck.users.email_recover_prompt') %></p>
|
6
|
-
<%= f.text_field :email, { :label => t('muck.users.email_address'), :hide_required => true } -%>
|
6
|
+
<%= f.text_field :email, { :label => t('muck.users.email_address'), :hide_required => true, :value => params[:email] } -%>
|
7
7
|
<div class="button form-row">
|
8
8
|
<%= submit_tag t('muck.users.reset_password') %>
|
9
9
|
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= link_to(t('muck.users.recover_password_prompt'), forgot_password_path( :email => email)) %>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<% custom_form_for :user, :url => users_path, :html => {:id => "register-user-form", :name => 'register-user-form'} do |f| -%>
|
2
|
+
|
3
|
+
<%= output_errors(t('muck.users.problem_creating_account'), {:class => 'help-box'}, user) %>
|
4
|
+
|
5
|
+
<%= f.text_field :login, { :label => t('muck.users.choose_member_name'),
|
6
|
+
:extra_html => '<span id="username-availibility" class="availability"></span>',
|
7
|
+
:tip => t('muck.users.username_help'),
|
8
|
+
:required_label => t('muck.users.username') } -%>
|
9
|
+
<%= f.text_field :email, { :label => t('muck.users.email_address'),
|
10
|
+
:tip => t('muck.users.email_help'),
|
11
|
+
:extra_html => '<span id="email-availibility" class="availability"></span>' } -%>
|
12
|
+
<%= f.password_field :password, { :label => t('muck.users.password'),
|
13
|
+
:tip => t('muck.users.password_help')} -%>
|
14
|
+
<%= f.password_field :password_confirmation, { :label => t('muck.users.confirm_password'),
|
15
|
+
:tip => t('muck.users.password_confirmation_help') } -%>
|
16
|
+
|
17
|
+
<%= hidden_field_tag :redirect_to, redirect_to -%>
|
18
|
+
|
19
|
+
<% if GlobalConfig.use_recaptcha -%>
|
20
|
+
<div class="recaptcha">
|
21
|
+
<%= recaptcha_tags %>
|
22
|
+
</div>
|
23
|
+
<% end -%>
|
24
|
+
|
25
|
+
<div class="button form-row">
|
26
|
+
<%= f.submit t('muck.users.sign_up_now') %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% content_for :javascript do -%>
|
2
|
+
jQuery("#user_login").blur(function(){
|
3
|
+
jQuery.post("is_login_available",{ user_login:jQuery(this).val() } ,function(data){
|
4
|
+
jQuery("#username-availibility").html(data);
|
5
|
+
});
|
6
|
+
});
|
7
|
+
jQuery("#user_login").keydown(function() {
|
8
|
+
jQuery("#username-availibility").html('');
|
9
|
+
});
|
10
|
+
jQuery("#user_email").blur(function(){
|
11
|
+
jQuery.post("is_email_available",{ user_email:jQuery(this).val() } ,function(data){
|
12
|
+
jQuery("#email-availibility").html(data);
|
13
|
+
});
|
14
|
+
});
|
15
|
+
jQuery("#user_email").keydown(function() {
|
16
|
+
jQuery("#email-availibility").html('');
|
17
|
+
});
|
18
|
+
<% end -%>
|
@@ -1,50 +1,6 @@
|
|
1
1
|
<div id="registration" class="common-form">
|
2
2
|
<h1><%= t('muck.users.register_account', :application_name => GlobalConfig.application_name) %></h1>
|
3
3
|
<p><%= t('muck.users.already_registered') %> <a href="<%=login_url%>"><%= t('muck.users.sign_in_now') %></a></p>
|
4
|
-
|
5
|
-
<% custom_form_for :user, :url => users_path, :html => {:id => "register-user-form", :name => 'register-user-form'} do |f| -%>
|
6
|
-
|
7
|
-
<%= output_errors(t('muck.users.problem_creating_account'), {:class => 'help-box'}, @user) %>
|
8
|
-
|
9
|
-
<%= f.text_field :login, { :label => t('muck.users.choose_member_name'),
|
10
|
-
:extra_html => '<span id="username-availibility" class="availability"></span>',
|
11
|
-
:tip => t('muck.users.username_help'),
|
12
|
-
:required_label => t('muck.users.username') } -%>
|
13
|
-
<%= f.text_field :email, { :label => t('muck.users.email_address'),
|
14
|
-
:tip => t('muck.users.email_help'),
|
15
|
-
:extra_html => '<span id="email-availibility" class="availability"></span>' } -%>
|
16
|
-
<%= f.password_field :password, { :label => t('muck.users.password'),
|
17
|
-
:tip => t('muck.users.password_help')} -%>
|
18
|
-
<%= f.password_field :password_confirmation, { :label => t('muck.users.confirm_password'),
|
19
|
-
:tip => t('muck.users.password_confirmation_help') } -%>
|
20
|
-
<% if GlobalConfig.use_recaptcha -%>
|
21
|
-
<div class="recaptcha">
|
22
|
-
<%= recaptcha_tags %>
|
23
|
-
</div>
|
24
|
-
<% end -%>
|
25
|
-
|
26
|
-
<div class="button form-row">
|
27
|
-
<%= f.submit t('muck.users.sign_up_now') %>
|
28
|
-
</div>
|
29
|
-
|
30
|
-
<% end %>
|
4
|
+
<%= signup_form(@user) -%>
|
31
5
|
</div>
|
32
|
-
|
33
|
-
<% content_for :javascript do -%>
|
34
|
-
jQuery("#user_login").blur(function(){
|
35
|
-
jQuery.post("is_login_available",{ user_login:jQuery(this).val() } ,function(data){
|
36
|
-
jQuery("#username-availibility").html(data);
|
37
|
-
});
|
38
|
-
});
|
39
|
-
jQuery("#user_login").keydown(function() {
|
40
|
-
jQuery("#username-availibility").html('');
|
41
|
-
});
|
42
|
-
jQuery("#user_email").blur(function(){
|
43
|
-
jQuery.post("is_email_available",{ user_email:jQuery(this).val() } ,function(data){
|
44
|
-
jQuery("#email-availibility").html(data);
|
45
|
-
});
|
46
|
-
});
|
47
|
-
jQuery("#user_email").keydown(function() {
|
48
|
-
jQuery("#email-availibility").html('');
|
49
|
-
});
|
50
|
-
<% end -%>
|
6
|
+
<%= signup_form_javascript -%>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
<div id="welcome" class="common-content">
|
2
|
-
|
2
|
+
<%= output_errors('', {:class => 'help-box'}) %>
|
3
|
+
<%= t('muck.users.welcome_message') %>
|
3
4
|
<%= link_to 'View Your Account', user_path(current_user) %>
|
4
5
|
</div>
|
data/lib/muck_users.rb
CHANGED
@@ -5,5 +5,6 @@ ActionController::Base.send :include, ActionController::AuthenticApplication
|
|
5
5
|
ActiveRecord::Base.send :include, ActiveRecord::SecureMethods
|
6
6
|
ActiveRecord::Base.class_eval { include ActiveRecord::Acts::MuckUser }
|
7
7
|
ActiveRecord::Base.class_eval { include MuckUsers::Exceptions }
|
8
|
+
ActionController::Base.send :helper, MuckUsersHelper
|
8
9
|
|
9
10
|
I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', 'locales', '*.{rb,yml}') ]
|
data/locales/en.yml
CHANGED
@@ -11,6 +11,7 @@ en:
|
|
11
11
|
thanks_sign_up: Thanks for signing up!
|
12
12
|
thanks_sign_up_login: Thanks for signing up! You may login now
|
13
13
|
thanks_sign_up_check: "Your account has been created. Please check your e-mail for your account activation instructions!"
|
14
|
+
welcome_message: "Welcome to muck. This system provides the basic components to help you build your website."
|
14
15
|
username_not_available: Username not available
|
15
16
|
username_available: Username available
|
16
17
|
join_application_name: Join and get it done
|
@@ -20,7 +21,9 @@ en:
|
|
20
21
|
name: Name
|
21
22
|
email_address: Email Address
|
22
23
|
email_help: "Please use a valid, current e-mail address. We will never share or spam your e-mail address."
|
23
|
-
email_available:
|
24
|
+
email_available: "Email available"
|
25
|
+
email_invalid: "Invalid email"
|
26
|
+
email_empty: "Please enter an email address"
|
24
27
|
username: Username
|
25
28
|
username_help: "You can use between 6 and 20 characters. If the name you want isn't available try adding numbers or punctuation."
|
26
29
|
password: Password
|
@@ -28,15 +31,15 @@ en:
|
|
28
31
|
confirm_password: Confirm Password
|
29
32
|
password_confirmation_help: "To ensure that your password is correct please enter it again here."
|
30
33
|
sign_up_now: Sign-up Now
|
31
|
-
terms_and_service: By clicking 'Sign-up Now' you agree to comply with the {{tos_link_anchor}}Terms and Conditions{{link_end}}.
|
34
|
+
terms_and_service: "By clicking 'Sign-up Now' you agree to comply with the {{tos_link_anchor}}Terms and Conditions{{link_end}}."
|
32
35
|
my_dashboard: My Dashboard
|
33
36
|
update_user: Update your user information
|
34
37
|
problem_editing_account: There was a problem updating your information.
|
35
38
|
edit_profile: Edit Profile
|
36
39
|
update_profile: Update your profile
|
37
40
|
complete_profile: Complete Your Profile
|
38
|
-
email_not_available: Email already in use. {{reset_password_help}}
|
39
|
-
recover_password_prompt: (If you forgot your password recover it here)
|
41
|
+
email_not_available: "Email already in use. {{reset_password_help}}"
|
42
|
+
recover_password_prompt: "(If you forgot your password recover it here)"
|
40
43
|
welcome: Welcome
|
41
44
|
login_title: Log-in to your Account
|
42
45
|
reset_password: "Reset Password"
|
data/muck-users.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{muck-users}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.9"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Justin Ball"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-25}
|
10
10
|
s.description = %q{Easily add user signup, login and other features to your application}
|
11
11
|
s.email = %q{justinball@gmail.com}
|
12
12
|
s.extra_rdoc_files = [
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"app/controllers/muck/user_sessions_controller.rb",
|
25
25
|
"app/controllers/muck/username_request_controller.rb",
|
26
26
|
"app/controllers/muck/users_controller.rb",
|
27
|
+
"app/helpers/muck_users_helper.rb",
|
27
28
|
"app/models/permission.rb",
|
28
29
|
"app/models/role.rb",
|
29
30
|
"app/models/user_mailer.rb",
|
@@ -59,6 +60,9 @@ Gem::Specification.new do |s|
|
|
59
60
|
"app/views/user_mailer/welcome_notification.text.plain.erb",
|
60
61
|
"app/views/user_sessions/new.html.erb",
|
61
62
|
"app/views/username_request/new.html.erb",
|
63
|
+
"app/views/users/_recover_password_via_email_link.html.erb",
|
64
|
+
"app/views/users/_signup_form.html.erb",
|
65
|
+
"app/views/users/_signup_form_javascript.html.erb",
|
62
66
|
"app/views/users/_user.html.erb",
|
63
67
|
"app/views/users/activation_confirmation.html.erb",
|
64
68
|
"app/views/users/activation_instructions.html.erb",
|
@@ -112,6 +116,7 @@ Gem::Specification.new do |s|
|
|
112
116
|
"muck-users.gemspec",
|
113
117
|
"pkg/muck-users-0.1.6.gem",
|
114
118
|
"pkg/muck-users-0.1.7.gem",
|
119
|
+
"pkg/muck-users-0.1.8.gem",
|
115
120
|
"public/images/profile_default.jpg",
|
116
121
|
"rails/init.rb",
|
117
122
|
"rdoc/classes/ActionController.html",
|
Binary file
|
data/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Wed, 24 Jun 2009 22:20:51 -0600
|
data/rdoc/files/README_rdoc.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Tue Jun 23 09:37:16 -0600 2009</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -77,7 +77,7 @@ muck_engine as well as authlogic. Both gems should be installed
|
|
77
77
|
automatically when you install the muck_users engine.
|
78
78
|
</p>
|
79
79
|
<pre>
|
80
|
-
sudo gem install
|
80
|
+
sudo gem install muck-users
|
81
81
|
</pre>
|
82
82
|
<p>
|
83
83
|
Use search logic for searching users. Add this to environment.rb:
|
@@ -96,6 +96,30 @@ into your Rails project:
|
|
96
96
|
<pre>
|
97
97
|
ruby script/plugin install ssl_requirement
|
98
98
|
</pre>
|
99
|
+
<p>
|
100
|
+
If you used the muck template to create your rails application you will
|
101
|
+
have a global_config.yml file. If not then you will need to create a
|
102
|
+
global_config.yml file and then add the following to environment.rb right
|
103
|
+
above Rails::Initializer.run do |config|
|
104
|
+
</p>
|
105
|
+
<pre>
|
106
|
+
require 'ostruct'
|
107
|
+
require 'yaml'
|
108
|
+
::GlobalConfig = OpenStruct.new(YAML.load_file("#{RAILS_ROOT}/config/global_config.yml")[RAILS_ENV])
|
109
|
+
</pre>
|
110
|
+
<p>
|
111
|
+
Inside of global_config.yml add the following changing the emails to match
|
112
|
+
your application:
|
113
|
+
</p>
|
114
|
+
<pre>
|
115
|
+
default: &DEFAULT
|
116
|
+
|
117
|
+
# Sent in emails to users
|
118
|
+
application_name: 'Name of my application'
|
119
|
+
from_email: 'support@example.com'
|
120
|
+
support_email: 'support@example.com'
|
121
|
+
admin_email: 'admin@example.com'
|
122
|
+
</pre>
|
99
123
|
<h2>Usage</h2>
|
100
124
|
<p>
|
101
125
|
Be sure to add this route to your routes.rb file:
|
@@ -126,17 +150,13 @@ Example
|
|
126
150
|
<p>
|
127
151
|
After installing the engine just create a user model thus:
|
128
152
|
</p>
|
129
|
-
<p>
|
130
|
-
class User < ActiveRecord::Base
|
131
|
-
</p>
|
132
153
|
<pre>
|
133
|
-
|
134
|
-
|
154
|
+
class User < ActiveRecord::Base
|
155
|
+
acts_as_authentic
|
156
|
+
acts_as_muck_user
|
157
|
+
end
|
135
158
|
</pre>
|
136
159
|
<p>
|
137
|
-
end
|
138
|
-
</p>
|
139
|
-
<p>
|
140
160
|
Then you will be able to go to: http//:localhost:3000/login
|
141
161
|
http//:localhost:3000/signup
|
142
162
|
</p>
|
@@ -23,7 +23,7 @@ form fieldset input[type="text"],form fieldset input[type="password"]{width:500p
|
|
23
23
|
.medium{width:300px;height:300px;}
|
24
24
|
|
25
25
|
/* tips */
|
26
|
-
.availability{color:#b61e12;}
|
26
|
+
.availability{color:#b61e12;position:absolute;}
|
27
27
|
.hidden-tips{display:none;}
|
28
28
|
.required-tip{color:#555555;font-size:1.2em;margin:0pt;font-weight:bolder;height:0px;}
|
29
29
|
.tip{position:absolute;z-index:100;border:2px solid #CCCCCC;background-color:#fff;width:400px;}
|
@@ -25,6 +25,10 @@ class Muck::UsersControllerTest < ActionController::TestCase
|
|
25
25
|
should "activate user" do
|
26
26
|
assert assigns(:user).active? == true, "user was not activated"
|
27
27
|
end
|
28
|
+
should "be logged in" do
|
29
|
+
user_session = UserSession.find
|
30
|
+
assert user_session, "user is not logged in"
|
31
|
+
end
|
28
32
|
end
|
29
33
|
context "on POST to :create with bad login (space in login name)" do
|
30
34
|
setup do
|
@@ -229,6 +233,46 @@ class Muck::UsersControllerTest < ActionController::TestCase
|
|
229
233
|
end
|
230
234
|
end
|
231
235
|
|
236
|
+
context "on GET to is_email_available" do
|
237
|
+
context "no params" do
|
238
|
+
setup do
|
239
|
+
get :is_email_available
|
240
|
+
end
|
241
|
+
should_respond_with :success
|
242
|
+
should_render_text ""
|
243
|
+
end
|
244
|
+
context "empty email" do
|
245
|
+
setup do
|
246
|
+
get :is_email_available, :user_email => ''
|
247
|
+
end
|
248
|
+
should_respond_with :success
|
249
|
+
should_render_text I18n.t('muck.users.email_empty')
|
250
|
+
end
|
251
|
+
context "valid email" do
|
252
|
+
setup do
|
253
|
+
get :is_email_available, :user_email => 'testdude1945@example.com'
|
254
|
+
end
|
255
|
+
should_respond_with :success
|
256
|
+
should_render_text I18n.t('muck.users.email_available')
|
257
|
+
end
|
258
|
+
context "invalid email" do
|
259
|
+
setup do
|
260
|
+
get :is_email_available, :user_email => 'testdude1945@com'
|
261
|
+
end
|
262
|
+
should_respond_with :success
|
263
|
+
should_render_text I18n.t('muck.users.email_invalid')
|
264
|
+
end
|
265
|
+
context "email not available" do
|
266
|
+
setup do
|
267
|
+
@user = Factory(:user)
|
268
|
+
get :is_email_available, :user_email => @user.email
|
269
|
+
end
|
270
|
+
should_respond_with :success
|
271
|
+
should_render_partial_text I18n.t('muck.users.email_not_available', :reset_password_help => '')
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
|
232
276
|
def put_update_user(user, options = {})
|
233
277
|
put :update,
|
234
278
|
:id => user.id,
|
@@ -40,6 +40,20 @@ module MuckControllerMacros
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
# make sure the response body matches the text exactly
|
44
|
+
def should_render_text(text)
|
45
|
+
should "render text #{text}" do
|
46
|
+
assert_equal text, @response.body
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# look for the given text in the response body
|
51
|
+
def should_render_partial_text(text)
|
52
|
+
should "contain text #{text}" do
|
53
|
+
assert @response.body.include?(text), "Response did not contain the text '#{text}'"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
43
57
|
end
|
44
58
|
|
45
59
|
ActionController::TestCase.extend(MuckControllerMacros)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muck-users
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-25 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- app/controllers/muck/user_sessions_controller.rb
|
73
73
|
- app/controllers/muck/username_request_controller.rb
|
74
74
|
- app/controllers/muck/users_controller.rb
|
75
|
+
- app/helpers/muck_users_helper.rb
|
75
76
|
- app/models/permission.rb
|
76
77
|
- app/models/role.rb
|
77
78
|
- app/models/user_mailer.rb
|
@@ -107,6 +108,9 @@ files:
|
|
107
108
|
- app/views/user_mailer/welcome_notification.text.plain.erb
|
108
109
|
- app/views/user_sessions/new.html.erb
|
109
110
|
- app/views/username_request/new.html.erb
|
111
|
+
- app/views/users/_recover_password_via_email_link.html.erb
|
112
|
+
- app/views/users/_signup_form.html.erb
|
113
|
+
- app/views/users/_signup_form_javascript.html.erb
|
110
114
|
- app/views/users/_user.html.erb
|
111
115
|
- app/views/users/activation_confirmation.html.erb
|
112
116
|
- app/views/users/activation_instructions.html.erb
|
@@ -160,6 +164,7 @@ files:
|
|
160
164
|
- muck-users.gemspec
|
161
165
|
- pkg/muck-users-0.1.6.gem
|
162
166
|
- pkg/muck-users-0.1.7.gem
|
167
|
+
- pkg/muck-users-0.1.8.gem
|
163
168
|
- public/images/profile_default.jpg
|
164
169
|
- rails/init.rb
|
165
170
|
- rdoc/classes/ActionController.html
|