Commit 5c9d49f032ae891922881cb26cf31ca40b85db07
Committed by
Antonio Terceiro
1 parent
d58a5daa
Exists in
master
and in
28 other branches
Removing useless code
last_lang was not being actually used anywhere.
Showing
4 changed files
with
3 additions
and
49 deletions
Show diff stats
app/controllers/public/account_controller.rb
@@ -18,7 +18,6 @@ class AccountController < ApplicationController | @@ -18,7 +18,6 @@ class AccountController < ApplicationController | ||
18 | return unless request.post? | 18 | return unless request.post? |
19 | self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) if params[:user] | 19 | self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) if params[:user] |
20 | if logged_in? | 20 | if logged_in? |
21 | - self.current_user.person.update_attribute(:last_lang, cookies[:lang]) | ||
22 | if params[:remember_me] == "1" | 21 | if params[:remember_me] == "1" |
23 | self.current_user.remember_me | 22 | self.current_user.remember_me |
24 | cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } | 23 | cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } |
@@ -95,7 +94,6 @@ class AccountController < ApplicationController | @@ -95,7 +94,6 @@ class AccountController < ApplicationController | ||
95 | # action to perform logout from the application | 94 | # action to perform logout from the application |
96 | def logout | 95 | def logout |
97 | if logged_in? | 96 | if logged_in? |
98 | - self.current_user.person.update_attribute(:last_lang, cookies[:lang]) | ||
99 | self.current_user.forget_me | 97 | self.current_user.forget_me |
100 | end | 98 | end |
101 | cookies.delete :auth_token | 99 | cookies.delete :auth_token |
app/models/person.rb
@@ -12,15 +12,6 @@ class Person < Profile | @@ -12,15 +12,6 @@ class Person < Profile | ||
12 | Friendship.find(:all, :conditions => { :friend_id => person.id}).each { |friendship| friendship.destroy } | 12 | Friendship.find(:all, :conditions => { :friend_id => person.id}).each { |friendship| friendship.destroy } |
13 | end | 13 | end |
14 | 14 | ||
15 | - settings_items :last_lang, :type => :string | ||
16 | - def last_lang | ||
17 | - if self.data[:last_lang].nil? or self.data[:last_lang].empty? | ||
18 | - Noosfero.default_locale | ||
19 | - else | ||
20 | - self.data[:last_lang] | ||
21 | - end | ||
22 | - end | ||
23 | - | ||
24 | def suggested_friend_groups | 15 | def suggested_friend_groups |
25 | (friend_groups.compact + [ _('friends'), _('work'), _('school'), _('family') ]).map {|i| i if !i.empty?}.compact.uniq | 16 | (friend_groups.compact + [ _('friends'), _('work'), _('school'), _('family') ]).map {|i| i if !i.empty?}.compact.uniq |
26 | end | 17 | end |
test/functional/account_controller_test.rb
@@ -290,27 +290,6 @@ class AccountControllerTest < Test::Unit::TestCase | @@ -290,27 +290,6 @@ class AccountControllerTest < Test::Unit::TestCase | ||
290 | assert_redirected_to :controller => 'profile_editor' | 290 | assert_redirected_to :controller => 'profile_editor' |
291 | end | 291 | end |
292 | 292 | ||
293 | - should 'save last lang after logout' do | ||
294 | - user = create_user('save_lang').person | ||
295 | - assert user.update_attribute(:last_lang, 'unknow') | ||
296 | - assert_equal 'unknow', user.last_lang | ||
297 | - login_as user.identifier | ||
298 | - get :logout | ||
299 | - user.reload | ||
300 | - assert_not_equal 'unknow', user.last_lang | ||
301 | - assert_equal @response.cookies[:lang], user.last_lang | ||
302 | - end | ||
303 | - | ||
304 | - should 'save last lang after login' do | ||
305 | - user = create_user('save_lang').person | ||
306 | - assert user.update_attribute(:last_lang, 'unknow') | ||
307 | - assert_equal 'unknow', user.last_lang | ||
308 | - | ||
309 | - post :login, :user => {:login => 'save_lang', :password => 'save_lang'} | ||
310 | - | ||
311 | - assert_not_equal 'unknow', Person['save_lang'].last_lang | ||
312 | - end | ||
313 | - | ||
314 | should 'signup from wizard' do | 293 | should 'signup from wizard' do |
315 | assert_difference User, :count do | 294 | assert_difference User, :count do |
316 | post :signup, :user => { :login => 'mylogin', :password => 'mypassword', :password_confirmation => 'mypassword', :email => 'mylogin@example.com' }, :wizard => true | 295 | post :signup, :user => { :login => 'mylogin', :password => 'mypassword', :password_confirmation => 'mypassword', :email => 'mylogin@example.com' }, :wizard => true |
test/unit/person_test.rb
@@ -44,13 +44,10 @@ class PersonTest < Test::Unit::TestCase | @@ -44,13 +44,10 @@ class PersonTest < Test::Unit::TestCase | ||
44 | assert p.community_memberships.include?(c), "Community should add a new member" | 44 | assert p.community_memberships.include?(c), "Community should add a new member" |
45 | end | 45 | end |
46 | 46 | ||
47 | - should 'can have user' do | 47 | + should 'be associated with a user' do |
48 | u = User.new(:login => 'john', :email => 'john@doe.org', :password => 'dhoe', :password_confirmation => 'dhoe') | 48 | u = User.new(:login => 'john', :email => 'john@doe.org', :password => 'dhoe', :password_confirmation => 'dhoe') |
49 | - p = Person.new(person_data.merge(:name => 'John', :identifier => 'john')) | ||
50 | - u.person = p | ||
51 | - assert u.save | ||
52 | - assert_kind_of User, p.user | ||
53 | - assert_equal 'John', u.person.name | 49 | + u.save! |
50 | + assert_equal u, Person['john'].user | ||
54 | end | 51 | end |
55 | 52 | ||
56 | should 'only one person per user' do | 53 | should 'only one person per user' do |
@@ -414,17 +411,6 @@ class PersonTest < Test::Unit::TestCase | @@ -414,17 +411,6 @@ class PersonTest < Test::Unit::TestCase | ||
414 | assert_equal p.pending_tasks_for_organization(c), c.tasks | 411 | assert_equal p.pending_tasks_for_organization(c), c.tasks |
415 | end | 412 | end |
416 | 413 | ||
417 | - should 'has default locale as last lang' do | ||
418 | - p = create_user('user_lang_test').person | ||
419 | - assert_equal Noosfero.default_locale, p.last_lang | ||
420 | - end | ||
421 | - | ||
422 | - should 'be able to change last lang' do | ||
423 | - p = create_user('user_lang_test').person | ||
424 | - assert p.update_attribute(:last_lang, 'pt_BR') | ||
425 | - assert_equal 'pt_BR', Person['user_lang_test'].last_lang | ||
426 | - end | ||
427 | - | ||
428 | should 'return active_person_fields' do | 414 | should 'return active_person_fields' do |
429 | e = Environment.default | 415 | e = Environment.default |
430 | e.expects(:active_person_fields).returns(['cell_phone', 'comercial_phone']).at_least_once | 416 | e.expects(:active_person_fields).returns(['cell_phone', 'comercial_phone']).at_least_once |