Commit b05096219fb3b40bf9a4e2c116dcf7ee2b69e0c1

Authored by Antonio Terceiro
1 parent 6c22b7ef

Fixing tests that depended on the old layout

test/functional/application_controller_test.rb
@@ -175,6 +175,7 @@ class ApplicationControllerTest < Test::Unit::TestCase @@ -175,6 +175,7 @@ class ApplicationControllerTest < Test::Unit::TestCase
175 end 175 end
176 176
177 should 'display only some categories in menu' do 177 should 'display only some categories in menu' do
  178 + @controller.stubs(:get_layout).returns('application')
178 c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent => nil, :display_in_menu => true ) 179 c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent => nil, :display_in_menu => true )
179 c2 = Environment.default.categories.create!(:name => 'Category 2', :display_color => nil, :parent => c1, :display_in_menu => true ) 180 c2 = Environment.default.categories.create!(:name => 'Category 2', :display_color => nil, :parent => c1, :display_in_menu => true )
180 get :index 181 get :index
@@ -182,6 +183,7 @@ class ApplicationControllerTest < Test::Unit::TestCase @@ -182,6 +183,7 @@ class ApplicationControllerTest < Test::Unit::TestCase
182 end 183 end
183 184
184 should 'not display some categories in menu' do 185 should 'not display some categories in menu' do
  186 + @controller.stubs(:get_layout).returns('application')
185 c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent_id => nil, :display_in_menu => true) 187 c1 = Environment.default.categories.create!(:name => 'Category 1', :display_color => 1, :parent_id => nil, :display_in_menu => true)
186 c2 = Environment.default.categories.create!(:name => 'Category 2', :display_color => nil, :parent_id => c1) 188 c2 = Environment.default.categories.create!(:name => 'Category 2', :display_color => nil, :parent_id => c1)
187 get :index 189 get :index
@@ -198,16 +200,8 @@ class ApplicationControllerTest < Test::Unit::TestCase @@ -198,16 +200,8 @@ class ApplicationControllerTest < Test::Unit::TestCase
198 assert_tag :tag => 'option', :attributes => { :value => 'it' }, :content => 'Italiano' 200 assert_tag :tag => 'option', :attributes => { :value => 'it' }, :content => 'Italiano'
199 end 201 end
200 202
201 - should 'display links for select language' do  
202 - Noosfero.expects(:locales).returns({ 'en' => 'English', 'pt_BR' => 'Português Brasileiro', 'fr' => 'Français', 'it' => 'Italiano' }).at_least_once  
203 - get :index, :lang => 'en'  
204 - assert_no_tag :tag => 'a', :attributes => { :href => /\?lang=en/ }, :content => 'English'  
205 - assert_tag :tag => 'a', :attributes => { :href => /\?lang=pt_BR/ }, :content => 'Português Brasileiro'  
206 - assert_tag :tag => 'a', :attributes => { :href => /\?lang=fr/ }, :content => 'Français'  
207 - assert_tag :tag => 'a', :attributes => { :href => /\?lang=it/ }, :content => 'Italiano'  
208 - end  
209 -  
210 should 'display link to webmail if enabled for system and for user' do 203 should 'display link to webmail if enabled for system and for user' do
  204 + @controller.stubs(:get_layout).returns('application')
211 login_as('ze') 205 login_as('ze')
212 MailConf.expects(:enabled?).returns(true) 206 MailConf.expects(:enabled?).returns(true)
213 MailConf.expects(:webmail_url).returns('http://web.mail/') 207 MailConf.expects(:webmail_url).returns('http://web.mail/')
@@ -218,6 +212,7 @@ class ApplicationControllerTest < Test::Unit::TestCase @@ -218,6 +212,7 @@ class ApplicationControllerTest < Test::Unit::TestCase
218 end 212 end
219 213
220 should 'not display link to webmail if not enabled for system' do 214 should 'not display link to webmail if not enabled for system' do
  215 + @controller.stubs(:get_layout).returns('application')
221 login_as('ze') 216 login_as('ze')
222 MailConf.expects(:enabled?).returns(false) 217 MailConf.expects(:enabled?).returns(false)
223 218
@@ -226,6 +221,7 @@ class ApplicationControllerTest < Test::Unit::TestCase @@ -226,6 +221,7 @@ class ApplicationControllerTest < Test::Unit::TestCase
226 end 221 end
227 222
228 should 'not display link in menu to webmail if not enabled for user' do 223 should 'not display link in menu to webmail if not enabled for user' do
  224 + @controller.stubs(:get_layout).returns('application')
229 login_as('ze') 225 login_as('ze')
230 MailConf.expects(:enabled?).returns(true) 226 MailConf.expects(:enabled?).returns(true)
231 User.any_instance.expects(:enable_email).returns(false) 227 User.any_instance.expects(:enable_email).returns(false)
@@ -389,6 +385,7 @@ class ApplicationControllerTest < Test::Unit::TestCase @@ -389,6 +385,7 @@ class ApplicationControllerTest < Test::Unit::TestCase
389 end 385 end
390 386
391 should 'display menu links for my environment when logged in other environment' do 387 should 'display menu links for my environment when logged in other environment' do
  388 + @controller.stubs(:get_layout).returns('application')
