aboutsummaryrefslogtreecommitdiffstats
path: root/tasks
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2019-01-15 20:21:32 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2019-01-15 20:21:32 +0100
commita08827a90b5a9be79379019cf5b242bd7236d2e3 (patch)
tree97ede594e80b573fb58035ea711551e6f54bdac0 /tasks
parenta64d7b470a6c1dacbce82dc421a3daed4e403a7d (diff)
downloadrails-a08827a90b5a9be79379019cf5b242bd7236d2e3.tar.gz
rails-a08827a90b5a9be79379019cf5b242bd7236d2e3.tar.bz2
rails-a08827a90b5a9be79379019cf5b242bd7236d2e3.zip
Exercise Active Storage and Action Text in verification app.
Allows the releaser to verify that: - A rich text description can be edited and shown *richly*. - An image/PDF can be uploaded and generate a variant that's shown. Also moves the generated app to a tmp directory for less cleanup need.
Diffstat (limited to 'tasks')
-rw-r--r--tasks/release.rb45
1 files changed, 42 insertions, 3 deletions
diff --git a/tasks/release.rb b/tasks/release.rb
index c1816cf533..214c1fd16e 100644
--- a/tasks/release.rb
+++ b/tasks/release.rb
@@ -173,17 +173,56 @@ namespace :all do
end
task verify: :install do
- app_name = "pkg/verify-#{version}-#{Time.now.to_i}"
+ require "tmpdir"
+
+ cd Dir.tmpdir
+ app_name = "verify-#{version}-#{Time.now.to_i}"
sh "rails _#{version}_ new #{app_name} --skip-bundle" # Generate with the right version.
cd app_name
+ substitute = -> (file_name, regex, replacement) do
+ File.write(file_name, File.read(file_name).sub(regex, replacement))
+ end
+
# Replace the generated gemfile entry with the exact version.
- File.write("Gemfile", File.read("Gemfile").sub(/^gem 'rails.*/, "gem 'rails', '#{version}'"))
+ substitute.call("Gemfile", /^gem 'rails.*/, "gem 'rails', '#{version}'")
+ substitute.call("Gemfile", /^# gem 'image_processing/, "gem 'image_processing")
sh "bundle"
sh "rails action_mailbox:install"
sh "rails action_text:install"
- sh "rails generate scaffold user name admin:boolean && rails db:migrate"
+ sh "rails generate scaffold user name description:text admin:boolean"
+ sh "rails db:migrate"
+
+ # Replace the generated gemfile entry with the exact version.
+ substitute.call("app/models/user.rb", /end\n\z/, <<~CODE)
+ has_one_attached :avatar
+ has_rich_text :description
+ end
+ CODE
+
+ substitute.call("app/views/users/_form.html.erb", /text_area :description %>\n <\/div>/, <<~CODE)
+ rich_text_area :description %>\n </div>
+
+ <div class="field">
+ Avatar: <%= form.file_field :avatar %>
+ </div>
+ CODE
+
+ substitute.call("app/views/users/show.html.erb", /description %>\n<\/p>/, <<~CODE)
+ description %>\n</p>
+
+ <p>
+ <%= image_tag @user.avatar.representation(resize_to_fit: [500, 500]) %>
+ </p>
+ CODE
+
+ # Permit the avatar param.
+ substitute.call("app/controllers/users_controller.rb", /:admin/, ":admin, :avatar")
+
+ if ENV["EDITOR"]
+ `#{ENV["EDITOR"]} #{File.expand_path(app_name)}`
+ end
puts "Booting a Rails server. Verify the release by:"
puts