spree_it_is_a_present 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +24 -0
  5. data/.travis.yml +45 -0
  6. data/Appraisals +9 -0
  7. data/CONTRIBUTING.md +58 -0
  8. data/Gemfile +11 -0
  9. data/LICENSE +26 -0
  10. data/README.md +62 -0
  11. data/Rakefile +21 -0
  12. data/app/.gitkeep +0 -0
  13. data/app/controllers/.gitkeep +0 -0
  14. data/app/controllers/spree_it_is_a_present/spree/admin/order/customer_details_controller_decorator.rb +28 -0
  15. data/app/controllers/spree_it_is_a_present/spree/checkout_controller_decorator.rb +19 -0
  16. data/app/models/.gitkeep +0 -0
  17. data/app/models/spree/present_note.rb +5 -0
  18. data/app/models/spree_it_is_a_present/spree/order_decorator.rb +19 -0
  19. data/app/overrides/add_present_notes_to_admin_customer_details.rb +5 -0
  20. data/app/overrides/add_present_notes_to_checkout_address_form.rb +5 -0
  21. data/app/services/.gitkeep +0 -0
  22. data/app/views/.gitkeep +0 -0
  23. data/app/views/spree/admin/orders/customer_details/_present_notes_form.html.erb +13 -0
  24. data/app/views/spree/admin/shared/_present_note_form.html.erb +11 -0
  25. data/app/views/spree/present_notes/_form.html.erb +21 -0
  26. data/bin/rails +8 -0
  27. data/config/locales/de.yml +13 -0
  28. data/config/locales/en.yml +13 -0
  29. data/config/locales/es.yml +13 -0
  30. data/config/routes.rb +3 -0
  31. data/db/migrate/20210413215328_create_spree_present_notes.rb +13 -0
  32. data/gemfiles/spree_4_2.gemfile +8 -0
  33. data/gemfiles/spree_master.gemfile +8 -0
  34. data/lib/generators/spree_it_is_a_present/install/install_generator.rb +20 -0
  35. data/lib/spree_it_is_a_present.rb +4 -0
  36. data/lib/spree_it_is_a_present/engine.rb +20 -0
  37. data/lib/spree_it_is_a_present/factories.rb +6 -0
  38. data/lib/spree_it_is_a_present/version.rb +11 -0
  39. data/spree_it_is_a_present.gemspec +31 -0
  40. metadata +170 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f3006330d73107a7947ecf160dcfa23b6fcc4a98d0ffb8de14cdcc87160af2f4
