maintenance_tasks 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '017924f32ef1d9cb9e8ef6b739e1dc7ab60695dce1ee03c9f9f14fcaa35dfdde'
4
- data.tar.gz: 17d3d2e220dd8b3cc7270797398abe33e5c90e38a3d19b28a571cb61c94a567c
3
+ metadata.gz: ab7d654d153de66a16dc940efdafe3c15e0f151383829b1cb331a67a86c6532c
4
+ data.tar.gz: 375fde5efda30bd597d9609f08ee2edada28d336e97991b05e9357f5edca17cb
5
5
  SHA512:
6
- metadata.gz: '0942f2e8f1d23e1dc180a13deef7af7c198dcb348fdd62ed0c9107d4eded0a7908c0477c6e15c954658f4a99a41c5858fec4b02477d8deed4f72f44c4ae7cb5e'
7
- data.tar.gz: 61c1d448e4c1eaf7a8076dc253d72de1d515b70ed4623b76a290b24dd4e6f0c76aff6fccde27619eceffc497ca750910aa9590363f2c3cbd2085a75a8838a18f
6
+ metadata.gz: 3ec5d5108af6fecdcfa4a8fd7a37640f48f3e5dc39c918a8a0bf52bd9792474f465cfc495491caad22337da8bba6446726e0f58114e1b22a44e2b30a10168d3c
7
+ data.tar.gz: 07c9fc9e6e5779fe9180081c5b8306acb43ab6d30dd500b2c2184ab24e8e901e1221f88c29294eaba51cf38f81e054f4ce2575fcd02f897d22238f0fe04c08df
@@ -41,6 +41,11 @@ module MaintenanceTasks
41
41
 
42
42
  scope :active, -> { where(status: ACTIVE_STATUSES) }
43
43
 
44
+ # Ensure ActiveStorage is in use before preloading the attachments
45
+ scope :with_attached_csv, -> do
46
+ with_attached_csv_file if ActiveStorage::Attachment.table_exists?
47
+ end
48
+
44
49
  validates_with RunStatusValidator, on: :update
45
50
 
46
51
  has_one_attached :csv_file
@@ -188,11 +193,21 @@ module MaintenanceTasks
188
193
  def csv_attachment_presence
189
194
  if Task.named(task_name) < CsvCollection && !csv_file.attached?
190
195
  errors.add(:csv_file, 'must be attached to CSV Task.')
191
- elsif !(Task.named(task_name) < CsvCollection) && csv_file.attached?
196
+ elsif !(Task.named(task_name) < CsvCollection) && csv_file.present?
192
197
  errors.add(:csv_file, 'should not be attached to non-CSV Task.')
193
198
  end
194
199
  rescue Task::NotFoundError
195
200
  nil
196
201
  end
202
+
203
+ # Fetches the attached ActiveStorage CSV file for the run. Checks first
204
+ # whether the ActiveStorage::Attachment table exists so that we are
205
+ # compatible with apps that are not using ActiveStorage.
206
+ #
207
+ # @return [ActiveStorage::Attached::One] the attached CSV file
208
+ def csv_file
209
+ return unless ActiveStorage::Attachment.table_exists?
210
+ super
211
+ end
197
212
  end
198
213
  end
@@ -135,7 +135,7 @@ module MaintenanceTasks
135
135
  private
136
136
 
137
137
  def runs
138
- Run.where(task_name: name).with_attached_csv_file.order(created_at: :desc)
138
+ Run.where(task_name: name).with_attached_csv.order(created_at: :desc)
139
139
  end
140
140
  end
141
141
  end
@@ -9,7 +9,7 @@
9
9
  <%= render "maintenance_tasks/runs/info/#{run.status}", run: run %>
10
10
  </div>
11
11
 
12
- <% if run.csv_file.attached? %>
12
+ <% if run.csv_file.present? %>
13
13
  <div class="block">
14
14
  <%= link_to('Download CSV', csv_file_download_path(run)) %>
15
15
  </div>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maintenance_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-01 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -151,10 +151,10 @@ files:
151
151
  homepage: https://github.com/Shopify/maintenance_tasks
152
152
  licenses: []
153
153
  metadata:
154
- source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.1.1
154
+ source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.1.2
155
155
  allowed_push_host: https://rubygems.org
156
156
  post_install_message: |-
157
- Thank you for installing Maintenance Tasks 1.1.1. To complete, please run:
157
+ Thank you for installing Maintenance Tasks 1.1.2. To complete, please run:
158
158
 
159
159
  rails generate maintenance_tasks:install
160
160
  rdoc_options: []