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 | 5 | class User < ActiveRecord::Base |
6 | 6 | |
7 | 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 | 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 | 12 | # Virtual attribute for the unencrypted password |
15 | 13 | attr_accessor :password |
16 | 14 | |
... | ... | @@ -41,12 +39,10 @@ class User < ActiveRecord::Base |
41 | 39 | self.class.encrypt(password, salt) |
42 | 40 | end |
43 | 41 | |
44 | - # returns +true+ if the +password+ is the correct one for the user | |
45 | 42 | def authenticated?(password) |
46 | 43 | crypted_password == encrypt(password) |
47 | 44 | end |
48 | 45 | |
49 | - # tells if the user has an authentication cookie | |
50 | 46 | def remember_token? |
51 | 47 | remember_token_expires_at && Time.now.utc < remember_token_expires_at |
52 | 48 | end |
... | ... | @@ -58,7 +54,6 @@ class User < ActiveRecord::Base |
58 | 54 | save(false) |
59 | 55 | end |
60 | 56 | |
61 | - # throws the auth cookie away | |
62 | 57 | def forget_me |
63 | 58 | self.remember_token_expires_at = nil |
64 | 59 | self.remember_token = nil |
... | ... | @@ -90,9 +85,7 @@ class User < ActiveRecord::Base |
90 | 85 | self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? |
91 | 86 | self.crypted_password = encrypt(password) |
92 | 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 | 89 | def password_required? |
97 | 90 | crypted_password.blank? || !password.blank? |
98 | 91 | end | ... | ... |
test/fixtures/profiles.yml
... | ... | @@ -4,8 +4,7 @@ johndoe: |
4 | 4 | name: 'John Doe' |
5 | 5 | identifier: johndoe |
6 | 6 | virtual_community_id: 1 |
7 | - profile_owner_id: 1 | |
8 | - profile_owner_type: 'User' | |
7 | + user_id: 1 | |
9 | 8 | flexible_template_template: 'default' |
10 | 9 | flexible_template_icon_theme: 'default' |
11 | 10 | flexible_template_theme: 'default' |
... | ... | @@ -14,8 +13,7 @@ joerandomhacker: |
14 | 13 | name: 'Joe Random Hacker' |
15 | 14 | identifier: joerandomhacker |
16 | 15 | virtual_community_id: 1 |
17 | - profile_owner_id: 2 | |
18 | - profile_owner_type: 'User' | |
16 | + user_id: 2 | |
19 | 17 | flexible_template_template: 'simple' |
20 | 18 | flexible_template_icon_theme: 'simple' |
21 | 19 | flexible_template_theme: 'simple' | ... | ... |