Skip to content

Commit a692e63

Browse files
authored
Merge pull request rails#43188 from ceritium/asset-debugging-template-per-case
Fix flaky tests, add a template per case on asset debugging tests
2 parents cf99be4 + 0063fb3 commit a692e63

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

railties/test/application/asset_debugging_test.rb

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,18 @@ class ::PostsController < ActionController::Base ; end
8585
image_submit_tag: %r{<input type="image" src="/images/#{contents}" />}
8686
}
8787

88+
class ::PostsController < ActionController::Base
89+
def index
90+
render params[:view_method]
91+
end
92+
end
93+
8894
cases.each do |(view_method, tag_match)|
89-
app_file "app/views/posts/index.html.erb", "<%= #{view_method} '#{contents}', skip_pipeline: true %>"
95+
app_file "app/views/posts/#{view_method}.html.erb", "<%= #{view_method} '#{contents}', skip_pipeline: true %>"
9096

9197
app "development"
9298

93-
class ::PostsController < ActionController::Base ; end
94-
95-
get "/posts?debug_assets=true"
99+
get "/posts?debug_assets=true&view_method=#{view_method}"
96100

97101
body = last_response.body
98102
assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{tag_match}, but did not: #{body}")
@@ -111,14 +115,18 @@ class ::PostsController < ActionController::Base ; end
111115
stylesheet_url: %r{http://example.org/stylesheets/#{contents}},
112116
}
113117

118+
class ::PostsController < ActionController::Base
119+
def index
120+
render params[:view_method]
121+
end
122+
end
123+
114124
cases.each do |(view_method, tag_match)|
115-
app_file "app/views/posts/index.html.erb", "<%= #{view_method} '#{contents}', skip_pipeline: true %>"
125+
app_file "app/views/posts/#{view_method}.html.erb", "<%= #{view_method} '#{contents}', skip_pipeline: true %> "
116126

117127
app "development"
118128

119-
class ::PostsController < ActionController::Base ; end
120-
121-
get "/posts?debug_assets=true"
129+
get "/posts?debug_assets=true&view_method=#{view_method}"
122130

123131
body = last_response.body
124132
assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{tag_match}, but did not: #{body}")
@@ -130,14 +138,19 @@ class ::PostsController < ActionController::Base ; end
130138
/\/assets\/application-.*.\.js/ => {},
131139
/application.js/ => { skip_pipeline: true },
132140
}
133-
cases.each do |(tag_match, options_hash)|
134-
app_file "app/views/posts/index.html.erb", "<%= asset_path('application.js', #{options_hash}) %>"
135141

136-
app "development"
142+
class ::PostsController < ActionController::Base
143+
def index
144+
render params[:version]
145+
end
146+
end
137147

138-
class ::PostsController < ActionController::Base ; end
148+
cases.each_with_index do |(tag_match, options_hash), index|
149+
app_file "app/views/posts/version_#{index}.html.erb", "<%= asset_path('application.js', #{options_hash}) %>"
150+
151+
app "development"
139152

140-
get "/posts?debug_assets=true"
153+
get "/posts?debug_assets=true&version=version_#{index}"
141154

142155
body = last_response.body.strip
143156
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 @@ class ::PostsController < ActionController::Base ; end
150163
public_compute_asset_path: /application.js/,
151164
}
152165

166+
class ::PostsController < ActionController::Base
167+
def index
168+
render params[:view_method]
169+
end
170+
end
171+
153172
cases.each do |(view_method, tag_match)|
154-
app_file "app/views/posts/index.html.erb", "<%= #{ view_method } 'application.js' %>"
173+
app_file "app/views/posts/#{view_method}.html.erb", "<%= #{ view_method } 'application.js' %>"
155174

156175
app "development"
157176

158-
class ::PostsController < ActionController::Base ; end
159-
160-
get "/posts?debug_assets=true"
177+
get "/posts?debug_assets=true&view_method=#{view_method}"
161178

162179
body = last_response.body.strip
163180
assert_match(tag_match, body, "Expected `#{view_method}` to produce a match to #{ tag_match }, but did not: #{ body }")

0 commit comments

Comments
 (0)