1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add a template per case on asset debugging tests

It avoids the problem when the file checker is not able to detect changes
on the files during testing.
This commit is contained in:
Jose Galisteo 2021-09-08 09:43:45 +02:00
parent a8c4c27a81
commit 0063fb307a

View file

@ -85,14 +85,18 @@ module ApplicationTests
image_submit_tag: %r{<input type="image" src="/images/#{contents}" />} image_submit_tag: %r{<input type="image" src="/images/#{contents}" />}
} }
class ::PostsController < ActionController::Base
def index
render params[:view_method]
end
end
cases.each do |(view_method, tag_match)| cases.each do |(view_method, tag_match)|
app_file "app/views/posts/index.html.erb", "<%= #{view_method} '#{contents}', skip_pipeline: true %>" app_file "app/views/posts/#{view_method}.html.erb", "<%= #{view_method} '#{contents}', skip_pipeline: true %>"
app "development" app "development"
class ::PostsController < ActionController::Base ; end get "/posts?debug_assets=true&view_method=#{view_method}"
get "/posts?debug_assets=true"
body = last_response.body body = last_response.body
assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{tag_match}, but did not: #{body}") assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{tag_match}, but did not: #{body}")
@ -111,14 +115,18 @@ module ApplicationTests
stylesheet_url: %r{http://example.org/stylesheets/#{contents}}, stylesheet_url: %r{http://example.org/stylesheets/#{contents}},
} }
class ::PostsController < ActionController::Base
def index
render params[:view_method]
end
end
cases.each do |(view_method, tag_match)| cases.each do |(view_method, tag_match)|
app_file "app/views/posts/index.html.erb", "<%= #{view_method} '#{contents}', skip_pipeline: true %>" app_file "app/views/posts/#{view_method}.html.erb", "<%= #{view_method} '#{contents}', skip_pipeline: true %> "
app "development" app "development"
class ::PostsController < ActionController::Base ; end get "/posts?debug_assets=true&view_method=#{view_method}"
get "/posts?debug_assets=true"
body = last_response.body body = last_response.body
assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{tag_match}, but did not: #{body}") assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{tag_match}, but did not: #{body}")
@ -130,14 +138,19 @@ module ApplicationTests
/\/assets\/application-.*.\.js/ => {}, /\/assets\/application-.*.\.js/ => {},
/application.js/ => { skip_pipeline: true }, /application.js/ => { skip_pipeline: true },
} }
cases.each do |(tag_match, options_hash)|
app_file "app/views/posts/index.html.erb", "<%= asset_path('application.js', #{options_hash}) %>" class ::PostsController < ActionController::Base
def index
render params[:version]
end
end
cases.each_with_index do |(tag_match, options_hash), index|
app_file "app/views/posts/version_#{index}.html.erb", "<%= asset_path('application.js', #{options_hash}) %>"
app "development" app "development"
class ::PostsController < ActionController::Base ; end get "/posts?debug_assets=true&version=version_#{index}"
get "/posts?debug_assets=true"
body = last_response.body.strip body = last_response.body.strip
assert_match(tag_match, body, "Expected `asset_path` with `#{options_hash}` to produce a match to #{tag_match}, but did not: #{body}") assert_match(tag_match, body, "Expected `asset_path` with `#{options_hash}` to produce a match to #{tag_match}, but did not: #{body}")
@ -150,14 +163,18 @@ module ApplicationTests
public_compute_asset_path: /application.js/, public_compute_asset_path: /application.js/,
} }
class ::PostsController < ActionController::Base
def index
render params[:view_method]
end
end
cases.each do |(view_method, tag_match)| cases.each do |(view_method, tag_match)|
app_file "app/views/posts/index.html.erb", "<%= #{ view_method } 'application.js' %>" app_file "app/views/posts/#{view_method}.html.erb", "<%= #{ view_method } 'application.js' %>"
app "development" app "development"
class ::PostsController < ActionController::Base ; end get "/posts?debug_assets=true&view_method=#{view_method}"
get "/posts?debug_assets=true"
body = last_response.body.strip body = last_response.body.strip
assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{ tag_match }, but did not: #{ body }") assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{ tag_match }, but did not: #{ body }")