spree_abandoned_cart 0.3.0 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -0
- data/.gitlab-ci.yml +15 -0
- data/.rspec +1 -0
- data/Gemfile +8 -0
- data/LICENSE +26 -0
- data/README.md +69 -0
- data/Rakefile +15 -0
- data/app/controllers/spree/admin/abandoned_orders_controller.rb +35 -0
- data/app/mailers/spree/abandoned_cart_mailer.rb +20 -0
- data/app/models/order_decorator.rb +38 -0
- data/app/models/order_updater_decorator.rb +25 -0
- data/app/models/spree/abandoned_cart_email_configuration.rb +5 -0
- data/app/models/spree/abandoned_order.rb +30 -0
- data/app/overrides/add_button_to_orders_tab_for_abandoned_index_page.rb +8 -0
- data/app/views/spree/abandoned_cart_mailer/abandoned_email.html.erb +145 -0
- data/app/views/spree/abandoned_cart_mailer/abandoned_second_email.html.erb +145 -0
- data/app/views/spree/abandoned_cart_mailer/abandoned_third_email.html.erb +145 -0
- data/app/views/spree/admin/abandoned_orders/_filters_bar.html.haml +49 -0
- data/app/views/spree/admin/abandoned_orders/_list.html.haml +22 -0
- data/app/views/spree/admin/abandoned_orders/_list_respond.js.erb +1 -0
- data/app/views/spree/admin/abandoned_orders/_order_summary.html.haml +16 -0
- data/app/views/spree/admin/abandoned_orders/_titles.html.haml +6 -0
- data/app/views/spree/admin/abandoned_orders/index.html.haml +3 -0
- data/app/views/spree/admin/abandoned_orders/index.js.haml +1 -0
- data/app/views/spree/admin/abandoned_orders/show.html.haml +2 -0
- data/config/initializers/load_preferences.rb +5 -0
- data/config/locales/en.yml +17 -0
- data/config/locales/ru.yml +17 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20130722151112_add_abandoned_email_sent_at_to_spree_orders.rb +5 -0
- data/db/migrate/20150825122125_create_spree_abandoned_orders.rb +12 -0
- data/lib/generators/spree_abandoned_cart/install/install_generator.rb +21 -0
- data/lib/spree_abandoned_cart.rb +3 -0
- data/lib/spree_abandoned_cart/engine.rb +22 -0
- data/lib/spree_abandoned_cart/factories.rb +6 -0
- data/script/rails +7 -0
- data/spec/models/order_spec.rb +35 -0
- data/spec/spec_helper.rb +86 -0
- data/spree_abandoned_cart.gemspec +38 -0
- metadata +68 -16
data/config/routes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateSpreeAbandonedOrders < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :spree_abandoned_orders do |t|
|
4
|
+
t.belongs_to :spree_order
|
5
|
+
t.integer :send_emails_count, default: 0, null: false
|
6
|
+
t.boolean :order_accomplished, default: false, null: false
|
7
|
+
t.datetime :accomplished_at, default: nil
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module SpreeAbandonedCart
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
class_option :auto_run_migrations, type: :boolean, default: false
|
6
|
+
|
7
|
+
def add_migrations
|
8
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_abandoned_cart'
|
9
|
+
end
|
10
|
+
|
11
|
+
def run_migrations
|
12
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
|
13
|
+
if run_migrations
|
14
|
+
run 'bundle exec rake db:migrate'
|
15
|
+
else
|
16
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SpreeAbandonedCart
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
require 'spree/core'
|
4
|
+
isolate_namespace Spree
|
5
|
+
engine_name 'spree_abandoned_cart'
|
6
|
+
|
7
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
8
|
+
|
9
|
+
# use rspec for tests
|
10
|
+
config.generators do |g|
|
11
|
+
g.test_framework :rspec
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.activate
|
15
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
16
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
config.to_prepare &method(:activate).to_proc
|
21
|
+
end
|
22
|
+
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_abandoned_cart/factories'
|
6
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
2
|
+
|
3
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
ENGINE_PATH = File.expand_path('../../lib/spree_abandoned_cart/engine', __FILE__)
|
5
|
+
|
6
|
+
require 'rails/all'
|
7
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Spree::Order do
|
4
|
+
|
5
|
+
let(:order) { create :order }
|
6
|
+
|
7
|
+
describe "#send_abandoned_email" do
|
8
|
+
|
9
|
+
let(:mailer) { double "Mailer", deliver_now: true }
|
10
|
+
|
11
|
+
it "returns if the order has no line items" do
|
12
|
+
Spree::AbandonedCartMailer.should_not receive(:abandoned_email)
|
13
|
+
|
14
|
+
order.send_abandoned_email
|
15
|
+
end
|
16
|
+
|
17
|
+
it "sends an email" do
|
18
|
+
Spree::AbandonedCartMailer.should receive(:abandoned_email).and_return(mailer)
|
19
|
+
|
20
|
+
order_with_line_items = create :order_with_line_items, line_items_count: 1
|
21
|
+
order_with_line_items.send_abandoned_email
|
22
|
+
end
|
23
|
+
|
24
|
+
it "sets the email sent at" do
|
25
|
+
Spree::AbandonedCartMailer.should receive(:abandoned_email).and_return(mailer)
|
26
|
+
|
27
|
+
order_with_line_items = create :order_with_line_items, line_items_count: 1
|
28
|
+
order_with_line_items.send_abandoned_email
|
29
|
+
|
30
|
+
expect(order_with_line_items.abandoned_email_sent_at).not_to be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Run Coverage report
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start do
|
4
|
+
add_group 'Controllers', 'app/controllers'
|
5
|
+
add_group 'Helpers', 'app/helpers'
|
6
|
+
add_group 'Mailers', 'app/mailers'
|
7
|
+
add_group 'Models', 'app/models'
|
8
|
+
add_group 'Views', 'app/views'
|
9
|
+
add_group 'Libraries', 'lib'
|
10
|
+
end
|
11
|
+
|
12
|
+
# Configure Rails Environment
|
13
|
+
ENV['RAILS_ENV'] = 'test'
|
14
|
+
|
15
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
16
|
+
|
17
|
+
require 'rspec/rails'
|
18
|
+
require 'database_cleaner'
|
19
|
+
require 'ffaker'
|
20
|
+
require 'factory_bot_rails'
|
21
|
+
|
22
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
23
|
+
# in spec/support/ and its subdirectories.
|
24
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
25
|
+
|
26
|
+
# Requires factories defined in spree_core
|
27
|
+
require 'spree/testing_support/factories'
|
28
|
+
require 'spree/testing_support/controller_requests'
|
29
|
+
require 'spree/testing_support/authorization_helpers'
|
30
|
+
require 'spree/testing_support/url_helpers'
|
31
|
+
|
32
|
+
# Requires factories defined in lib/spree_abandoned_cart/factories.rb
|
33
|
+
require 'spree_abandoned_cart/factories'
|
34
|
+
|
35
|
+
RSpec.configure do |config|
|
36
|
+
config.include FactoryBot::Syntax::Methods
|
37
|
+
|
38
|
+
# == URL Helpers
|
39
|
+
#
|
40
|
+
# Allows access to Spree's routes in specs:
|
41
|
+
#
|
42
|
+
# visit spree.admin_path
|
43
|
+
# current_path.should eql(spree.products_path)
|
44
|
+
config.include Spree::TestingSupport::UrlHelpers
|
45
|
+
|
46
|
+
# == Mock Framework
|
47
|
+
#
|
48
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
49
|
+
#
|
50
|
+
# config.mock_with :mocha
|
51
|
+
# config.mock_with :flexmock
|
52
|
+
# config.mock_with :rr
|
53
|
+
config.mock_with :rspec
|
54
|
+
config.color = true
|
55
|
+
|
56
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
57
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
58
|
+
|
59
|
+
# Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
|
60
|
+
# to cleanup after each test instead. Without transactional fixtures set to false the records created
|
61
|
+
# to setup a test will be unavailable to the browser, which runs under a seperate server instance.
|
62
|
+
config.use_transactional_fixtures = false
|
63
|
+
|
64
|
+
# Ensure Suite is set to use transactions for speed.
|
65
|
+
config.before :suite do
|
66
|
+
DatabaseCleaner.strategy = :transaction
|
67
|
+
DatabaseCleaner.clean_with :truncation
|
68
|
+
end
|
69
|
+
|
70
|
+
config.before(:each) do
|
71
|
+
if Capybara.current_driver == :rack_test
|
72
|
+
DatabaseCleaner.strategy = :transaction
|
73
|
+
else
|
74
|
+
DatabaseCleaner.strategy = :truncation
|
75
|
+
end
|
76
|
+
|
77
|
+
DatabaseCleaner.start
|
78
|
+
end
|
79
|
+
|
80
|
+
# After each spec clean the database.
|
81
|
+
config.after :each do
|
82
|
+
DatabaseCleaner.clean
|
83
|
+
end
|
84
|
+
|
85
|
+
config.fail_fast = ENV['FAIL_FAST'] || false
|
86
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.name = 'spree_abandoned_cart'
|
9
|
+
s.version = '0.3.3'
|
10
|
+
s.summary = "Base 'abandoned cart functionality' for Spree E-commerce"
|
11
|
+
s.description = "Base 'abandoned cart functionality' for Spree E-commerce"
|
12
|
+
s.required_ruby_version = '>= 1.9.3'
|
13
|
+
|
14
|
+
s.author = 'Jet Ruby Agency'
|
15
|
+
s.email = 'info@jetruby.com'
|
16
|
+
s.homepage = 'http://jetruby.com/'
|
17
|
+
|
18
|
+
s.files = `git ls-files -z`.split("\x0")
|
19
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
|
21
|
+
s.require_path = 'lib'
|
22
|
+
s.requirements << 'none'
|
23
|
+
|
24
|
+
s.add_dependency 'spree_core', '~> 3.6'
|
25
|
+
s.add_runtime_dependency 'haml'
|
26
|
+
|
27
|
+
s.add_development_dependency 'capybara', '~> 3.2.1'
|
28
|
+
s.add_development_dependency 'coffee-rails'
|
29
|
+
s.add_development_dependency 'database_cleaner'
|
30
|
+
s.add_development_dependency 'factory_bot_rails', '~> 4.10.0'
|
31
|
+
s.add_development_dependency 'ffaker'
|
32
|
+
s.add_development_dependency 'rspec-rails', '~> 3.7.1'
|
33
|
+
s.add_development_dependency 'rails-controller-testing'
|
34
|
+
s.add_development_dependency 'sass-rails'
|
35
|
+
s.add_development_dependency 'selenium-webdriver'
|
36
|
+
s.add_development_dependency 'simplecov'
|
37
|
+
s.add_development_dependency 'sqlite3'
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_abandoned_cart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jet Ruby Agency
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: '3.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.
|
26
|
+
version: '3.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: haml
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: capybara
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.2.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.2.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: coffee-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,19 +81,19 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: factory_bot_rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 4.10.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 4.10.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: ffaker
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,6 +110,20 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec-rails
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 3.7.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 3.7.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rails-controller-testing
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - ">="
|
@@ -183,7 +197,46 @@ email: info@jetruby.com
|
|
183
197
|
executables: []
|
184
198
|
extensions: []
|
185
199
|
extra_rdoc_files: []
|
186
|
-
files:
|
200
|
+
files:
|
201
|
+
- ".gitignore"
|
202
|
+
- ".gitlab-ci.yml"
|
203
|
+
- ".rspec"
|
204
|
+
- Gemfile
|
205
|
+
- LICENSE
|
206
|
+
- README.md
|
207
|
+
- Rakefile
|
208
|
+
- app/controllers/spree/admin/abandoned_orders_controller.rb
|
209
|
+
- app/mailers/spree/abandoned_cart_mailer.rb
|
210
|
+
- app/models/order_decorator.rb
|
211
|
+
- app/models/order_updater_decorator.rb
|
212
|
+
- app/models/spree/abandoned_cart_email_configuration.rb
|
213
|
+
- app/models/spree/abandoned_order.rb
|
214
|
+
- app/overrides/add_button_to_orders_tab_for_abandoned_index_page.rb
|
215
|
+
- app/views/spree/abandoned_cart_mailer/abandoned_email.html.erb
|
216
|
+
- app/views/spree/abandoned_cart_mailer/abandoned_second_email.html.erb
|
217
|
+
- app/views/spree/abandoned_cart_mailer/abandoned_third_email.html.erb
|
218
|
+
- app/views/spree/admin/abandoned_orders/_filters_bar.html.haml
|
219
|
+
- app/views/spree/admin/abandoned_orders/_list.html.haml
|
220
|
+
- app/views/spree/admin/abandoned_orders/_list_respond.js.erb
|
221
|
+
- app/views/spree/admin/abandoned_orders/_order_summary.html.haml
|
222
|
+
- app/views/spree/admin/abandoned_orders/_titles.html.haml
|
223
|
+
- app/views/spree/admin/abandoned_orders/index.html.haml
|
224
|
+
- app/views/spree/admin/abandoned_orders/index.js.haml
|
225
|
+
- app/views/spree/admin/abandoned_orders/show.html.haml
|
226
|
+
- config/initializers/load_preferences.rb
|
227
|
+
- config/locales/en.yml
|
228
|
+
- config/locales/ru.yml
|
229
|
+
- config/routes.rb
|
230
|
+
- db/migrate/20130722151112_add_abandoned_email_sent_at_to_spree_orders.rb
|
231
|
+
- db/migrate/20150825122125_create_spree_abandoned_orders.rb
|
232
|
+
- lib/generators/spree_abandoned_cart/install/install_generator.rb
|
233
|
+
- lib/spree_abandoned_cart.rb
|
234
|
+
- lib/spree_abandoned_cart/engine.rb
|
235
|
+
- lib/spree_abandoned_cart/factories.rb
|
236
|
+
- script/rails
|
237
|
+
- spec/models/order_spec.rb
|
238
|
+
- spec/spec_helper.rb
|
239
|
+
- spree_abandoned_cart.gemspec
|
187
240
|
homepage: http://jetruby.com/
|
188
241
|
licenses: []
|
189
242
|
metadata: {}
|
@@ -204,9 +257,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
257
|
requirements:
|
205
258
|
- none
|
206
259
|
rubyforge_project:
|
207
|
-
rubygems_version: 2.
|
260
|
+
rubygems_version: 2.6.13
|
208
261
|
signing_key:
|
209
262
|
specification_version: 4
|
210
263
|
summary: Base 'abandoned cart functionality' for Spree E-commerce
|
211
264
|
test_files: []
|
212
|
-
has_rdoc:
|