Commit 576c5dbe0fbed1e727a93b9a55ed6c1b90ad7486

Authored by Victor Costa
1 parent eb5dddac

added tests for welcome screen settings

test/functional/admin_panel_controller_test.rb
@@ -73,6 +73,7 @@ class AdminPanelControllerTest < ActionController::TestCase @@ -73,6 +73,7 @@ class AdminPanelControllerTest < ActionController::TestCase
73 assert_tag :tag => 'textarea', :attributes => { :name => 'environment[terms_of_use]'} 73 assert_tag :tag => 'textarea', :attributes => { :name => 'environment[terms_of_use]'}
74 assert_tag :tag => 'input', :attributes => { :name => 'environment[signup_welcome_text_subject]'} 74 assert_tag :tag => 'input', :attributes => { :name => 'environment[signup_welcome_text_subject]'}
75 assert_tag :tag => 'textarea', :attributes => { :name => 'environment[signup_welcome_text_body]'} 75 assert_tag :tag => 'textarea', :attributes => { :name => 'environment[signup_welcome_text_body]'}
  76 + assert_tag :tag => 'textarea', :attributes => { :name => 'environment[signup_welcome_screen_body]'}
76 end 77 end
77 78
78 should 'display form for editing message for disabled enterprise' do 79 should 'display form for editing message for disabled enterprise' do
@@ -381,4 +382,13 @@ class AdminPanelControllerTest < ActionController::TestCase @@ -381,4 +382,13 @@ class AdminPanelControllerTest < ActionController::TestCase
381 assert_not_includes environment.languages, 'en' 382 assert_not_includes environment.languages, 'en'
382 end 383 end
383 384
  385 + should 'save body of signup welcome screen' do
  386 + body = "This is my welcome body"
  387 + post :site_info, :environment => { :signup_welcome_screen_body => body }
  388 + assert_redirected_to :action => 'index'
  389 +
  390 + assert_equal body, Environment.default.signup_welcome_screen_body
  391 + assert !Environment.default.signup_welcome_screen_body.blank?
  392 + end
  393 +
384 end 394 end
test/unit/environment_test.rb
@@ -1355,4 +1355,32 @@ class EnvironmentTest < ActiveSupport::TestCase @@ -1355,4 +1355,32 @@ class EnvironmentTest < ActiveSupport::TestCase
1355 environment.save! 1355 environment.save!
1356 assert_equal ['en', 'pt'], environment.available_locales 1356 assert_equal ['en', 'pt'], environment.available_locales
1357 end 1357 end
  1358 +
  1359 + should 'not consider custom welcome screen text if not defined' do
  1360 + env = Environment.default
  1361 + assert !env.has_custom_welcome_screen?
  1362 + end
  1363 +
  1364 + should 'not consider custom welcome screen text if nil' do
  1365 + env = Environment.default
  1366 +
  1367 + env.signup_welcome_screen_body = nil
  1368 + assert !env.has_custom_welcome_screen?
  1369 + end
  1370 +
  1371 + should 'consider signup welcome screen if body is defined' do
  1372 + env = Environment.default
  1373 + env.signup_welcome_screen_body = 'Welcome to the environment'
  1374 + assert env.has_custom_welcome_screen?
  1375 + end
  1376 +
  1377 + should 'store custom welcome screen body' do
  1378 + environment = Environment.default
  1379 +
  1380 + environment.signup_welcome_screen_body = 'Welcome to the environment'
  1381 + environment.save
  1382 + environment.reload
  1383 +
  1384 + assert_equal 'Welcome to the environment', environment.signup_welcome_screen_body
  1385 + end
1358 end 1386 end