2010-12-18 02:22:01 -05:00
|
|
|
require "test_helper"
|
2010-10-18 16:05:04 -04:00
|
|
|
|
|
|
|
class ViewsGeneratorTest < Rails::Generators::TestCase
|
|
|
|
tests Devise::Generators::ViewsGenerator
|
2010-12-09 20:52:30 -05:00
|
|
|
destination File.expand_path("../../tmp", __FILE__)
|
2010-10-18 16:05:04 -04:00
|
|
|
setup :prepare_destination
|
|
|
|
|
|
|
|
test "Assert all views are properly created with no params" do
|
|
|
|
run_generator
|
2010-10-18 16:52:29 -04:00
|
|
|
assert_files
|
|
|
|
end
|
|
|
|
|
|
|
|
test "Assert all views are properly created with scope param param" do
|
|
|
|
run_generator %w(users)
|
|
|
|
assert_files "users"
|
|
|
|
|
|
|
|
run_generator %w(admins)
|
|
|
|
assert_files "admins"
|
|
|
|
end
|
|
|
|
|
2011-06-27 10:50:28 -04:00
|
|
|
test "Assert views with simple form" do
|
|
|
|
run_generator %w(-b simple_form_for)
|
|
|
|
assert_files
|
|
|
|
assert_file "app/views/devise/confirmations/new.html.erb", /simple_form_for/
|
|
|
|
|
|
|
|
run_generator %w(users -b simple_form_for)
|
|
|
|
assert_files "users"
|
|
|
|
assert_file "app/views/users/confirmations/new.html.erb", /simple_form_for/
|
|
|
|
end
|
|
|
|
|
2010-10-18 16:52:29 -04:00
|
|
|
def assert_files(scope = nil, template_engine = nil)
|
|
|
|
scope = "devise" if scope.nil?
|
2010-12-09 20:52:30 -05:00
|
|
|
assert_file "app/views/#{scope}/confirmations/new.html.erb"
|
|
|
|
assert_file "app/views/#{scope}/mailer/confirmation_instructions.html.erb"
|
|
|
|
assert_file "app/views/#{scope}/mailer/reset_password_instructions.html.erb"
|
|
|
|
assert_file "app/views/#{scope}/mailer/unlock_instructions.html.erb"
|
|
|
|
assert_file "app/views/#{scope}/passwords/edit.html.erb"
|
|
|
|
assert_file "app/views/#{scope}/passwords/new.html.erb"
|
|
|
|
assert_file "app/views/#{scope}/registrations/new.html.erb"
|
|
|
|
assert_file "app/views/#{scope}/registrations/edit.html.erb"
|
|
|
|
assert_file "app/views/#{scope}/sessions/new.html.erb"
|
|
|
|
assert_file "app/views/#{scope}/shared/_links.erb"
|
|
|
|
assert_file "app/views/#{scope}/unlocks/new.html.erb"
|
2010-10-18 16:05:04 -04:00
|
|
|
end
|
|
|
|
end
|