392 e = Environment.create!(:name => 'other_environment') 389 e = Environment.create!(:name => 'other_environment')
393 e.domains << Domain.new(:name => 'other.environment') 390 e.domains << Domain.new(:name => 'other.environment')
394 e.save! 391 e.save!
test/functional/profile_editor_controller_test.rb
@@ -410,10 +410,10 @@ class ProfileEditorControllerTest &lt; Test::Unit::TestCase @@ -410,10 +410,10 @@ class ProfileEditorControllerTest &lt; Test::Unit::TestCase
410 end 410 end
411 411
412 should 'not link to mailconf for organizations' do 412 should 'not link to mailconf for organizations' do
413 - MailConf.stubs(:enabled?).returns(true).at_least_once 413 + MailConf.stubs(:enabled?).returns(true)
414 org = fast_create(Organization) 414 org = fast_create(Organization)
415 get :index, :profile => org.identifier 415 get :index, :profile => org.identifier
416 - assert_no_tag :tag => 'a', :attributes => { :href => '/myprofile/testorg/mailconf' } 416 + assert_no_tag :tag => 'a', :attributes => { :href => "/myprofile/#{org.identifier}/mailconf" }
417 end 417 end
418 418
419 should 'not link to mailconf if mail not enabled' do 419 should 'not link to mailconf if mail not enabled' do
test/functional/search_controller_test.rb
@@ -981,7 +981,7 @@ class SearchControllerTest &lt; Test::Unit::TestCase @@ -981,7 +981,7 @@ class SearchControllerTest &lt; Test::Unit::TestCase
981 should 'not display steps when searching not on wizard' do 981 should 'not display steps when searching not on wizard' do
982 c1 = create_profile_with_optional_category(Community, 'a beautiful community') 982 c1 = create_profile_with_optional_category(Community, 'a beautiful community')
983 get :index, :query => 'beautiful', :find_in => [ 'communities' ] 983 get :index, :query => 'beautiful', :find_in => [ 'communities' ]
984 - assert_equal 'layouts/application', @response.layout 984 + assert_match 'layouts/application', @response.layout
985 assert_no_tag :tag => 'div', :attributes => {:id => 'wizard-steps'} 985 assert_no_tag :tag => 'div', :attributes => {:id => 'wizard-steps'}
986 end 986 end
987 987
test/integration/assets_menu_test.rb
@@ -3,6 +3,9 @@ require &quot;#{File.dirname(__FILE__)}/../test_helper&quot; @@ -3,6 +3,9 @@ require &quot;#{File.dirname(__FILE__)}/../test_helper&quot;
3 class AssetsMenuTest < ActionController::IntegrationTest 3 class AssetsMenuTest < ActionController::IntegrationTest
4 4
5 def setup 5 def setup
  6 + HomeController.any_instance.stubs(:get_layout).returns('application')
  7 + SearchController.any_instance.stubs(:get_layout).returns('application')
  8 +
6 parent = Category.create!(:name => "Parent Category", :environment => Environment.default, :display_color => 1) 9 parent = Category.create!(:name => "Parent Category", :environment => Environment.default, :display_color => 1)
7 @category = Category.create!(:name => "Category A", :environment => Environment.default, :parent => parent) 10 @category = Category.create!(:name => "Category A", :environment => Environment.default, :parent => parent)
8 end 11 end
test/integration/categories_menu_test.rb
@@ -3,6 +3,9 @@ require &quot;#{File.dirname(__FILE__)}/../test_helper&quot; @@ -3,6 +3,9 @@ require &quot;#{File.dirname(__FILE__)}/../test_helper&quot;
3 class CategoriesMenuTest < ActionController::IntegrationTest 3 class CategoriesMenuTest < ActionController::IntegrationTest
4 4
5 def setup 5 def setup
  6 + HomeController.any_instance.stubs(:get_layout).returns('application')
  7 + SearchController.any_instance.stubs(:get_layout).returns('application')
  8 +
6 Category.delete_all 9 Category.delete_all
7 @cat1 = Category.create!(:display_in_menu => true, :name => 'Food', :environment => Environment.default, :display_color => 1) 10 @cat1 = Category.create!(:display_in_menu => true, :name => 'Food', :environment => Environment.default, :display_color => 1)
8 @cat2 = Category.create!(:display_in_menu => true, :name => 'Vegetables', :environment => Environment.default, :parent => @cat1) 11 @cat2 = Category.create!(:display_in_menu => true, :name => 'Vegetables', :environment => Environment.default, :parent => @cat1)
test/integration/search_popup_test.rb
@@ -2,6 +2,11 @@ require &quot;#{File.dirname(__FILE__)}/../test_helper&quot; @@ -2,6 +2,11 @@ require &quot;#{File.dirname(__FILE__)}/../test_helper&quot;
2 2
3 class SearchPopupTest < ActionController::IntegrationTest 3 class SearchPopupTest < ActionController::IntegrationTest
4 4
  5 + def setup
  6 + HomeController.any_instance.stubs(:get_layout).returns('application')
  7 + SearchController.any_instance.stubs(:get_layout).returns('application')
  8 + end
  9 +
5 should 'link to search without category when not inside a filter' do 10 should 'link to search without category when not inside a filter' do
6 get '/' 11 get '/'
7 assert_tag :tag => 'a', :attributes => { :href => '/search/popup' } 12 assert_tag :tag => 'a', :attributes => { :href => '/search/popup' }