From c76304736452ef9431eaa92d13a267807d103f02 Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Wed, 13 Jan 2010 14:36:20 -0300 Subject: [PATCH] Support for testing specific themes in development mode --- app/helpers/application_helper.rb | 2 ++ test/unit/application_helper_test.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0eaa31e..4bdab05 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -333,6 +333,8 @@ module ApplicationHelper if ENV['RAILS_ENV'] == 'development' && environment.theme == 'random' @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand @random_theme + elsif ENV['RAILS_ENV'] == 'development' && params[:theme] + params[:theme] else if profile profile.theme diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index e466689..264652b 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -538,6 +538,21 @@ class ApplicationHelperTest < Test::Unit::TestCase assert_match(/(\?|&)size=50(&|$)/, url) end + should 'use theme passed via param when in development mode' do + stubs(:environment).returns(Environment.new(:theme => 'environment-theme')) + ENV.stubs(:[]).with('RAILS_ENV').returns('development') + self.stubs(:params).returns({:theme => 'my-theme'}) + assert_equal 'my-theme', current_theme + end + + should 'not use theme passed via param when in production mode' do + stubs(:environment).returns(Environment.new(:theme => 'environment-theme')) + ENV.stubs(:[]).with('RAILS_ENV').returns('production') + self.stubs(:params).returns({:theme => 'my-theme'}) + stubs(:profile).returns(Profile.new(:theme => 'profile-theme')) + assert_equal 'profile-theme', current_theme + end + protected def url_for(args = {}) -- libgit2 0.21.2