Commit c76304736452ef9431eaa92d13a267807d103f02

Authored by Joenio Costa
Committed by Antonio Terceiro
1 parent 3bb18c5d

Support for testing specific themes in development mode

app/helpers/application_helper.rb
... ... @@ -333,6 +333,8 @@ module ApplicationHelper
333 333 if ENV['RAILS_ENV'] == 'development' && environment.theme == 'random'
334 334 @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand
335 335 @random_theme
  336 + elsif ENV['RAILS_ENV'] == 'development' && params[:theme]
  337 + params[:theme]
336 338 else
337 339 if profile
338 340 profile.theme
... ...
test/unit/application_helper_test.rb
... ... @@ -538,6 +538,21 @@ class ApplicationHelperTest < Test::Unit::TestCase
538 538 assert_match(/(\?|&)size=50(&|$)/, url)
539 539 end
540 540  
  541 + should 'use theme passed via param when in development mode' do
  542 + stubs(:environment).returns(Environment.new(:theme => 'environment-theme'))
  543 + ENV.stubs(:[]).with('RAILS_ENV').returns('development')
  544 + self.stubs(:params).returns({:theme => 'my-theme'})
  545 + assert_equal 'my-theme', current_theme
  546 + end
  547 +
  548 + should 'not use theme passed via param when in production mode' do
  549 + stubs(:environment).returns(Environment.new(:theme => 'environment-theme'))
  550 + ENV.stubs(:[]).with('RAILS_ENV').returns('production')
  551 + self.stubs(:params).returns({:theme => 'my-theme'})
  552 + stubs(:profile).returns(Profile.new(:theme => 'profile-theme'))
  553 + assert_equal 'profile-theme', current_theme
  554 + end
  555 +
541 556 protected
542 557  
543 558 def url_for(args = {})
... ...