Commit 57ae8cf15f3b481b27bf0553b074d71876e36664

Authored by Gabriela Navarro
Committed by David Silva
1 parent cc6c8078

Refactoring using the Law of Demeter

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Signed-off-by: Parley Martins <parley@outlook.com>
lib/ext/person.rb
@@ -8,6 +8,8 @@ class Person @@ -8,6 +8,8 @@ class Person
8 8
9 attr_accessible :percentage_incomplete 9 attr_accessible :percentage_incomplete
10 10
  11 + delegate :login, :to => :user, :prefix => true
  12 +
11 scope :search, lambda { |name="", state="", city="", email=""| 13 scope :search, lambda { |name="", state="", city="", email=""|
12 like_sql = "" 14 like_sql = ""
13 values = [] 15 values = []
@@ -33,8 +35,8 @@ class Person @@ -33,8 +35,8 @@ class Person
33 end 35 end
34 like_sql = like_sql[0..like_sql.length-5] 36 like_sql = like_sql[0..like_sql.length-5]
35 37
36 - {  
37 - :joins => :user, 38 + {
  39 + :joins => :user,
38 :conditions=>[like_sql, *values] 40 :conditions=>[like_sql, *values]
39 } 41 }
40 } 42 }
test/functional/mpog_software_plugin_myprofile_controller_test.rb
@@ -22,7 +22,7 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase @@ -22,7 +22,7 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase
22 DatabaseDescription.create(:name => "database") 22 DatabaseDescription.create(:name => "database")
23 OperatingSystemName.create(:name=>"Debian") 23 OperatingSystemName.create(:name=>"Debian")
24 24
25 - login_as(@person.user.login) 25 + login_as(@person.user_login)
26 @environment = Environment.default 26 @environment = Environment.default
27 @environment.enable_plugin('MpogSoftwarePlugin') 27 @environment.enable_plugin('MpogSoftwarePlugin')
28 @environment.save! 28 @environment.save!
@@ -64,7 +64,7 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase @@ -64,7 +64,7 @@ class MpogSoftwarePluginMyprofileControllerTest &lt; ActionController::TestCase
64 assert response.count == 0 64 assert response.count == 0
65 end 65 end
66 66
67 - should 'create a new software with all fields filled in' do 67 + should 'create a new software with all fields filled in' do
68 fields = software_fields 68 fields = software_fields
69 @environment.add_admin(@person) 69 @environment.add_admin(@person)
70 post :new_software, :profile => @person.identifier, :community => fields[1], :license_info => fields[0], 70 post :new_software, :profile => @person.identifier, :community => fields[1], :license_info => fields[0],