diff --git a/test/fixtures/static_assets_app/app/controllers/home/dashboard.rb b/test/fixtures/static_assets_app/app/controllers/home/dashboard.rb new file mode 100644 index 000000000..4ce44dbbf --- /dev/null +++ b/test/fixtures/static_assets_app/app/controllers/home/dashboard.rb @@ -0,0 +1,8 @@ +module StaticAssetsApp::Controllers::Home + class Dashboard + include StaticAssetsApp::Action + + def call(params) + end + end +end diff --git a/test/fixtures/static_assets_app/app/templates/home/dashboard.html.erb b/test/fixtures/static_assets_app/app/templates/home/dashboard.html.erb new file mode 100644 index 000000000..2bb1f2c4e --- /dev/null +++ b/test/fixtures/static_assets_app/app/templates/home/dashboard.html.erb @@ -0,0 +1 @@ +dashboard diff --git a/test/fixtures/static_assets_app/app/views/home/dashboard.rb b/test/fixtures/static_assets_app/app/views/home/dashboard.rb new file mode 100644 index 000000000..054ea7135 --- /dev/null +++ b/test/fixtures/static_assets_app/app/views/home/dashboard.rb @@ -0,0 +1,5 @@ +module StaticAssetsApp::Views::Home + class Dashboard + include StaticAssetsApp::View + end +end diff --git a/test/fixtures/static_assets_app/config/routes.rb b/test/fixtures/static_assets_app/config/routes.rb index e63d24d1f..571d04fd8 100644 --- a/test/fixtures/static_assets_app/config/routes.rb +++ b/test/fixtures/static_assets_app/config/routes.rb @@ -1,3 +1,4 @@ +get '/dashboard', to: 'home#dashboard' get '/', to: 'home#index' # Configure your routes here # See: http://www.rubydoc.info/gems/hanami-router/#Usage diff --git a/test/fixtures/static_assets_app/spec/controllers/home/dashboard_spec.rb b/test/fixtures/static_assets_app/spec/controllers/home/dashboard_spec.rb new file mode 100644 index 000000000..30a39773b --- /dev/null +++ b/test/fixtures/static_assets_app/spec/controllers/home/dashboard_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' +require_relative '../../../app/controllers/home/dashboard' + +describe StaticAssetsApp::Controllers::Home::Dashboard do + let(:action) { StaticAssetsApp::Controllers::Home::Dashboard.new } + let(:params) { Hash[] } + + it 'is successful' do + response = action.call(params) + response[0].must_equal 200 + end +end diff --git a/test/fixtures/static_assets_app/spec/views/home/dashboard_spec.rb b/test/fixtures/static_assets_app/spec/views/home/dashboard_spec.rb new file mode 100644 index 000000000..89a7897f6 --- /dev/null +++ b/test/fixtures/static_assets_app/spec/views/home/dashboard_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' +require_relative '../../../app/views/home/dashboard' + +describe StaticAssetsApp::Views::Home::Dashboard do + let(:exposures) { Hash[foo: 'bar'] } + let(:template) { Hanami::View::Template.new('app/templates/home/dashboard.html.erb') } + let(:view) { StaticAssetsApp::Views::Home::Dashboard.new(template, exposures) } + let(:rendered) { view.render } + + it 'exposes #foo' do + view.foo.must_equal exposures.fetch(:foo) + end +end diff --git a/test/integration/static_assets/test_application.rb b/test/integration/static_assets/test_application.rb index 7f5b290b8..06ca537b8 100644 --- a/test/integration/static_assets/test_application.rb +++ b/test/integration/static_assets/test_application.rb @@ -67,6 +67,22 @@ response.status.must_equal 404 end + it "does not block application path" do + asset = root.join('public', 'assets', 'dashboard.js') + @assets_directory.mkpath + + File.open(asset, File::WRONLY|File::CREAT) do |f| + f.write <<-JS + console.log('stale'); + JS + end + + get 'dashboard' + response.status.must_equal 200 + response.body.must_include 'dashboard' + asset.delete if asset.exist? + end + it "replaces fresh version of assets by copying it" do begin fixture = root.join('app', 'assets', 'javascripts', 'dashboard.js')