Commit c76304736452ef9431eaa92d13a267807d103f02
Committed by
Antonio Terceiro
1 parent
3bb18c5d
Exists in
master
and in
29 other branches
Support for testing specific themes in development mode
Showing
2 changed files
with
17 additions
and
0 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -333,6 +333,8 @@ module ApplicationHelper | @@ -333,6 +333,8 @@ module ApplicationHelper | ||
333 | if ENV['RAILS_ENV'] == 'development' && environment.theme == 'random' | 333 | if ENV['RAILS_ENV'] == 'development' && environment.theme == 'random' |
334 | @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand | 334 | @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand |
335 | @random_theme | 335 | @random_theme |
336 | + elsif ENV['RAILS_ENV'] == 'development' && params[:theme] | ||
337 | + params[:theme] | ||
336 | else | 338 | else |
337 | if profile | 339 | if profile |
338 | profile.theme | 340 | profile.theme |
test/unit/application_helper_test.rb
@@ -538,6 +538,21 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -538,6 +538,21 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
538 | assert_match(/(\?|&)size=50(&|$)/, url) | 538 | assert_match(/(\?|&)size=50(&|$)/, url) |
539 | end | 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 | protected | 556 | protected |
542 | 557 | ||
543 | def url_for(args = {}) | 558 | def url_for(args = {}) |