From f2fe847e9f04d04b72d532e5fbfa5471c84b1b05 Mon Sep 17 00:00:00 2001 From: Raimundo Herrera Date: Fri, 2 Aug 2019 21:41:33 -0400 Subject: [PATCH 1/2] feat(storage): update paperclip and remove unnecesary initializer --- lib/potassium/assets/aws.rb | 1 - lib/potassium/recipes/aws_sdk.rb | 2 -- lib/potassium/recipes/file_storage.rb | 2 +- spec/features/new_project_spec.rb | 3 --- 4 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 lib/potassium/assets/aws.rb diff --git a/lib/potassium/assets/aws.rb b/lib/potassium/assets/aws.rb deleted file mode 100644 index e322d0b1..00000000 --- a/lib/potassium/assets/aws.rb +++ /dev/null @@ -1 +0,0 @@ -Aws::VERSION = Gem.loaded_specs["aws-sdk"].version diff --git a/lib/potassium/recipes/aws_sdk.rb b/lib/potassium/recipes/aws_sdk.rb index 67a232b5..532df7c6 100644 --- a/lib/potassium/recipes/aws_sdk.rb +++ b/lib/potassium/recipes/aws_sdk.rb @@ -1,7 +1,5 @@ class Recipes::AwsSdk < Rails::AppBuilder def create gather_gem('aws-sdk', '~> 3') - - template("../assets/aws.rb", "config/initializers/aws.rb", force: true) end end diff --git a/lib/potassium/recipes/file_storage.rb b/lib/potassium/recipes/file_storage.rb index d6da1dd1..f88305b5 100644 --- a/lib/potassium/recipes/file_storage.rb +++ b/lib/potassium/recipes/file_storage.rb @@ -48,7 +48,7 @@ def config_rspec_for_paperclip end def add_paperclip - gather_gem 'paperclip', '~> 5.0' + gather_gem 'paperclip', '~> 6.0' application paperclip_config, env: 'production' append_to_file '.gitignore', "/public/system/*\n" end diff --git a/spec/features/new_project_spec.rb b/spec/features/new_project_spec.rb index 0762eac9..217a5cd6 100644 --- a/spec/features/new_project_spec.rb +++ b/spec/features/new_project_spec.rb @@ -29,9 +29,6 @@ it "configures aws" do gemfile_content = IO.read("#{project_path}/Gemfile") expect(gemfile_content).to include("'aws-sdk', '~> 3'") - - initializer = IO.read("#{project_path}/config/initializers/aws.rb") - expect(initializer).to include("Aws::VERSION") end it "configures the correct ruby version" do From f89f635f12cdb4e289e484e5f1615cf6aeb77715 Mon Sep 17 00:00:00 2001 From: Raimundo Herrera Date: Fri, 2 Aug 2019 22:21:32 -0400 Subject: [PATCH 2/2] feat(storage): use aws-sdk-s3 gem instead of aws-sdk Closes #190 --- lib/potassium/recipes/aws_sdk.rb | 5 ----- lib/potassium/recipes/file_storage.rb | 1 + lib/potassium/templates/application.rb | 1 - spec/features/file_storage_spec.rb | 10 ++++++++++ spec/features/new_project_spec.rb | 5 ----- 5 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 lib/potassium/recipes/aws_sdk.rb diff --git a/lib/potassium/recipes/aws_sdk.rb b/lib/potassium/recipes/aws_sdk.rb deleted file mode 100644 index 532df7c6..00000000 --- a/lib/potassium/recipes/aws_sdk.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Recipes::AwsSdk < Rails::AppBuilder - def create - gather_gem('aws-sdk', '~> 3') - end -end diff --git a/lib/potassium/recipes/file_storage.rb b/lib/potassium/recipes/file_storage.rb index f88305b5..5cd35049 100644 --- a/lib/potassium/recipes/file_storage.rb +++ b/lib/potassium/recipes/file_storage.rb @@ -63,6 +63,7 @@ def add_active_storage end def common_setup + gather_gem 'aws-sdk-s3', '~> 1.0' add_readme_section :internal_dependencies, get(:storage) append_to_file '.env.development', "S3_BUCKET=\n" end diff --git a/lib/potassium/templates/application.rb b/lib/potassium/templates/application.rb index cd4b7175..aa5f95f3 100644 --- a/lib/potassium/templates/application.rb +++ b/lib/potassium/templates/application.rb @@ -49,7 +49,6 @@ create :ruby create :yarn create :editorconfig - create :aws_sdk create :mailer create :background_processor create :schedule diff --git a/spec/features/file_storage_spec.rb b/spec/features/file_storage_spec.rb index 700acdaa..d30b87ab 100644 --- a/spec/features/file_storage_spec.rb +++ b/spec/features/file_storage_spec.rb @@ -8,6 +8,11 @@ create_dummy_project(storage: :active_storage) end + it "adds the aws-sdk-s3 gem to Gemfile" do + gemfile_content = IO.read("#{project_path}/Gemfile") + expect(gemfile_content).to include("gem 'aws-sdk-s3'") + end + it "customizes config file" do content = IO.read("#{project_path}/config/storage.yml") expect(content).to include("bucket: <%= ENV['S3_BUCKET'] %>") @@ -41,6 +46,11 @@ expect(gemfile_content).to include("gem 'paperclip'") end + it "adds the aws-sdk-s3 gem to Gemfile" do + gemfile_content = IO.read("#{project_path}/Gemfile") + expect(gemfile_content).to include("gem 'aws-sdk-s3'") + end + it "adds brief to README file" do content = IO.read("#{project_path}/README.md") expect(content).to include("Paperclip") diff --git a/spec/features/new_project_spec.rb b/spec/features/new_project_spec.rb index 217a5cd6..48fa28b5 100644 --- a/spec/features/new_project_spec.rb +++ b/spec/features/new_project_spec.rb @@ -26,11 +26,6 @@ expect(gemfile).to include %{gem 'pg'} end - it "configures aws" do - gemfile_content = IO.read("#{project_path}/Gemfile") - expect(gemfile_content).to include("'aws-sdk', '~> 3'") - end - it "configures the correct ruby version" do ruby_version_file = IO.read("#{project_path}/.ruby-version")