Skip to content

Commit

Permalink
Add test for verification this bug
Browse files Browse the repository at this point in the history
  • Loading branch information
davydovanton committed Feb 3, 2016
1 parent 1f7b2c8 commit 7ce11e3
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 0 deletions.
@@ -0,0 +1,8 @@
module StaticAssetsApp::Controllers::Home
class Dashboard
include StaticAssetsApp::Action

def call(params)
end
end
end
@@ -0,0 +1 @@
dashboard
5 changes: 5 additions & 0 deletions 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
1 change: 1 addition & 0 deletions 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
@@ -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
13 changes: 13 additions & 0 deletions 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
16 changes: 16 additions & 0 deletions test/integration/static_assets/test_application.rb
Expand Up @@ -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')
Expand Down

0 comments on commit 7ce11e3

Please sign in to comment.