Commit 297b3b7204a8d29cb6939a3c8ed4eb2ad5a925a2

Authored by Gust
1 parent b0874b74

Fixing AI2897 problems:

-Changed update_attribute to setting the attribute then 'save!'
-Removed some whitespaces
-The file controller/themes_controller.rb is needed because it is inherited by controller/my_profile/profile_themes_controller.rb and controller/admin/environment_themes_controller.rb, it is a generalization. Before this functionality was created, there was only one file called controller/my_profile/themes_controller.rb.

(ActionItem2897)

Signed-off-by: Alex de Souza <campelo.al1@gmail.com>
Signed-off-by: Gustavo Jaruga <darksshades@hotmail.com>
app/controllers/themes_controller.rb
@@ -5,7 +5,7 @@ class ThemesController &lt; ApplicationController @@ -5,7 +5,7 @@ class ThemesController &lt; ApplicationController
5 no_design_blocks 5 no_design_blocks
6 6
7 # attr_reader :target 7 # attr_reader :target
8 - 8 +
9 def target 9 def target
10 @target 10 @target
11 end 11 end
app/models/environment.rb
@@ -679,11 +679,13 @@ class Environment &lt; ActiveRecord::Base @@ -679,11 +679,13 @@ class Environment &lt; ActiveRecord::Base
679 end 679 end
680 680
681 def update_theme(theme) 681 def update_theme(theme)
682 - self.update_attribute(:theme, theme) 682 + self.theme = theme
  683 + self.save!
683 end 684 end
684 685
685 def update_layout_template(template) 686 def update_layout_template(template)
686 - self.update_attribute(:layout_template, template) 687 + self.layout_template = template
  688 + self.save!
687 end 689 end
688 690
689 before_create do |env| 691 before_create do |env|
test/functional/environment_themes_controller_test.rb
@@ -96,7 +96,8 @@ class EnvironmentThemesControllerTest &lt; ActionController::TestCase @@ -96,7 +96,8 @@ class EnvironmentThemesControllerTest &lt; ActionController::TestCase
96 96
97 should 'display links to set template' do 97 should 'display links to set template' do
98 env = Environment.default 98 env = Environment.default
99 - env.update_attributes!(:layout_template => 'rightbar') 99 + env.layout_template = 'rightbar'
  100 + env.save!
100 t1 = LayoutTemplate.find('default') 101 t1 = LayoutTemplate.find('default')
101 t2 = LayoutTemplate.find('leftbar') 102 t2 = LayoutTemplate.find('leftbar')
102 LayoutTemplate.expects(:all).returns([t1, t2]) 103 LayoutTemplate.expects(:all).returns([t1, t2])
@@ -109,6 +110,7 @@ class EnvironmentThemesControllerTest &lt; ActionController::TestCase @@ -109,6 +110,7 @@ class EnvironmentThemesControllerTest &lt; ActionController::TestCase
109 should 'highlight current template' do 110 should 'highlight current template' do
110 env = Environment.default 111 env = Environment.default
111 env.update_attributes!(:layout_template => 'default') 112 env.update_attributes!(:layout_template => 'default')
  113 + env.layout_template = 'default'
112 114
113 t1 = LayoutTemplate.find('default') 115 t1 = LayoutTemplate.find('default')
114 t2 = LayoutTemplate.find('leftbar') 116 t2 = LayoutTemplate.find('leftbar')
test/functional/profile_themes_controller_test.rb
@@ -254,7 +254,8 @@ class ProfileThemesControllerTest &lt; ActionController::TestCase @@ -254,7 +254,8 @@ class ProfileThemesControllerTest &lt; ActionController::TestCase
254 end 254 end
255 255
256 should 'display links to set template' do 256 should 'display links to set template' do
257 - profile.update_attributes!(:layout_template => 'rightbar') 257 + profile.layout_template = 'rightbar'
  258 + profile.save!
258 t1 = LayoutTemplate.find('default') 259 t1 = LayoutTemplate.find('default')
259 t2 = LayoutTemplate.find('leftbar') 260 t2 = LayoutTemplate.find('leftbar')
260 LayoutTemplate.expects(:all).returns([t1, t2]) 261 LayoutTemplate.expects(:all).returns([t1, t2])
@@ -265,7 +266,8 @@ class ProfileThemesControllerTest &lt; ActionController::TestCase @@ -265,7 +266,8 @@ class ProfileThemesControllerTest &lt; ActionController::TestCase
265 end 266 end
266 267
267 should 'highlight current template' do 268 should 'highlight current template' do
268 - profile.update_attributes!(:layout_template => 'default') 269 + profile.layout_template = 'default'
  270 + profile.save!
269 271
270 t1 = LayoutTemplate.find('default') 272 t1 = LayoutTemplate.find('default')
271 t2 = LayoutTemplate.find('leftbar') 273 t2 = LayoutTemplate.find('leftbar')