muck-users 0.2.5 → 0.2.6

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/.gitignore CHANGED
@@ -26,3 +26,4 @@ coverage
26
26
  rdoc
27
27
  pkg
28
28
  pkg/*
29
+ log/*
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -29,15 +29,4 @@ class Muck::UsernameRequestController < ApplicationController
29
29
  end
30
30
  end
31
31
 
32
- private
33
-
34
- def permission_denied
35
- respond_to do |format|
36
- format.html do
37
- flash[:notice] = t('muck.users.already_logged_in')
38
- redirect_to account_url
39
- end
40
- end
41
- end
42
-
43
32
  end
@@ -140,17 +140,15 @@ module ActionController
140
140
  def permission_denied
141
141
  respond_to do |format|
142
142
  format.html do
143
- #Put your domain name here ex. http://www.example.com
144
- domain_name = GlobalConfig.application_base_url
143
+ domain_name = GlobalConfig.application_url
144
+ raise t('muck.users.application_base_url_not_set') if domain_name.blank?
145
145
  http_referer = session[:refer_to]
146
146
  if http_referer.nil?
147
147
  store_referer
148
148
  http_referer = ( session[:refer_to] || domain_name )
149
149
  end
150
150
  flash[:error] = I18n.t('muck.users.permission_denied')
151
- #The [0..20] represents the 21 characters in http://localhost:3000
152
- #You have to set that to the number of characters in your domain name
153
- if http_referer[0..domain_name.length] != domain_name
151
+ if http_referer[0..domain_name.length] != domain_name
154
152
  session[:refer_to] = nil
155
153
  redirect_to root_path
156
154
  else
@@ -144,6 +144,7 @@ module ActiveRecord
144
144
  options[:except] << :email << :crypted_password << :salt << :remember_token << :remember_token_expires_at << :activation_code
145
145
  options[:except] << :activated_at << :password_reset_code << :enabled << :terms_of_service << :can_send_messages << :identity_url
146
146
  options[:except] << :tmp_password << :protected_profile << :public_profile
147
+ options[:except] << :password_salt << :perishable_token << :persistence_token << :single_access_token
147
148
  super
148
149
  end
149
150
 
data/locales/en.yml CHANGED
@@ -113,6 +113,7 @@ en:
113
113
  delete_this_user: "Delete this user."
114
114
  sign_up: Sign up
115
115
  email_recover_prompt: "Please provide the email you signed up with to recover your password."
116
+ application_base_url_not_set: "Please set application_base_url in global_config.yml"
116
117
  admin:
117
118
  unactivated_users: "There are {{count}} unactivated users"
118
119
  activate_all_inactive_users: "Activate All Inactive Users"
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.2.5"
5
+ s.version = "0.2.6"
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-07-24}
9
+ s.date = %q{2009-08-08}
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 = [
@@ -852,6 +852,7 @@ Gem::Specification.new do |s|
852
852
  "test/rails_root/test/unit/.keep",
853
853
  "test/rails_root/test/unit/permission_test.rb",
854
854
  "test/rails_root/test/unit/role_test.rb",
855
+ "test/rails_root/test/unit/secure_methods_test.rb",
855
856
  "test/rails_root/test/unit/user_mailer_test.rb",
856
857
  "test/rails_root/test/unit/user_test.rb",
857
858
  "test/rails_root/vendor/plugins/ssl_requirement/README",
@@ -914,6 +915,7 @@ Gem::Specification.new do |s|
914
915
  "test/rails_root/test/test_helper.rb",
915
916
  "test/rails_root/test/unit/permission_test.rb",
916
917
  "test/rails_root/test/unit/role_test.rb",
918
+ "test/rails_root/test/unit/secure_methods_test.rb",
917
919
  "test/rails_root/test/unit/user_mailer_test.rb",
918
920
  "test/rails_root/test/unit/user_test.rb",
919
921
  "test/rails_root/vendor/plugins/ssl_requirement/lib/ssl_requirement.rb",
@@ -4,7 +4,17 @@ class User < ActiveRecord::Base
4
4
  end
5
5
  acts_as_muck_user
6
6
 
7
- def display_name
8
- 'test guy'
7
+ # these are just for testing
8
+ def creator_id
9
+ self.id
9
10
  end
10
- end
11
+
12
+ def user_id
13
+ self.id
14
+ end
15
+
16
+ def shared_by_id
17
+ self.id
18
+ end
19
+
20
+ end
@@ -4,4 +4,36 @@ class Muck::UsernameRequestControllerTest < ActionController::TestCase
4
4
 
5
5
  tests Muck::UsernameRequestController
6
6
 
7
+ context "username request controller" do
8
+ setup do
9
+ @user = Factory(:user)
10
+ end
11
+ context "get new" do
12
+ setup do
13
+ get :new
14
+ end
15
+ should_respond_with :success
16
+ should_render_template :new
17
+ end
18
+ context "find user using email and send email message" do
19
+ setup do
20
+ post :create, :request_username => { :email => @user.email }
21
+ end
22
+ should "send username" do
23
+ assert_sent_email do |email|
24
+ email.to.include?(@user.email)
25
+ end
26
+ end
27
+ should_redirect_to("login") { login_path }
28
+ end
29
+ context "bad email - fail to send username" do
30
+ setup do
31
+ post :create, :request_username => { :email => 'quentin@bad_email_example.com' }
32
+ end
33
+ should_respond_with :success
34
+ should_render_template :new
35
+ end
36
+
37
+ end
38
+
7
39
  end
@@ -44,6 +44,20 @@ module MuckControllerMacros
44
44
  end
45
45
  end
46
46
 
47
+ # make sure the response body matches the text exactly
48
+ def should_render_text(text)
49
+ should "render text #{text}" do
50
+ assert_equal text, @response.body
51
+ end
52
+ end
53
+
54
+ # look for the given text in the response body
55
+ def should_render_partial_text(text)
56
+ should "contain text #{text}" do
57
+ assert @response.body.include?(text), "Response did not contain the text '#{text}'"
58
+ end
59
+ end
60
+
47
61
  end
48
62
 
49
63
  ActionController::TestCase.extend(MuckControllerMacros)
@@ -35,4 +35,17 @@ class ActiveSupport::TestCase
35
35
  def ensure_flash(val)
36
36
  assert_contains flash.values, val, ", Flash: #{flash.inspect}"
37
37
  end
38
- end
38
+
39
+ # Add more helper methods to be used for testing xml
40
+ def assert_xml_tag(xml, conditions)
41
+ doc = HTML::Document.new(xml)
42
+ assert doc.find(conditions),
43
+ "expected tag, but no tag found matching #{conditions.inspect} in:\n#{xml.inspect}"
44
+ end
45
+
46
+ def assert_no_xml_tag(xml, conditions)
47
+ doc = HTML::Document.new(xml)
48
+ assert !doc.find(conditions),
49
+ "expected no tag, but found tag matching #{conditions.inspect} in:\n#{xml.inspect}"
50
+ end
51
+ end
@@ -0,0 +1,55 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class SecureMethodsTest < ActiveSupport::TestCase
4
+
5
+ context "check creator method" do
6
+ setup do
7
+ @user = Factory(:user)
8
+ @another_user = Factory(:user)
9
+ end
10
+ should "return true if creators are equal" do
11
+ assert @user.send(:check_creator, @user)
12
+ end
13
+ should "return false if creators are different" do
14
+ assert_equal false, @another_user.send(:check_creator, @user)
15
+ end
16
+ end
17
+ context "check user method" do
18
+ setup do
19
+ @user = Factory(:user)
20
+ @another_user = Factory(:user)
21
+ end
22
+ should "return true if users are equal" do
23
+ assert @user.send(:check_user, @user)
24
+ end
25
+ should "return false if users are different" do
26
+ assert_equal false, @another_user.send(:check_user, @user)
27
+ end
28
+ end
29
+ context "check sharer method" do
30
+ setup do
31
+ @user = Factory(:user)
32
+ @another_user = Factory(:user)
33
+ end
34
+ should "return true if sharers are equal" do
35
+ assert @user.send(:check_sharer, @user)
36
+ end
37
+ should "return false if sharers are different" do
38
+ assert_equal false, @another_user.send(:check_sharer, @user)
39
+ end
40
+ end
41
+ context "check method" do
42
+ setup do
43
+ @user = Factory(:user)
44
+ @admin = Factory(:user)
45
+ end
46
+ should " return false when user is nil" do
47
+ assert_equal false, @user.send(:check, nil, :user_id)
48
+ end
49
+ should "return true when user is different but an admin" do
50
+ @admin.add_to_role('administrator')
51
+ @admin.reload
52
+ assert @user.send(:check, @admin, :user_id)
53
+ end
54
+ end
55
+ end
@@ -47,6 +47,27 @@ class UserTest < ActiveSupport::TestCase
47
47
  assert user.full_name == 'quent smith'
48
48
  end
49
49
  end
50
+
51
+ should "show display name if first and last name is blank" do
52
+ @del_user = User.new
53
+ @del_user.destroy
54
+ assert_equal @del_user.display_name, @del_user.full_name
55
+ end
56
+
57
+ should "not display sensitive information when converted to xml" do
58
+ @user = Factory(:user)
59
+ assert @user.to_xml
60
+ assert_xml_tag( @user.to_xml, :tag => "user" )
61
+ assert_xml_tag( @user.to_xml, :tag => "created-at", :parent => { :tag => "user"} )
62
+ assert_xml_tag( @user.to_xml, :tag => "first-name", :parent => { :tag => "user"} )
63
+ assert_xml_tag( @user.to_xml, :tag => "last-name", :parent => { :tag => "user"} )
64
+ assert_no_xml_tag( @user.to_xml, :tag => "crypted_password" )
65
+ end
66
+
67
+ should "return the first_name or display_name" do
68
+ @user = Factory(:user)
69
+ assert_equal @user.short_name, CGI::escapeHTML(@user.first_name) || @user.display_name
70
+ end
50
71
 
51
72
  should "Create a new user and lowercase the login" do
52
73
  assert_difference 'User.count' do
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.2.5
4
+ version: 0.2.6
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-07-24 00:00:00 -06:00
12
+ date: 2009-08-08 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -910,6 +910,7 @@ files:
910
910
  - test/rails_root/test/unit/.keep
911
911
  - test/rails_root/test/unit/permission_test.rb
912
912
  - test/rails_root/test/unit/role_test.rb
913
+ - test/rails_root/test/unit/secure_methods_test.rb
913
914
  - test/rails_root/test/unit/user_mailer_test.rb
914
915
  - test/rails_root/test/unit/user_test.rb
915
916
  - test/rails_root/vendor/plugins/ssl_requirement/README
@@ -990,6 +991,7 @@ test_files:
990
991
  - test/rails_root/test/test_helper.rb
991
992
  - test/rails_root/test/unit/permission_test.rb
992
993
  - test/rails_root/test/unit/role_test.rb
994
+ - test/rails_root/test/unit/secure_methods_test.rb
993
995
  - test/rails_root/test/unit/user_mailer_test.rb
994
996
  - test/rails_root/test/unit/user_test.rb
995
997
  - test/rails_root/vendor/plugins/ssl_requirement/lib/ssl_requirement.rb