Delayed::Job.countDelayed::Job.first.destroy| # Create an instance of an AWS S3 resource (bucket) | |
| class S3Bucket | |
| def self.fetch | |
| s3 = Aws::S3::Resource.new( | |
| Aws::Credentials.new( | |
| Rails.configuration.aws_uploader_access_key_id, | |
| Rails.configuration.aws_uploader_secret_access_key | |
| ), | |
| ) | |
| s3.bucket(Rails.configuration.aws_bucket) |
| # Zip file | |
| # | |
| # @private | |
| # | |
| # @return [String] path to file | |
| def zip_file | |
| zfilename ||= 'example.zip' | |
| zfile ||= Tempfile.new(zfilename) # you can also create a non-temp file so that it's not in the tmp directory | |
| Zip::File.open(zfile.path, Zip::File::CREATE) do |zip| | |
| ['path/to/file1', 'path/to/file2'].each do |filepath| |
| ACTION_LINK_BASE_URL = URI.parse('https://example.com/service.html') | |
| # Action Link URL | |
| # | |
| # @example Example usage | |
| # action_link_url('abc-123-xyz') #=> https://example.com/service.html?id=abc-123-xyz | |
| # | |
| # @param account_id [String] | |
| # @return [String] | |
| def action_link_url(account_id) |
| routes = Rails.application.routes.routes.map { |r| r.path.spec.to_s } | |
| # *OR* for even more attributes | |
| Rails.application.routes.routes.map { |r| { alias: r.name, path: r.path.spec.to_s, controller: r.defaults[:controller], action: r.defaults[:action] } } |
| # frozen_string_literal: true | |
| require "rails_helper" | |
| RSpec.describe Notifications, type: :mailer do | |
| describe '.google_places_report_ready' do | |
| let(:mail) { Notifications.google_places_report_ready } | |
| let(:download_path) { '/google_places/download_report' } | |
| it 'renders the subject' do |
| volumes: | |
| postgresql: | |
| name: automotiontv-postgresql | |
| external: true | |
| x-restart_policy: &default_restart_policy | |
| deploy: | |
| restart_policy: | |
| condition: on-failure | |
| delay: 5s |
| it 'downloads the file' do | |
| expect(controller).to receive(:send_file).with(GooglePlacesApiClient::DEFAULT_CSV_FILEPATH, type: 'text/csv').and_call_original | |
| get :download_report | |
| end | |
| # OR | |
| it 'does not try to download the file' do | |
| expect(controller).not_to receive(:send_file) | |
| get :download_report |
| # Stubbing a single class constant is a little finicky and can remove all constants of a class if not done right | |
| MyClass::MY_CONSTANT_1 #=> 'foo' | |
| MyClass::MY_CONSTANT_2 #=> 'bar' | |
| # METHOD 1 (PREFERRED) | |
| before(:example) do | |
| stub_const('MyClass', MyClass) |
| # Diff between Logger and ActiveSupport::Logger | |
| https://stackoverflow.com/q/64433146/990637 | |
| # Problem with Puma / .silence method when using Logger instead of ActiveSupport::Logger | |
| https://github.com/rails/sprockets-rails/issues/376#issuecomment-287560399 |