muck-users 0.2.18 → 0.2.19

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.18
1
+ 0.2.19
@@ -145,7 +145,7 @@ module ActionController
145
145
  end
146
146
  end
147
147
 
148
- def permission_denied
148
+ def permission_denied
149
149
  respond_to do |format|
150
150
  format.html do
151
151
  domain_name = GlobalConfig.application_url
@@ -214,6 +214,27 @@ module ActionController
214
214
  # end
215
215
  # end
216
216
 
217
+ # Used to get a user based on parameters
218
+ def get_user
219
+ return nil if !logged_in?
220
+ if is_admin?
221
+ @user ||= User.find(params[:user_id]) rescue nil
222
+ @user ||= User.find(params[:id]) rescue nil
223
+ @user ||= current_user
224
+ else
225
+ @user = current_user
226
+ end
227
+ end
228
+
229
+ # Try to get a user. If no user is found then call permission_denied
230
+ def get_user_deny
231
+ @user = get_user
232
+ if !@user
233
+ flash[:notice] = "There was a problem finding your user information. Please try again."
234
+ permission_denied
235
+ end
236
+ end
237
+
217
238
  end
218
239
  end
219
240
  end
data/muck-users.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-users}
8
- s.version = "0.2.18"
8
+ s.version = "0.2.19"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball", "Joel Duffin"]
12
- s.date = %q{2009-11-30}
12
+ s.date = %q{2009-12-16}
13
13
  s.description = %q{Easily add user signup, login and other features to your application}
14
14
  s.email = %q{justin@tatemae.com}
15
15
  s.extra_rdoc_files = [
@@ -925,3 +925,4 @@ Gem::Specification.new do |s|
925
925
  s.add_dependency(%q<friendly_id>, [">= 0"])
926
926
  end
927
927
  end
928
+
@@ -1,3 +1,32 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: users
4
+ #
5
+ # id :integer not null, primary key
6
+ # login :string(255)
7
+ # email :string(255)
8
+ # first_name :string(255)
9
+ # last_name :string(255)
10
+ # crypted_password :string(255)
11
+ # password_salt :string(255)
12
+ # persistence_token :string(255)
13
+ # single_access_token :string(255)
14
+ # perishable_token :string(255)
15
+ # login_count :integer default(0), not null
16
+ # failed_login_count :integer default(0), not null
17
+ # last_request_at :datetime
18
+ # last_login_at :datetime
19
+ # current_login_at :datetime
20
+ # current_login_ip :string(255)
21
+ # last_login_ip :string(255)
22
+ # terms_of_service :boolean not null
23
+ # time_zone :string(255) default("UTC")
24
+ # disabled_at :datetime
25
+ # activated_at :datetime
26
+ # created_at :datetime
27
+ # updated_at :datetime
28
+ #
29
+
1
30
  class User < ActiveRecord::Base
2
31
  acts_as_authentic do |c|
3
32
  c.crypto_provider = Authlogic::CryptoProviders::BCrypt
@@ -1,3 +1,32 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: users
4
+ #
5
+ # id :integer not null, primary key
6
+ # login :string(255)
7
+ # email :string(255)
8
+ # first_name :string(255)
9
+ # last_name :string(255)
10
+ # crypted_password :string(255)
11
+ # password_salt :string(255)
12
+ # persistence_token :string(255)
13
+ # single_access_token :string(255)
14
+ # perishable_token :string(255)
15
+ # login_count :integer default(0), not null
16
+ # failed_login_count :integer default(0), not null
17
+ # last_request_at :datetime
18
+ # last_login_at :datetime
19
+ # current_login_at :datetime
20
+ # current_login_ip :string(255)
21
+ # last_login_ip :string(255)
22
+ # terms_of_service :boolean not null
23
+ # time_zone :string(255) default("UTC")
24
+ # disabled_at :datetime
25
+ # activated_at :datetime
26
+ # created_at :datetime
27
+ # updated_at :datetime
28
+ #
29
+
1
30
  require File.dirname(__FILE__) + '/../test_helper'
2
31
 
3
32
  class UserTest < ActiveSupport::TestCase
@@ -6,10 +35,8 @@ class UserTest < ActiveSupport::TestCase
6
35
  should_have_many :permissions
7
36
  should_have_many :roles
8
37
 
9
- should_have_named_scope :by_newest
10
- should_have_named_scope :active
11
- should_have_named_scope :inactive
12
- should_have_named_scope :recent
38
+ should_scope_by_newest
39
+ should_scope_recent
13
40
 
14
41
  should_ensure_length_in_range :email, 6..100 #, :short_message => 'does not look like a valid email address.', :long_message => 'does not look like a valid email address.'
15
42
  should_allow_values_for :email, 'a@x.com', 'de.veloper@example.com'
@@ -22,6 +49,29 @@ class UserTest < ActiveSupport::TestCase
22
49
  should_not_allow_mass_assignment_of :crypted_password, :password_salt, :persistence_token, :single_access_token, :perishable_token, :login_count,
23
50
  :failed_login_count, :last_request_at, :last_login_at, :current_login_at, :current_login_ip, :last_login_ip,
24
51
  :terms_of_service, :time_zone, :disabled_at, :activated_at, :created_at, :updated_at
52
+
53
+ context "named scopes" do
54
+ setup do
55
+ @active_user = Factory(:user, :activated_at => DateTime.now)
56
+ @inactive_user = Factory(:user, :activated_at => nil)
57
+ end
58
+ context "active" do
59
+ should "find active user" do
60
+ assert User.active.include?(@active_user)
61
+ end
62
+ should "not find inactive user" do
63
+ assert !User.active.include?(@inactive_user)
64
+ end
65
+ end
66
+ context "inactive" do
67
+ should "find inactive user" do
68
+ assert User.inactive.include?(@inactive_user)
69
+ end
70
+ should "not find active user" do
71
+ assert !User.inactive.include?(@active_user)
72
+ end
73
+ end
74
+ end
25
75
  end
26
76
 
27
77
  context "search" 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.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Ball
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-30 00:00:00 -07:00
13
+ date: 2009-12-16 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency