spree_id_verification 0.0.1.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +24 -0
  5. data/.travis.yml +49 -0
  6. data/Appraisals +20 -0
  7. data/Gemfile +31 -0
  8. data/LICENSE +26 -0
  9. data/README.md +54 -0
  10. data/Rakefile +21 -0
  11. data/app/.gitkeep +0 -0
  12. data/app/controllers/.gitkeep +0 -0
  13. data/app/controllers/spree_id_verification/spree/admin/users_controller_decorator.rb +35 -0
  14. data/app/mailers/spree/verification_mailer.rb +25 -0
  15. data/app/models/.gitkeep +0 -0
  16. data/app/models/spree_id_verification/spree/id_verification_image.rb +41 -0
  17. data/app/models/spree_id_verification/spree/user_decorator.rb +52 -0
  18. data/app/overrides/add_id_verification_image_to_user_form.rb +6 -0
  19. data/app/services/.gitkeep +0 -0
  20. data/app/views/.gitkeep +0 -0
  21. data/app/views/spree/admin/users/verification.html.erb +37 -0
  22. data/app/views/spree/shared/_id_verification_fields.html.erb +4 -0
  23. data/app/views/spree/verification_mailer/welcome_email.html.erb +2 -0
  24. data/app/views/spree/verification_mailer/welcome_email.text.erb +3 -0
  25. data/bin/rails +8 -0
  26. data/config/initializers/permitted_attributes.rb +1 -0
  27. data/config/locales/en.yml +10 -0
  28. data/config/routes.rb +11 -0
  29. data/db/migrate/20200827233305_create_spree_id_verification_images.rb +19 -0
  30. data/db/migrate/20200828144231_add_status_to_users.rb +27 -0
  31. data/db/migrate/20200902162323_add_pending_default_value_to_users.rb +8 -0
  32. data/gemfiles/spree_3_7.gemfile +9 -0
  33. data/gemfiles/spree_4_0.gemfile +8 -0
  34. data/gemfiles/spree_4_1.gemfile +9 -0
  35. data/gemfiles/spree_master.gemfile +8 -0
  36. data/lib/generators/spree_id_verification/install/install_generator.rb +20 -0
  37. data/lib/spree_id_verification.rb +4 -0
  38. data/lib/spree_id_verification/engine.rb +20 -0
  39. data/lib/spree_id_verification/factories.rb +6 -0
  40. data/lib/spree_id_verification/version.rb +18 -0
  41. data/spec/fixtures/example.png +0 -0
  42. data/spree_id_verification.gemspec +31 -0
  43. metadata +186 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1962702745d78a5d511715b5ae8242d31d4d7fe61f1ea01efcbec8a4710bf687
4
+ data.tar.gz: 04a262e7894af5dcf4dd8ace04efadb470b580fc2bef2fafc012c63e6d6d5fe2
5
+ SHA512:
6
+ metadata.gz: d4412d7b1d442ac527ea226707dff41ba50af23999a90b7725118f5ba03f3bb374f2f2890dcf411821322e6019647f8f942d8bb775abdb072347c6e4b466b47a
7
+ data.tar.gz: 4af42b5b0ea6d830c230f9b0580f6aae1ecfe44bbf6909c5b86751ff98434cfba73fdd7a268a9281c8956f1264d7c5bcfc8fc4130c1795e9c46f310aebacd022
@@ -0,0 +1,22 @@
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
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ -r spec_helper
3
+ -f documentation
@@ -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
@@ -0,0 +1,49 @@
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.5
19
+ - 2.6
20
+
21
+ env:
22
+ - DB=mysql
23
+ - DB=postgres
24
+
25
+ gemfile:
26
+ - gemfiles/spree_3_7.gemfile
27
+ - gemfiles/spree_4_0.gemfile
28
+ - gemfiles/spree_4_1.gemfile
29
+ - gemfiles/spree_master.gemfile
30
+
31
+ jobs:
32
+ allow_failures:
33
+ - gemfile: gemfiles/spree_master.gemfile
34
+ exclude:
35
+ - rvm: 2.6
36
+ gemfile: gemfiles/spree_3_7.gemfile
37
+
38
+ before_install:
39
+ - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
40
+
41
+ before_script:
42
+ - CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
43
+ - CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
44
+ - curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
45
+ - unzip chromedriver_linux64.zip -d ~/bin
46
+
47
+ script:
48
+ - bundle exec rake test_app
49
+ - bundle exec rake spec
@@ -0,0 +1,20 @@
1
+ appraise 'spree-3-7' do
2
+ gem 'spree', '~> 3.7.0'
3
+ gem 'sass-rails'
4
+ gem 'rails-controller-testing'
5
+ end
6
+
7
+ appraise 'spree-4-0' do
8
+ gem 'spree', '~> 4.0.0'
9
+ gem 'rails-controller-testing'
10
+ end
11
+
12
+ appraise 'spree-4-1' do
13
+ gem 'spree', '~> 4.1.0'
14
+ gem 'rails-controller-testing'
15
+ end
16
+
17
+ appraise 'spree-master' do
18
+ gem 'spree', github: 'spree/spree', branch: 'master'
19
+ gem 'rails-controller-testing'
20
+ end
data/Gemfile ADDED
@@ -0,0 +1,31 @@
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 'spree_auth_devise', '~> 4.1'
10
+
11
+ gem 'state_machines-activerecord', '~> 0.6'
12
+ gem 'state_machines-activemodel', '~> 0.7'
13
+
14
+ group :test do
15
+ gem 'sqlite3'
16
+
17
+ gem 'rails-controller-testing'
18
+
19
+ gem 'database_cleaner'
20
+ gem 'ffaker'
21
+ gem 'factory_bot'
22
+
23
+ gem 'pry'
24
+ gem 'pry-byebug'
25
+ gem 'pry-stack_explorer', '~> 0.5.0'
26
+
27
+ gem 'rspec'
28
+ gem 'rspec-rails'
29
+ end
30
+
31
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2020 [name of plugin creator]
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.
@@ -0,0 +1,54 @@
1
+ # SpreeIdVerification
2
+
3
+ - library introduce user verification on sign up form.
4
+ - admin should verify user to change status to `verified`
5
+ - spree developer could decide how to use status column in terms of accessing to specific endpoints of Spree
6
+
7
+
8
+ ## Installation
9
+
10
+ 1. Add this extension to your Gemfile with this line:
11
+
12
+ ```ruby
13
+ gem 'spree_id_verification', github: '[your-github-handle]/spree_id_verification'
14
+ ```
15
+
16
+ 2. Install the gem using Bundler
17
+
18
+ ```ruby
19
+ bundle install
20
+ ```
21
+
22
+ 3. Copy & run migrations
23
+
24
+ ```ruby
25
+ bundle exec rails g spree_id_verification:install
26
+ ```
27
+
28
+ 4. Restart your server
29
+
30
+ If your server was running, restart it so that it can find the assets properly.
31
+
32
+ ## Testing
33
+
34
+ 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`.
35
+
36
+ ```shell
37
+ bundle
38
+ bundle exec rake
39
+ ```
40
+
41
+ When testing your applications integration with this extension you may use it's factories.
42
+ Simply add this require statement to your spec_helper:
43
+
44
+ ```ruby
45
+ require 'spree_id_verification/factories'
46
+ ```
47
+
48
+ ## Contributing
49
+
50
+ If you'd like to contribute, please take a look at the
51
+ [instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
52
+ pull request.
53
+
54
+ Copyright (c) 2020 [name of extension creator], released under the New BSD License
@@ -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_id_verification'
20
+ Rake::Task['extension:test_app'].invoke
21
+ end
File without changes
File without changes
@@ -0,0 +1,35 @@
1
+ module SpreeIdVerification
2
+ module Spree
3
+ module Admin
4
+
5
+ module UsersControllerDecorator
6
+ def verification
7
+ @user = ::Spree::User.find(params[:id])
8
+ end
9
+
10
+ def verify
11
+ @user = ::Spree::User.find(params[:id])
12
+ if @user.status.blank?
13
+ @user.status = 'pending'
14
+ end
15
+ @user.verify!
16
+
17
+ render :verification
18
+ end
19
+
20
+ def reject
21
+ @user = ::Spree::User.find(params[:id])
22
+ if @user.status.blank?
23
+ @user.status = 'pending'
24
+ end
25
+ @user.reject!
26
+
27
+ render :verification
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+
35
+ ::Spree::Admin::UsersController.prepend SpreeIdVerification::Spree::Admin::UsersControllerDecorator if ::Spree::Admin::UsersController.included_modules.exclude?(SpreeIdVerification::Spree::Admin::UsersControllerDecorator)
@@ -0,0 +1,25 @@
1
+ module Spree
2
+ class VerificationMailer < ::Spree::BaseMailer
3
+ # if you are using custom email templates
4
+ if Object.const_defined?(:EmailTemplate)
5
+ prepend_view_path ::EmailTemplate.resolver
6
+ end
7
+
8
+ def welcome_email
9
+ # verification pending
10
+ @user = params[:user]
11
+ @user_email = @user.email
12
+ subject = "#{Spree::Store.current.name} #{Spree.t('verification_mailer.welcome_email.subject')}"
13
+
14
+ mail(to: @user_email, from: from_address, subject: subject)
15
+ end
16
+
17
+ def verified_email
18
+ # you are verified
19
+ end
20
+
21
+ def rejected_email
22
+ # you are rejected
23
+ end
24
+ end
25
+ end
File without changes
@@ -0,0 +1,41 @@
1
+ module SpreeIdVerification
2
+ module Spree
3
+
4
+ class IdVerificationImage < ::Spree::Base
5
+ self.table_name = 'spree_id_verification_images'
6
+
7
+ # include ::Spree::Asset::Support::ActiveStorage
8
+ include Rails.application.routes.url_helpers
9
+
10
+ has_one_attached :attachment
11
+
12
+ validate :check_attachment_presence
13
+ validate :check_attachment_content_type
14
+
15
+ def get_image_url
16
+ if Rails.env.production?
17
+ self.attachment.service_url
18
+ else
19
+ url_for(self.attachment)
20
+ end
21
+ end
22
+
23
+ def accepted_image_types
24
+ %w(image/jpeg image/jpg image/png image/gif)
25
+ end
26
+
27
+ def check_attachment_presence
28
+ unless attachment.attached?
29
+ errors.add(:attachment, :attachment_must_be_present)
30
+ end
31
+ end
32
+
33
+ def check_attachment_content_type
34
+ if attachment.attached? && !attachment.content_type.in?(accepted_image_types)
35
+ errors.add(:attachment, :not_allowed_content_type)
36
+ end
37
+ end
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,52 @@
1
+ module SpreeIdVerification
2
+ module Spree
3
+
4
+ module UserDecorator
5
+ DEFAULT_ADMIN_ROLE = :admin
6
+
7
+ def self.prepended(base)
8
+ base.enum status: [:pending, :verified, :rejected],
9
+ _prefix: :status
10
+
11
+ base.has_one :id_verification_image, dependent: :destroy,
12
+ class_name: '::SpreeIdVerification::Spree::IdVerificationImage'
13
+
14
+ base.validates_associated :id_verification_image, on: :create
15
+
16
+ base.class_eval do
17
+ after_create :auto_verify!
18
+
19
+ state_machine :status, initial: :pending, action: :save_state do
20
+ event :verify do
21
+ transition to: :verified
22
+ end
23
+
24
+ event :reject do
25
+ transition to: :rejected
26
+ end
27
+ end
28
+
29
+ alias_method :save_state, :save
30
+
31
+ private
32
+
33
+ def auto_verify!
34
+ if spree_roles.exists?(name: DEFAULT_ADMIN_ROLE)
35
+ verify!
36
+ save
37
+ end
38
+ end
39
+ end # define state machine
40
+ end
41
+
42
+ def id_verification_image=(file)
43
+ build_id_verification_image(attachment: file)
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+
50
+ if ::Spree::User.included_modules.exclude?(SpreeIdVerification::Spree::UserDecorator)
51
+ ::Spree::User.prepend SpreeIdVerification::Spree::UserDecorator
52
+ end
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(
2
+ virtual_path: 'spree/shared/_user_form',
3
+ name: 'add_id_verification_image_to_user_form',
4
+ insert_after: '[data-hook="signup_below_password_fields"]',
5
+ partial: 'spree/shared/id_verification_fields'
6
+ )
File without changes
File without changes
@@ -0,0 +1,37 @@
1
+ <%= render partial: 'spree/admin/users/sidebar', locals: { current: :verification } %>
2
+
3
+ <% content_for :page_actions do %>
4
+ <% unless @user.try(:status_verified?) %>
5
+ <%= button_link_to Spree.t(:verify), spree.verify_admin_user_path(@user), class: "btn-success", method: :post %>
6
+ <%= button_link_to Spree.t(:reject), spree.reject_admin_user_path(@user), class: "btn btn-danger", method: :post %>
7
+ <% end %>
8
+ <% end %>
9
+
10
+ <% content_for :page_title do %>
11
+ <%= link_to @user.email, spree.edit_admin_user_url(@user) %> /
12
+ <%= Spree.t(:"admin.user.verification") %>
13
+ <% end %>
14
+
15
+ <div>
16
+ <div class="form-group">
17
+ <p>
18
+ <% if @user.status_verified? %>
19
+ <span class="badge badge-success"><%= @user.status %></span>
20
+ <% end %>
21
+
22
+ <% if @user.status_rejected? %>
23
+ <span class="badge badge-danger"><%= @user.status %></span>
24
+ <% end %>
25
+
26
+ <% if @user.status_pending? %>
27
+ <span class="badge badge-warning"><%= @user.status %></span>
28
+ <% end %>
29
+ </p>
30
+
31
+ <% if @user.id_verification_image.present? %>
32
+ <%= image_tag @user.id_verification_image.get_image_url, class: "img-fluid" %>
33
+ <% else %>
34
+ No image
35
+ <% end %>
36
+ </div>
37
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="form-group mb-5">
2
+ <%= f.label :id_verification_image, 'ID Verification', class: 'spree-flat-input' %>
3
+ <%= f.file_field :id_verification_image, required: true, class: 'spree-flat-input' %>
4
+ </div>
@@ -0,0 +1,2 @@
1
+ <h1>Hi, <%= @user.email %>!</h1>
2
+ <div>You are successfully registered! You need to wait for verification by admin before accessing our products!</div>
@@ -0,0 +1,3 @@
1
+ Hi, <%= @user.email %>!
2
+ You are successfully registered!
3
+ You need to wait for verification by admin before accessing our products!
@@ -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_id_verification/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1 @@
1
+ Spree::PermittedAttributes.user_attributes.push(:id_verification_image)
@@ -0,0 +1,10 @@
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
+ id_verification:
7
+ required: 'You are not verified user, please wait for awhile. Administrator should review your id.'
8
+ verification_mailer:
9
+ welcome_email:
10
+ subject: Successful registration
@@ -0,0 +1,11 @@
1
+ Spree::Core::Engine.add_routes do
2
+ namespace :admin, path: Spree.admin_path do
3
+ resources :users, only: [] do
4
+ member do
5
+ get :verification
6
+ post :verify
7
+ post :reject
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ class CreateSpreeIdVerificationImages < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :spree_id_verification_images do |t|
4
+ t.integer :attachment_width
5
+ t.integer :attachment_height
6
+ t.integer :attachment_file_size
7
+ t.integer :position, index: true
8
+ t.string :attachment_content_type
9
+ t.string :attachment_file_name
10
+ t.string :type, limit: 75
11
+ t.datetime :attachment_updated_at
12
+ t.text :alt
13
+
14
+ t.integer :user_id, null: false, index: true
15
+
16
+ t.timestamps null: false, precision: 6
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ # This migration comes from spree_id_verification (originally 20200828144231)
2
+ class AddStatusToUsers < ActiveRecord::Migration[5.1]
3
+ def up
4
+ # unless Rails.env.test?
5
+ # execute <<-SQL
6
+ # CREATE TYPE spree_user_status AS ENUM ('pending', 'rejected', 'verified');
7
+ # SQL
8
+
9
+ # add_column :spree_users, :status, :spree_user_status, default: 'pending'
10
+ # add_index :spree_users, :status
11
+ # else
12
+ add_column :spree_users, :status, :integer
13
+ # end
14
+ end
15
+
16
+ def down
17
+ # unless Rails.env.test?
18
+ # remove_column :spree_users, :status
19
+
20
+ # execute <<-SQL
21
+ # DROP TYPE spree_user_status;
22
+ # SQL
23
+ # else
24
+ remove_column :spree_users, :status
25
+ # end
26
+ end
27
+ end
@@ -0,0 +1,8 @@
1
+ class AddPendingDefaultValueToUsers < ActiveRecord::Migration[5.1]
2
+ def up
3
+ ::Spree::User.update_all(status: 'verified')
4
+ end
5
+
6
+ def down
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails-controller-testing"
6
+ gem "spree", "~> 3.7.0"
7
+ gem "sass-rails"
8
+
9
+ 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", "~> 4.0.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,9 @@
1
+
2
+ # This file was generated by Appraisal
3
+
4
+ source "https://rubygems.org"
5
+
6
+ gem "rails-controller-testing"
7
+ gem "spree", "~> 4.1.0"
8
+
9
+ 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 SpreeIdVerification
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ class_option :auto_run_migrations, type: :boolean, default: false
5
+
6
+ def add_migrations
7
+ run 'bundle exec rake railties:install:migrations FROM=spree_id_verification'
8
+ end
9
+
10
+ def run_migrations
11
+ run_migrations = options[:auto_run_migrations] || ['', '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_id_verification/engine'
4
+ require 'spree_id_verification/version'
@@ -0,0 +1,20 @@
1
+ module SpreeIdVerification
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_id_verification'
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
+ # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
+ #
4
+ # Example adding this to your spec_helper will load these Factories for use:
5
+ # require 'spree_id_verification/factories'
6
+ end
@@ -0,0 +1,18 @@
1
+ module SpreeIdVerification
2
+ module_function
3
+
4
+ # Returns the version of the currently loaded SpreeIdVerification as a
5
+ # <tt>Gem::Version</tt>.
6
+ def version
7
+ Gem::Version.new VERSION::STRING
8
+ end
9
+
10
+ module VERSION
11
+ MAJOR = 0
12
+ MINOR = 0
13
+ TINY = 1
14
+ PRE = 'alpha'.freeze
15
+
16
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
17
+ end
18
+ end
Binary file
@@ -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_id_verification/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.platform = Gem::Platform::RUBY
9
+ s.name = 'spree_id_verification'
10
+ s.version = SpreeIdVerification.version
11
+ s.summary = 'Add extension summary here'
12
+ s.description = 'Add (optional) extension description here'
13
+ s.required_ruby_version = '>= 2.2.7'
14
+
15
+ s.author = 'You'
16
+ s.email = 'you@example.com'
17
+ s.homepage = 'https://github.com/your-github-handle/spree_id_verification'
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 = '>= 3.2.0', '< 5.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
+ s.add_dependency 'state_machines-activerecord', '~> 0.6'
30
+ s.add_dependency 'state_machines-activemodel', '~> 0.7'
31
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_id_verification
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha
5
+ platform: ruby
6
+ authors:
7
+ - You
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-01 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: 3.2.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.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: 3.2.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '5.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 3.2.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '5.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: 3.2.0
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '5.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 3.2.0
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '5.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: state_machines-activerecord
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '0.6'
94
+ type: :runtime
95
+ prerelease: false
96
+ version_requirements: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '0.6'
101
+ - !ruby/object:Gem::Dependency
102
+ name: state_machines-activemodel
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '0.7'
108
+ type: :runtime
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: '0.7'
115
+ description: Add (optional) extension description here
116
+ email: you@example.com
117
+ executables: []
118
+ extensions: []
119
+ extra_rdoc_files: []
120
+ files:
121
+ - ".gitignore"
122
+ - ".rspec"
123
+ - ".rubocop.yml"
124
+ - ".travis.yml"
125
+ - Appraisals
126
+ - Gemfile
127
+ - LICENSE
128
+ - README.md
129
+ - Rakefile
130
+ - app/.gitkeep
131
+ - app/controllers/.gitkeep
132
+ - app/controllers/spree_id_verification/spree/admin/users_controller_decorator.rb
133
+ - app/mailers/spree/verification_mailer.rb
134
+ - app/models/.gitkeep
135
+ - app/models/spree_id_verification/spree/id_verification_image.rb
136
+ - app/models/spree_id_verification/spree/user_decorator.rb
137
+ - app/overrides/add_id_verification_image_to_user_form.rb
138
+ - app/services/.gitkeep
139
+ - app/views/.gitkeep
140
+ - app/views/spree/admin/users/verification.html.erb
141
+ - app/views/spree/shared/_id_verification_fields.html.erb
142
+ - app/views/spree/verification_mailer/welcome_email.html.erb
143
+ - app/views/spree/verification_mailer/welcome_email.text.erb
144
+ - bin/rails
145
+ - config/initializers/permitted_attributes.rb
146
+ - config/locales/en.yml
147
+ - config/routes.rb
148
+ - db/migrate/20200827233305_create_spree_id_verification_images.rb
149
+ - db/migrate/20200828144231_add_status_to_users.rb
150
+ - db/migrate/20200902162323_add_pending_default_value_to_users.rb
151
+ - gemfiles/spree_3_7.gemfile
152
+ - gemfiles/spree_4_0.gemfile
153
+ - gemfiles/spree_4_1.gemfile
154
+ - gemfiles/spree_master.gemfile
155
+ - lib/generators/spree_id_verification/install/install_generator.rb
156
+ - lib/spree_id_verification.rb
157
+ - lib/spree_id_verification/engine.rb
158
+ - lib/spree_id_verification/factories.rb
159
+ - lib/spree_id_verification/version.rb
160
+ - spec/fixtures/example.png
161
+ - spree_id_verification.gemspec
162
+ homepage: https://github.com/your-github-handle/spree_id_verification
163
+ licenses:
164
+ - BSD-3-Clause
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: 2.2.7
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">"
178
+ - !ruby/object:Gem::Version
179
+ version: 1.3.1
180
+ requirements:
181
+ - none
182
+ rubygems_version: 3.0.1
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: Add extension summary here
186
+ test_files: []