Sha256: d8f7fa4b463b7c6fce2985360c5249b3e2afcc7bbabcd2333fca280202eb383f

Contents?: true

Size: 1.47 KB

Versions: 8

Compression:

Stored size: 1.47 KB

Contents

require 'test_helper'

class RenderHtmlClass < ActionView::TestCase
	test 'simple params' do
		self.params = {
			controller: 'controller',
			action: 'action'
		}
		cls = render_html_class.split ' '
		assert cls.include?('controller')
		assert cls.include?('action')
		assert cls.include?('controller_action')
	end

	test 'module controller' do
		self.params = {
			controller: 'module/controller',
			action: 'action'
		}
		cls = render_html_class.split ' '
		assert cls.include?('module_controller')
		assert cls.include?('controller')
		assert cls.include?('action')
		assert cls.include?('module_controller_action')
	end

	test 'addition html class' do
		self.params = {
			controller: 'controller',
			action: 'action',
			html_class: 'addition'
		}
		cls = render_html_class.split ' '
		assert cls.include?('controller')
		assert cls.include?('action')
		assert cls.include?('controller_action')
		assert cls.include?('addition')
	end

	test 'mobile' do
		self.params = {
			controller: 'controller',
			action: 'action'
		}
		self.request.env['X_MOBILE_DEVICE'] = 'iPad'
		cls = render_html_class.split ' '
		assert cls.include?('controller')
		assert cls.include?('action')
		assert cls.include?('controller_action')
		assert cls.include?('mobile')
		assert cls.include?('iPad')
	end

	def params
		@params || {}
	end

	def params= data
		@params = data
	end

	class Request
		def env
			@env || {}
		end

		def env= data
			@env = data
		end
	end

	def request
		@request ||= Request.new
	end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
h2ocube_rails_helper-0.0.14 test/render_html_class_test.rb
h2ocube_rails_helper-0.0.13 test/render_html_class_test.rb
h2ocube_rails_helper-0.0.12 test/render_html_class_test.rb
h2ocube_rails_helper-0.0.11 test/render_html_class_test.rb
h2ocube_rails_helper-0.0.10 test/render_html_class_test.rb
h2ocube_rails_helper-0.0.9 test/render_html_class_test.rb
h2ocube_rails_helper-0.0.8 test/render_html_class_test.rb
h2ocube_rails_helper-0.0.7 test/render_html_class_test.rb