|
190 | 190 | end
|
191 | 191 | end
|
192 | 192 |
|
193 |
| - task verify: :install do |
194 |
| - require "tmpdir" |
195 |
| - |
196 |
| - cd Dir.tmpdir |
197 |
| - app_name = "verify-#{version}-#{Time.now.to_i}" |
198 |
| - sh "rails _#{version}_ new #{app_name} --skip-bundle" # Generate with the right version. |
199 |
| - cd app_name |
200 |
| - |
201 |
| - substitute = -> (file_name, regex, replacement) do |
202 |
| - File.write(file_name, File.read(file_name).sub(regex, replacement)) |
203 |
| - end |
204 |
| - |
205 |
| - # Replace the generated gemfile entry with the exact version. |
206 |
| - substitute.call("Gemfile", /^gem "rails.*/, %{gem "rails", "#{version}"}) |
207 |
| - substitute.call("Gemfile", /^# gem "image_processing/, 'gem "image_processing') |
208 |
| - sh "bundle" |
209 |
| - sh "rails action_mailbox:install" |
210 |
| - sh "rails action_text:install" |
211 |
| - |
212 |
| - sh "rails generate scaffold user name description:text admin:boolean" |
213 |
| - sh "rails db:migrate" |
214 |
| - |
215 |
| - # Replace the generated gemfile entry with the exact version. |
216 |
| - substitute.call("app/models/user.rb", /end\n\z/, <<~CODE) |
217 |
| - has_one_attached :avatar |
218 |
| - has_rich_text :description |
219 |
| - end |
220 |
| - CODE |
221 |
| - |
222 |
| - substitute.call("app/views/users/_form.html.erb", /textarea :description %>\n <\/div>/, <<~CODE) |
223 |
| - rich_textarea :description %>\n </div> |
224 |
| -
|
225 |
| - <div class="field"> |
226 |
| - Avatar: <%= form.file_field :avatar %> |
227 |
| - </div> |
228 |
| - CODE |
229 |
| - |
230 |
| - substitute.call("app/views/users/show.html.erb", /description %>\n<\/p>/, <<~CODE) |
231 |
| - description %>\n</p> |
232 |
| -
|
233 |
| - <p> |
234 |
| - <% if @user.avatar.attached? -%> |
235 |
| - <%= image_tag @user.avatar.representation(resize_to_limit: [500, 500]) %> |
236 |
| - <% end -%> |
237 |
| - </p> |
238 |
| - CODE |
239 |
| - |
240 |
| - # Permit the avatar param. |
241 |
| - substitute.call("app/controllers/users_controller.rb", /:admin/, ":admin, :avatar") |
242 |
| - |
243 |
| - editor = ENV["VISUAL"] || ENV["EDITOR"] |
244 |
| - if editor |
245 |
| - `#{editor} #{File.expand_path(app_name)}` |
246 |
| - end |
247 |
| - |
248 |
| - puts "Booting a Rails server. Verify the release by:" |
249 |
| - puts |
250 |
| - puts "- Seeing the correct release number on the root page" |
251 |
| - puts "- Viewing /users" |
252 |
| - puts "- Creating a user" |
253 |
| - puts "- Updating a user (e.g. disable the admin flag)" |
254 |
| - puts "- Deleting a user on /users" |
255 |
| - puts "- Whatever else you want." |
256 |
| - begin |
257 |
| - sh "rails server" |
258 |
| - rescue Interrupt |
259 |
| - # Server passes along interrupt. Prevent halting verify task. |
260 |
| - end |
261 |
| - end |
262 |
| - |
263 | 193 | task :bundle do
|
264 | 194 | sh "bundle check"
|
265 | 195 | end
|
|
0 commit comments