Commit 5c9d49f032ae891922881cb26cf31ca40b85db07
Committed by
Antonio Terceiro
1 parent
d58a5daa
Exists in
master
and in
8 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 | 18 | return unless request.post? |
19 | 19 | self.current_user = User.authenticate(params[:user][:login], params[:user][:password]) if params[:user] |
20 | 20 | if logged_in? |
21 | - self.current_user.person.update_attribute(:last_lang, cookies[:lang]) | |
22 | 21 | if params[:remember_me] == "1" |
23 | 22 | self.current_user.remember_me |
24 | 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 | 94 | # action to perform logout from the application |
96 | 95 | def logout |
97 | 96 | if logged_in? |
98 | - self.current_user.person.update_attribute(:last_lang, cookies[:lang]) | |
99 | 97 | self.current_user.forget_me |
100 | 98 | end |
101 | 99 | cookies.delete :auth_token | ... | ... |
app/models/person.rb
... | ... | @@ -12,15 +12,6 @@ class Person < Profile |
12 | 12 | Friendship.find(:all, :conditions => { :friend_id => person.id}).each { |friendship| friendship.destroy } |
13 | 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 | 15 | def suggested_friend_groups |
25 | 16 | (friend_groups.compact + [ _('friends'), _('work'), _('school'), _('family') ]).map {|i| i if !i.empty?}.compact.uniq |
26 | 17 | end | ... | ... |
test/functional/account_controller_test.rb
... | ... | @@ -290,27 +290,6 @@ class AccountControllerTest < Test::Unit::TestCase |
290 | 290 | assert_redirected_to :controller => 'profile_editor' |
291 | 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 | 293 | should 'signup from wizard' do |
315 | 294 | assert_difference User, :count do |
316 | 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 | 44 | assert p.community_memberships.include?(c), "Community should add a new member" |
45 | 45 | end |
46 | 46 | |
47 | - should 'can have user' do | |
47 | + should 'be associated with a user' do | |
48 | 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 | 51 | end |
55 | 52 | |
56 | 53 | should 'only one person per user' do |
... | ... | @@ -414,17 +411,6 @@ class PersonTest < Test::Unit::TestCase |
414 | 411 | assert_equal p.pending_tasks_for_organization(c), c.tasks |
415 | 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 | 414 | should 'return active_person_fields' do |
429 | 415 | e = Environment.default |
430 | 416 | e.expects(:active_person_fields).returns(['cell_phone', 'comercial_phone']).at_least_once | ... | ... |