Commit 04bc7077a280978af99562180935cba0e18ec73f
1 parent
4b75bdee
Exists in
master
and in
28 other branches
ActionItem6: fixtures fixed to match new model hierachy
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@199 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
6 additions
and
15 deletions
Show diff stats
app/models/affiliation.rb
app/models/user.rb
@@ -5,12 +5,10 @@ require 'digest/sha1' | @@ -5,12 +5,10 @@ require 'digest/sha1' | ||
5 | class User < ActiveRecord::Base | 5 | class User < ActiveRecord::Base |
6 | 6 | ||
7 | after_create do |user| | 7 | after_create do |user| |
8 | - Person.create!(:identifier => user.login, :profile_owner_id => user.id, :profile_owner_type => 'User') | 8 | + Person.create!(:identifier => user.login, :user_id => user.id) |
9 | end | 9 | end |
10 | 10 | ||
11 | - has_one :personal_profile, :class_name => 'Profile', :as => :profile_owner | ||
12 | - has_many :affiliations | ||
13 | - has_many :profiles, :through => :affiliations | 11 | + has_one :person |
14 | # Virtual attribute for the unencrypted password | 12 | # Virtual attribute for the unencrypted password |
15 | attr_accessor :password | 13 | attr_accessor :password |
16 | 14 | ||
@@ -41,12 +39,10 @@ class User < ActiveRecord::Base | @@ -41,12 +39,10 @@ class User < ActiveRecord::Base | ||
41 | self.class.encrypt(password, salt) | 39 | self.class.encrypt(password, salt) |
42 | end | 40 | end |
43 | 41 | ||
44 | - # returns +true+ if the +password+ is the correct one for the user | ||
45 | def authenticated?(password) | 42 | def authenticated?(password) |
46 | crypted_password == encrypt(password) | 43 | crypted_password == encrypt(password) |
47 | end | 44 | end |
48 | 45 | ||
49 | - # tells if the user has an authentication cookie | ||
50 | def remember_token? | 46 | def remember_token? |
51 | remember_token_expires_at && Time.now.utc < remember_token_expires_at | 47 | remember_token_expires_at && Time.now.utc < remember_token_expires_at |
52 | end | 48 | end |
@@ -58,7 +54,6 @@ class User < ActiveRecord::Base | @@ -58,7 +54,6 @@ class User < ActiveRecord::Base | ||
58 | save(false) | 54 | save(false) |
59 | end | 55 | end |
60 | 56 | ||
61 | - # throws the auth cookie away | ||
62 | def forget_me | 57 | def forget_me |
63 | self.remember_token_expires_at = nil | 58 | self.remember_token_expires_at = nil |
64 | self.remember_token = nil | 59 | self.remember_token = nil |
@@ -90,9 +85,7 @@ class User < ActiveRecord::Base | @@ -90,9 +85,7 @@ class User < ActiveRecord::Base | ||
90 | self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? | 85 | self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? |
91 | self.crypted_password = encrypt(password) | 86 | self.crypted_password = encrypt(password) |
92 | end | 87 | end |
93 | - | ||
94 | - # auxiliary method to test if a password must be supplied (i.e. returns | ||
95 | - # +true+ when creating an user without supplying a password) | 88 | + |
96 | def password_required? | 89 | def password_required? |
97 | crypted_password.blank? || !password.blank? | 90 | crypted_password.blank? || !password.blank? |
98 | end | 91 | end |
test/fixtures/profiles.yml
@@ -4,8 +4,7 @@ johndoe: | @@ -4,8 +4,7 @@ johndoe: | ||
4 | name: 'John Doe' | 4 | name: 'John Doe' |
5 | identifier: johndoe | 5 | identifier: johndoe |
6 | virtual_community_id: 1 | 6 | virtual_community_id: 1 |
7 | - profile_owner_id: 1 | ||
8 | - profile_owner_type: 'User' | 7 | + user_id: 1 |
9 | flexible_template_template: 'default' | 8 | flexible_template_template: 'default' |
10 | flexible_template_icon_theme: 'default' | 9 | flexible_template_icon_theme: 'default' |
11 | flexible_template_theme: 'default' | 10 | flexible_template_theme: 'default' |
@@ -14,8 +13,7 @@ joerandomhacker: | @@ -14,8 +13,7 @@ joerandomhacker: | ||
14 | name: 'Joe Random Hacker' | 13 | name: 'Joe Random Hacker' |
15 | identifier: joerandomhacker | 14 | identifier: joerandomhacker |
16 | virtual_community_id: 1 | 15 | virtual_community_id: 1 |
17 | - profile_owner_id: 2 | ||
18 | - profile_owner_type: 'User' | 16 | + user_id: 2 |
19 | flexible_template_template: 'simple' | 17 | flexible_template_template: 'simple' |
20 | flexible_template_icon_theme: 'simple' | 18 | flexible_template_icon_theme: 'simple' |
21 | flexible_template_theme: 'simple' | 19 | flexible_template_theme: 'simple' |