4
+ data.tar.gz: be613c6d350bd09fcb148cadd7e102dd69f4f72258317337b0824cede055432d
5
+ SHA512:
6
+ metadata.gz: e6413e5b985755249efe6349a3c4a517efa4e729c6605b29155efe3c64a61c46591c45c9cef91ed70c080fe5b358fbb71d25085f48d7d60542b314f6b9988f76
7
+ data.tar.gz: 87a32609cb1ab79446eb438268b976b5eb5f16a537d53a93e217108c3281be551b08f9f897320efbeb93c09fb38ee6b3b8d4d901308ece6394425bccdff8ab84
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .localeapp/locales
7
+ .project
8
+ .vscode
9
+ coverage
10
+ default
11
+ Gemfile.lock
12
+ tmp
13
+ nbproject
14
+ pkg
15
+ *.sw?
16
+ spec/dummy
17
+ .rvmrc
18
+ .sass-cache
19
+ public/spree
20
+ .ruby-version
21
+ .ruby-gemset
22
+ gemfiles/*.gemfile.lock
23
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ -r spec_helper
3
+ -f documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.5
4
+ Include:
5
+ - '**/Gemfile'
6
+ - '**/Rakefile'
7
+ - '**/Appraisals'
8
+ Exclude:
9
+ - 'spec/dummy/**/*'
10
+ - 'lib/generators/**/*'
11
+
12
+ Rails:
13
+ Enabled: true
14
+
15
+ Metrics/LineLength:
16
+ Max: 150
17
+
18
+ # DISABLED
19
+
20
+ Style/Documentation:
21
+ Enabled: false
22
+
23
+ Style/FrozenStringLiteralComment:
24
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,45 @@
1
+ os: linux
2
+ dist: bionic
3
+
4
+ addons:
5
+ apt:
6
+ sources:
7
+ - google-chrome
8
+ packages:
9
+ - google-chrome-stable
10
+
11
+ services:
12
+ - mysql
13
+ - postgresql
14
+
15
+ language: ruby
16
+
17
+ rvm:
18
+ - 2.7
19
+ - 3.0
20
+
21
+ env:
22
+ - DB=mysql
23
+ - DB=postgres
24
+
25
+ gemfile:
26
+ - gemfiles/spree_4_2.gemfile
27
+ - gemfiles/spree_master.gemfile
28
+
29
+ jobs:
30
+ allow_failures:
31
+ - gemfile: gemfiles/spree_master.gemfile
32
+
33
+ before_install:
34
+ - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
35
+
36
+ before_script:
37
+ - CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
38
+ - CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
39
+ - curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
40
+ - unzip chromedriver_linux64.zip -d ~/bin
41
+ - nvm install 14
42
+
43
+ script:
44
+ - bundle exec rake test_app
45
+ - bundle exec rake spec
data/Appraisals ADDED
@@ -0,0 +1,9 @@
1
+ appraise 'spree-4-2' do
2
+ gem 'spree', '~> 4.2.0'
3
+ gem 'rails-controller-testing'
4
+ end
5
+
6
+ appraise 'spree-master' do
7
+ gem 'spree', github: 'spree/spree', branch: 'master'
8
+ gem 'rails-controller-testing'
9
+ end
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,58 @@
1
+ # Contributing
2
+
3
+ **Everyone** is encouraged to help improve this project.
4
+
5
+ Here are some ways *you* can contribute:
6
+
7
+ ---
8
+
9
+ ## Filing an issue
10
+
11
+ When [filing an issue][2] on this extension, please first do these things:
12
+
13
+ * Verify you can reproduce this issue in a brand new application.
14
+ * Run through the steps to reproduce the issue again.
15
+
16
+ In the issue itself please provide:
17
+
18
+ * A comprehensive list of steps to reproduce the issue.
19
+ * What you're *expecting* to happen compared with what's *actually* happening.
20
+ * The version of Spree *and* the version of Rails.
21
+ * A list of all extensions.
22
+ * Any relevant stack traces ("Full trace" preferred)
23
+ * Your `Gemfile`
24
+
25
+ ---
26
+
27
+ ## Pull requests
28
+
29
+ [Pull requests][2] to fix bugs and also add new features to this extension are welcome. However, on the latter, it's recommended that before you do any work, you first open an [issue][3] to discuss about it.
30
+
31
+ Here's a quick guide to create your pull request:
32
+
33
+ 1. Fork this repo and clone it to your machine.
34
+
35
+ 2. Run `bundle install`
36
+
37
+ 3. Run `bundle exec rake test_app` to create the test application in `spec/dummy`
38
+
39
+ 4. Run the tests. Only pull requests with passing tests are accepted, and it's great to know that you have a clean slate.
40
+
41
+ 5. Create a new dedicated branch for your pull request, then make changes and add tests for your changes. Only refactoring and documentation changes require no new tests. If you are adding functionality, please ensure you include test coverage for it. In case you are fixing a bug, please add regression tests so that it never happens again. You can run your tests by executing `bundle exec rspec spec`.
42
+
43
+ 6. Ensure syntax is correct by running `rubocop .`
44
+
45
+ 7. Push to your fork and submit a pull request.
46
+
47
+ At this point your pull request will be reviewed by me. In the pull request I may suggest some changes, improvements or alternatives.
48
+
49
+ Some things that will increase the chance that your pull request is accepted, taken straight from the Ruby on Rails guide:
50
+
51
+ * Use Rails idioms and helpers.
52
+ * Include tests that fail without your code, and pass with it.
53
+ * Update the documentation, the surrounding one, examples elsewhere, guides, whatever is affected by your contribution.
54
+
55
+
56
+ [1]: https://github.com/albertoalmagro/spree_it_is_a_present/issues
57
+ [2]: https://github.com/albertoalmagro/spree_it_is_a_present/pulls
58
+ [3]: https://github.com/albertoalmagro/spree_it_is_a_present/tree/master/config/locales
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+ gem 'spree', github: 'spree/spree', branch: 'master'
9
+ gem 'rails-controller-testing'
10
+
11
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2021 Alberto Almagro
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # Spree It is a present!
2
+
3
+ With `spree_it_is_a_present` your customers will be able to add a name and a dedication to properly give your products as a present.
4
+
5
+ ## Installation
6
+
7
+ 1. Add this extension to your Gemfile with this line:
8
+
9
+ ```ruby
10
+ gem 'spree_it_is_a_present'
11
+ ```
12
+
13
+ 2. Install the gem using Bundler
14
+
15
+ ```ruby
16
+ bundle install
17
+ ```
18
+
19
+ 3. Copy & run migrations
20
+
21
+ ```ruby
22
+ bundle exec rails g spree_it_is_a_present:install
23
+ ```
24
+
25
+ 4. Restart your server
26
+
27
+ If your server was running, restart it so that it can find the assets properly.
28
+
29
+ 5. If you are using [Spree frontend](https://github.com/spree/spree/tree/master/frontend), you should see the form added by this gem at the address step during checkout. In the backend, the data provided by the frontend form will be displayed within the Order's client information.
30
+
31
+ ## Testing
32
+
33
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
34
+
35
+ ```shell
36
+ bundle
37
+ bundle exec rake
38
+ ```
39
+
40
+ When testing your applications integration with this extension you may use it's factories.
41
+ Simply add this require statement to your spec_helper:
42
+
43
+ ```ruby
44
+ require 'spree_it_is_a_present/factories'
45
+ ```
46
+
47
+ ## Releasing
48
+
49
+ ```shell
50
+ bundle exec gem bump -p -t
51
+ bundle exec gem release
52
+ ```
53
+
54
+ For more options please see [gem-release REAMDE](https://github.com/svenfuchs/gem-release)
55
+
56
+ ## Contributing
57
+
58
+ If you'd like to contribute, please take a look at the
59
+ [instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
60
+ pull request. (TODO)
61
+
62
+ Copyright (c) 2021 Alberto Almagro, released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'spree/testing_support/extension_rake'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir['spec/dummy'].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir('../../')
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc 'Generates a dummy app for testing'
18
+ task :test_app do
19
+ ENV['LIB_NAME'] = 'spree_it_is_a_present'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
data/app/.gitkeep ADDED
File without changes
File without changes
@@ -0,0 +1,28 @@
1
+ module SpreeItIsAPresent
2
+ module Spree
3
+ module Admin
4
+ module Order
5
+ module CustomerDetailsControllerDecorator
6
+ extend ActiveSupport::Concern
7
+
8
+ private
9
+
10
+ def order_params
11
+ params.require(:order).permit(
12
+ :email, :user_id, :use_billing,
13
+ bill_address_attributes: permitted_address_attributes,
14
+ ship_address_attributes: permitted_address_attributes,
15
+ present_note_attributes: present_note_attributes
16
+ )
17
+ end
18
+
19
+ def present_note_attributes
20
+ %i[recipient_name dedication]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ Spree::Admin::Orders::CustomerDetailsController.prepend SpreeItIsAPresent::Spree::Admin::Order::CustomerDetailsControllerDecorator
@@ -0,0 +1,19 @@
1
+ module SpreeItIsAPresent
2
+ module Spree
3
+ module CheckoutControllerDecorator
4
+ extend ActiveSupport::Concern
5
+
6
+ private
7
+
8
+ def permitted_checkout_attributes
9
+ super + [ present_note_attributes: present_note_attributes ]
10
+ end
11
+
12
+ def present_note_attributes
13
+ %i[recipient_name dedication]
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Spree::CheckoutController.prepend SpreeItIsAPresent::Spree::CheckoutControllerDecorator
File without changes
@@ -0,0 +1,5 @@
1
+ module Spree
2
+ class PresentNote < Spree::Base
3
+ belongs_to :order, class_name: 'Spree::Order'
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ module SpreeItIsAPresent
2
+ module Spree
3
+ module OrderDecorator
4
+ extend ActiveSupport::Concern
5
+
6
+ prepended do
7
+ has_one :present_note, class_name: 'Spree::PresentNote', dependent: :destroy
8
+
9
+ accepts_nested_attributes_for :present_note, reject_if: :all_blank
10
+ end
11
+
12
+ def present_note_with_default
13
+ present_note || build_present_note
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Spree::Order.prepend SpreeItIsAPresent::Spree::OrderDecorator
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(
2
+ virtual_path: 'spree/admin/orders/customer_details/_form',
3
+ partial: 'spree/admin/orders/customer_details/present_notes_form',
4
+ name: 'present_notes_autocomplete',
5
+ insert_before: "[data-hook='bill_address_wrapper']")
@@ -0,0 +1,5 @@
1
+ Deface::Override.new(
2
+ virtual_path: 'spree/checkout/_address',
3
+ text: "<%= render partial: 'spree/present_notes/form', locals: { form: form, order: @order } %>",
4
+ name: 'present_notes_form',
5
+ insert_before: '#delete-address-popup')
File without changes
File without changes
@@ -0,0 +1,13 @@
1
+ <div data-hook="spree_it_is_a_present_wrapper" class="col-12">
2
+ <div class="card mb-3">
3
+ <div class="card-header">
4
+ <h1 class="card-title mb-0 h5"><%= Spree.t('it_is_a_present.admin.header') %></h1>
5
+ </div>
6
+
7
+ <div class="card-body">
8
+ <%= f.fields_for :present_note, @order.present_note_with_default do |present_note_form| %>
9
+ <%= render 'spree/admin/shared/present_note_form', f: present_note_form %>
10
+ <% end %>
11
+ </div>
12
+ </div>
13
+ </div>
@@ -0,0 +1,11 @@
1
+ <div data-hook="present_note_fields">
2
+ <div class="form-group">
3
+ <%= f.label :recipient_name, Spree.t('it_is_a_present.form.recipient_name') %>
4
+ <%= f.text_field :recipient_name, class: 'form-control' %>
5
+ </div>
6
+
7
+ <div class="form-group">
8
+ <%= f.label :dedication, Spree.t('it_is_a_present.form.dedication') %>
9
+ <%= f.text_area :dedication, class: 'form-control' %>
10
+ </div>
11
+ </div>
@@ -0,0 +1,21 @@
1
+ <div class="row">
2
+ <div class="col-12 mb-4">
3
+ <div id="present_note">
4
+ <h5 class="text-uppercase checkout-content-header">
5
+ <%= Spree.t('it_is_a_present.form.header') %>
6
+ </h5>
7
+ <%= form.fields_for :present_note, order.present_note_with_default do |present_note_form| %>
8
+ <div class="inner checkout-content-inner" data-hook='present_note_inner'>
9
+ <div class="form-group checkout-content-inner-field has-float-label">
10
+ <%= present_note_form.text_field :recipient_name, class: 'required spree-flat-input', placeholder: Spree.t('it_is_a_present.form.recipient_name') %>
11
+ <%= present_note_form.label :name, Spree.t('it_is_a_present.form.recipient_name'), class: 'text-uppercase' %>
12
+ </div>
13
+ <div class="form-group checkout-content-inner-field has-float-label">
14
+ <%= present_note_form.text_area :dedication, class: 'required spree-flat-input', placeholder: Spree.t('it_is_a_present.form.dedication') %>
15
+ <%= present_note_form.label :dedication, Spree.t('it_is_a_present.form.dedication'), class: 'text-uppercase' %>
16
+ </div>
17
+ </div>
18
+ <% end %>
19
+ </div>
20
+ </div>
21
+ </div>
data/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" from the root of your extension
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/spree_it_is_a_present/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,13 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ de:
5
+ spree:
6
+ it_is_a_present:
7
+ admin:
8
+ header: Diese Bestellung ist ein Geschenk
9
+ form:
10
+ checkbox_label: Als Geschenk absenden
11
+ dedication: Widmung
12
+ header: Ist es ein Geschenk?
13
+ recipient_name: Name der Empfängerin / Name des Empfängers
@@ -0,0 +1,13 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ spree:
6
+ it_is_a_present:
7
+ admin:
8
+ header: This order is a present
9
+ form:
10
+ checkbox_label: Send as a present
11
+ dedication: Dedication
12
+ header: Is it a present?
13
+ recipient_name: Recipient name
@@ -0,0 +1,13 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ es:
5
+ spree:
6
+ it_is_a_present:
7
+ admin:
8
+ header: Este pedido es un regalo
9
+ form:
10
+ checkbox_label: Enviar como regalo
11
+ dedication: Dedicatoria
12
+ header: ¿Es un regalo?
13
+ recipient_name: Nombre de la persona que recibirá el regalo
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Spree::Core::Engine.add_routes do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'spree_extension/migration'
2
+
3
+ class CreateSpreePresentNotes < SpreeExtension::Migration[6.1]
4
+ def change
5
+ create_table :spree_present_notes do |t|
6
+ t.belongs_to :order, index: { unique: true }, null: false
7
+ t.string :recipient_name
8
+ t.text :dedication
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails-controller-testing"
6
+ gem "spree", "~> 4.2.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails-controller-testing"
6
+ gem "spree", github: "spree/spree", branch: "master"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,20 @@
1
+ module SpreeItIsAPresent
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :migrate, type: :boolean, default: true
5
+
6
+ def add_migrations
7
+ run 'bundle exec rake railties:install:migrations FROM=spree_it_is_a_present'
8
+ end
9
+
10
+ def run_migrations
11
+ run_migrations = options[:migrate] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
12
+ if run_migrations
13
+ run 'bundle exec rails db:migrate'
14
+ else
15
+ puts 'Skipping rails db:migrate, don\'t forget to run it!'
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,4 @@
1
+ require 'spree_core'
2
+ require 'spree_extension'
3
+ require 'spree_it_is_a_present/engine'
4
+ require 'spree_it_is_a_present/version'
@@ -0,0 +1,20 @@
1
+ module SpreeItIsAPresent
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_it_is_a_present'
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare(&method(:activate).to_proc)
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :present_note, class: 'Spree::PresentNote' do
3
+ recipient_name { 'María' }
4
+ dedication { 'This is a present for you' }
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ module SpreeItIsAPresent
2
+ VERSION = '0.0.2'.freeze
3
+
4
+ module_function
5
+
6
+ # Returns the version of the currently loaded SpreeItIsAPresent as a
7
+ # <tt>Gem::Version</tt>.
8
+ def version
9
+ Gem::Version.new VERSION
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: UTF-8
2
+ lib = File.expand_path('../lib/', __FILE__)
3
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'spree_it_is_a_present/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.platform = Gem::Platform::RUBY
9
+ s.name = 'spree_it_is_a_present'
10
+ s.version = SpreeItIsAPresent.version
11
+ s.summary = 'spree_it_is_a_present adds name and dedication to your orders'
12
+ s.description = 'With spree_it_is_a_present your customers will be able to add a name and a dedication to properly give your products as a present'
13
+ s.required_ruby_version = '>= 2.5.0'
14
+
15
+ s.author = 'Alberto Almagro'
16
+ s.email = 'alberto@albertoalmagro.com'
17
+ s.homepage = 'https://github.com/albertoalmagro/spree_it_is_a_present'
18
+ s.license = 'BSD-3-Clause'
19
+
20
+ s.files = `git ls-files`.split("\n").reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
21
+ s.require_path = 'lib'
22
+ s.requirements << 'none'
23
+
24
+ spree_version = '>= 4.2.0', '< 6.0'
25
+ s.add_dependency 'spree_core', spree_version
26
+ s.add_dependency 'spree_api', spree_version
27
+ s.add_dependency 'spree_backend', spree_version
28
+ s.add_dependency 'spree_extension'
29
+
30
+ s.add_development_dependency 'spree_dev_tools'
31
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_it_is_a_present
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Alberto Almagro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: spree_core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 4.2.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: spree_api
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 4.2.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 4.2.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: spree_backend
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 4.2.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '6.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 4.2.0
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '6.0'
73
+ - !ruby/object:Gem::Dependency
74
+ name: spree_extension
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ - !ruby/object:Gem::Dependency
88
+ name: spree_dev_tools
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ type: :development
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ description: With spree_it_is_a_present your customers will be able to add a name
102
+ and a dedication to properly give your products as a present
103
+ email: alberto@albertoalmagro.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - ".gitignore"
109
+ - ".rspec"
110
+ - ".rubocop.yml"
111
+ - ".travis.yml"
112
+ - Appraisals
113
+ - CONTRIBUTING.md
114
+ - Gemfile
115
+ - LICENSE
116
+ - README.md
117
+ - Rakefile
118
+ - app/.gitkeep
119
+ - app/controllers/.gitkeep
120
+ - app/controllers/spree_it_is_a_present/spree/admin/order/customer_details_controller_decorator.rb
121
+ - app/controllers/spree_it_is_a_present/spree/checkout_controller_decorator.rb
122
+ - app/models/.gitkeep
123
+ - app/models/spree/present_note.rb
124
+ - app/models/spree_it_is_a_present/spree/order_decorator.rb
125
+ - app/overrides/add_present_notes_to_admin_customer_details.rb
126
+ - app/overrides/add_present_notes_to_checkout_address_form.rb
127
+ - app/services/.gitkeep
128
+ - app/views/.gitkeep
129
+ - app/views/spree/admin/orders/customer_details/_present_notes_form.html.erb
130
+ - app/views/spree/admin/shared/_present_note_form.html.erb
131
+ - app/views/spree/present_notes/_form.html.erb
132
+ - bin/rails
133
+ - config/locales/de.yml
134
+ - config/locales/en.yml
135
+ - config/locales/es.yml
136
+ - config/routes.rb
137
+ - db/migrate/20210413215328_create_spree_present_notes.rb
138
+ - gemfiles/spree_4_2.gemfile
139
+ - gemfiles/spree_master.gemfile
140
+ - lib/generators/spree_it_is_a_present/install/install_generator.rb
141
+ - lib/spree_it_is_a_present.rb
142
+ - lib/spree_it_is_a_present/engine.rb
143
+ - lib/spree_it_is_a_present/factories.rb
144
+ - lib/spree_it_is_a_present/version.rb
145
+ - spree_it_is_a_present.gemspec
146
+ homepage: https://github.com/albertoalmagro/spree_it_is_a_present
147
+ licenses:
148
+ - BSD-3-Clause
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: 2.5.0
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements:
165
+ - none
166
+ rubygems_version: 3.1.6
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: spree_it_is_a_present adds name and dedication to your orders
170
+ test_files: []