├── .rspec
├── app
├── assets
│ ├── stylesheets
│ │ └── spree
│ │ │ └── frontend
│ │ │ └── spree_recently_viewed.css
│ └── javascripts
│ │ └── spree
│ │ └── frontend
│ │ ├── spree_recently_viewed.js
│ │ └── add_recently_viewed_products.js
├── models
│ └── spree
│ │ └── product_decorator.rb
├── views
│ └── spree
│ │ ├── shared
│ │ └── _add_recently_viewed_products.html.erb
│ │ └── products
│ │ └── recently_viewed.html.erb
├── overrides
│ └── spree
│ │ ├── shared
│ │ └── _products
│ │ │ └── add_recently_viewed_products_to_products_index.rb
│ │ └── products
│ │ └── show
│ │ └── add_recently_viewed_products_to_products_show.rb
├── helpers
│ └── spree
│ │ └── recently_viewed_products_helper.rb
└── controllers
│ └── spree
│ └── products_controller_decorator.rb
├── config
├── locales
│ ├── cs.yml
│ ├── ru.yml
│ ├── de.yml
│ ├── en.yml
│ ├── es.yml
│ ├── nl.yml
│ ├── pt.yml
│ ├── sv.yml
│ └── pl.yml
└── routes.rb
├── .rubocop.yml
├── Gemfile
├── spec
├── support
│ ├── factory_girl.rb
│ ├── spree.rb
│ ├── database_cleaner.rb
│ └── capybara.rb
├── features
│ └── recently_viewed_spec.rb
├── spec_helper.rb
└── models
│ └── spree
│ └── product_decorator_spec.rb
├── .byebug_history
├── .gitignore
├── lib
├── spree
│ └── recently_viewed_setting.rb
├── spree_recently_viewed.rb
├── spree_recently_viewed
│ ├── version.rb
│ └── engine.rb
└── generators
│ └── spree_recently_viewed
│ └── install
│ └── install_generator.rb
├── bin
└── rails.rb
├── gemfiles
├── spree_4_1.gemfile
├── spree_4_0.gemfile
├── spree_3_7.gemfile
└── spree_master.gemfile
├── CHANGELOG.md
├── Rakefile
├── .hound.yml
├── Appraisals
├── .travis.yml
├── LICENSE.md
├── README.md
├── spree_recently_viewed.gemspec
└── CONTRIBUTING.md
/.rspec:
--------------------------------------------------------------------------------
1 | --color
2 | -r spec_helper
3 | -f documentation
4 | -r pry
5 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/spree/frontend/spree_recently_viewed.css:
--------------------------------------------------------------------------------
1 | /*
2 | *= require spree/frontend
3 | */
4 |
--------------------------------------------------------------------------------
/config/locales/cs.yml:
--------------------------------------------------------------------------------
1 | ---
2 | cs:
3 | spree:
4 | recently_viewed_products: "Nedávno zhlédnuté"
5 |
--------------------------------------------------------------------------------
/config/locales/ru.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ru:
3 | spree:
4 | recently_viewed_products: "Недавно Просмотренные"
5 |
--------------------------------------------------------------------------------
/config/locales/de.yml:
--------------------------------------------------------------------------------
1 | ---
2 | de:
3 | spree:
4 | recently_viewed_products: "Zuletzt Angesehene Produkte"
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | ---
2 | en:
3 | spree:
4 | recently_viewed_products: "Recently Viewed Products"
5 |
--------------------------------------------------------------------------------
/config/locales/es.yml:
--------------------------------------------------------------------------------
1 | ---
2 | es:
3 | spree:
4 | recently_viewed_products: "Productos vistos recientemente"
--------------------------------------------------------------------------------
/config/locales/nl.yml:
--------------------------------------------------------------------------------
1 | ---
2 | nl:
3 | spree:
4 | recently_viewed_products: "Recent Bekeken Producten"
5 |
--------------------------------------------------------------------------------
/config/locales/pt.yml:
--------------------------------------------------------------------------------
1 | ---
2 | pt:
3 | spree:
4 | recently_viewed_products: "Produtos vistos recentemente"
--------------------------------------------------------------------------------
/config/locales/sv.yml:
--------------------------------------------------------------------------------
1 | ---
2 | sv:
3 | spree:
4 | recently_viewed_products: "Nyligen visade produkter"
5 |
--------------------------------------------------------------------------------
/config/locales/pl.yml:
--------------------------------------------------------------------------------
1 | ---
2 | pl:
3 | spree:
4 | recently_viewed_products: "Ostatnio przeglądane produkty"
5 |
--------------------------------------------------------------------------------
/.rubocop.yml:
--------------------------------------------------------------------------------
1 | ---
2 | inherit_from: .hound.yml
3 |
4 | AllCops:
5 | Exclude:
6 | - spec/dummy/**/*
7 | - bin/*
8 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Spree::Core::Engine.add_routes do
2 | get '/recently_viewed_products' => 'products#recently_viewed'
3 | end
4 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | branch = 'master'
4 | gem 'spree', github: 'spree/spree', branch: branch
5 |
6 | gemspec
7 |
--------------------------------------------------------------------------------
/spec/support/factory_girl.rb:
--------------------------------------------------------------------------------
1 | require 'factory_bot'
2 |
3 | RSpec.configure do |config|
4 | config.include FactoryBot::Syntax::Methods
5 | end
6 |
--------------------------------------------------------------------------------
/app/assets/javascripts/spree/frontend/spree_recently_viewed.js:
--------------------------------------------------------------------------------
1 | //= require spree/frontend
2 | //= require spree/frontend/add_recently_viewed_products
3 |
--------------------------------------------------------------------------------
/.byebug_history:
--------------------------------------------------------------------------------
1 | c
2 | n
3 | c
4 | n
5 | c
6 | exception
7 | n
8 | c
9 | n
10 | c
11 | n
12 | c
13 | n
14 | c
15 | n
16 | c
17 | save_and_open_page
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.swp
2 | Gemfile.lock
3 | .rvmrc
4 | spec/dummy
5 | .DS_Store
6 | coverage
7 | .bundle
8 | .ruby-version
9 | .ruby-gemset
10 | gemfiles/*.gemfile.lock
11 |
--------------------------------------------------------------------------------
/lib/spree/recently_viewed_setting.rb:
--------------------------------------------------------------------------------
1 | module Spree
2 | class RecentlyViewedSetting < Preferences::Configuration
3 | preference :recently_viewed_products_max_count, :integer, default: 5
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/bin/rails.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | ENGINE_ROOT = File.expand_path('../..', __FILE__)
4 | ENGINE_PATH = File.expand_path('../../lib/spree_recently_viewed/engine', __FILE__)
5 |
6 | require 'rails/all'
7 | require 'rails/engine/commands'
8 |
--------------------------------------------------------------------------------
/gemfiles/spree_4_1.gemfile:
--------------------------------------------------------------------------------
1 | # This file was generated by Appraisal
2 |
3 | source "https://rubygems.org"
4 |
5 | gem "spree", "~> 4.1.0"
6 | gem "spree_auth_devise", "~> 4.1"
7 | gem "rails-controller-testing"
8 |
9 | gemspec path: "../"
10 |
--------------------------------------------------------------------------------
/gemfiles/spree_4_0.gemfile:
--------------------------------------------------------------------------------
1 | # This file was generated by Appraisal
2 |
3 | source "https://rubygems.org"
4 |
5 | gem "spree", "~> 4.0.0.rc2"
6 | gem "spree_auth_devise", "~> 4.0"
7 | gem "rails-controller-testing"
8 |
9 | gemspec path: "../"
10 |
--------------------------------------------------------------------------------
/app/models/spree/product_decorator.rb:
--------------------------------------------------------------------------------
1 | module Spree::ProductDecorator
2 | def self.prepended(base)
3 | def base.find_by_array_of_ids(ids)
4 | where(id: ids)
5 | end
6 | end
7 | end
8 |
9 | Spree::Product.prepend Spree::ProductDecorator
10 |
--------------------------------------------------------------------------------
/app/views/spree/shared/_add_recently_viewed_products.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/lib/spree_recently_viewed.rb:
--------------------------------------------------------------------------------
1 | require 'spree_core'
2 | require 'spree_extension'
3 | require 'spree_recently_viewed/engine'
4 | require 'spree_recently_viewed/version'
5 | require 'deface'
6 |
7 | module Spree
8 | module RecentlyViewed
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/gemfiles/spree_3_7.gemfile:
--------------------------------------------------------------------------------
1 | # This file was generated by Appraisal
2 |
3 | source "https://rubygems.org"
4 |
5 | gem "spree", "~> 3.7.0"
6 | gem "spree_auth_devise", "~> 3.5"
7 | gem "rails-controller-testing"
8 | gem "sass-rails"
9 |
10 | gemspec path: "../"
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | #### v2.0.0
4 |
5 | * Preferences class moved to lib folder and renamed to `Spree::RecentlyViewedSetting`.
6 | * Updated layout for Spree `v3.0.0.beta` that now uses Bootstrap.
7 | * `Spree::BaseHelper` methods prefix renaming from `get_` to `cache_`.
8 |
--------------------------------------------------------------------------------
/app/assets/javascripts/spree/frontend/add_recently_viewed_products.js:
--------------------------------------------------------------------------------
1 | Spree.fetch_recently_viewed_products = (productId = "") => {
2 | $.ajax({
3 | url: Spree.pathFor("recently_viewed_products?product_id=" + productId),
4 | success: (data) =>
5 | $("#recently_viewed_container").html(data)
6 | })
7 | };
8 |
--------------------------------------------------------------------------------
/gemfiles/spree_master.gemfile:
--------------------------------------------------------------------------------
1 | # This file was generated by Appraisal
2 |
3 | source "https://rubygems.org"
4 |
5 | gem "spree", github: "spree/spree", branch: "master"
6 | gem "spree_auth_devise", github: "spree/spree_auth_devise", branch: "master"
7 | gem "rails-controller-testing"
8 |
9 | gemspec path: "../"
10 |
--------------------------------------------------------------------------------
/app/overrides/spree/shared/_products/add_recently_viewed_products_to_products_index.rb:
--------------------------------------------------------------------------------
1 | Deface::Override.new(
2 | virtual_path: 'spree/shared/_products',
3 | name: 'add_recently_viewed_products_to_products_index',
4 | insert_after: "#products[data-hook]",
5 | partial: 'spree/shared/add_recently_viewed_products'
6 | )
7 |
--------------------------------------------------------------------------------
/app/overrides/spree/products/show/add_recently_viewed_products_to_products_show.rb:
--------------------------------------------------------------------------------
1 | Deface::Override.new(
2 | virtual_path: 'spree/products/show',
3 | name: 'add_recently_viewed_products_to_products_show',
4 | insert_after: "#product-description, [data-hook='product_description']",
5 | partial: 'spree/shared/add_recently_viewed_products'
6 | )
7 |
--------------------------------------------------------------------------------
/spec/support/spree.rb:
--------------------------------------------------------------------------------
1 | require 'spree/testing_support/factories'
2 | require 'spree/testing_support/controller_requests'
3 | require 'spree/testing_support/authorization_helpers'
4 | require 'spree/testing_support/capybara_ext'
5 |
6 | RSpec.configure do |config|
7 | config.include Spree::TestingSupport::ControllerRequests, type: :controller
8 | end
9 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require 'bundler'
2 | Bundler::GemHelper.install_tasks
3 |
4 | require 'rspec/core/rake_task'
5 | require 'spree/testing_support/common_rake'
6 |
7 | RSpec::Core::RakeTask.new
8 |
9 | task default: [:spec]
10 |
11 | desc 'Generates a dummy app for testing'
12 | task :test_app do
13 | ENV['LIB_NAME'] = 'spree_recently_viewed'
14 | Rake::Task['common:test_app'].invoke
15 | end
16 |
--------------------------------------------------------------------------------
/app/helpers/spree/recently_viewed_products_helper.rb:
--------------------------------------------------------------------------------
1 | module Spree
2 | module RecentlyViewedProductsHelper
3 | def cached_recently_viewed_products_ids
4 | (cookies['recently_viewed_products'] || '').split(', ')
5 | end
6 |
7 | def cached_recently_viewed_products
8 | Spree::Product.find_by_array_of_ids(cached_recently_viewed_products_ids)
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/lib/spree_recently_viewed/version.rb:
--------------------------------------------------------------------------------
1 | module SpreeRecentlyViewed
2 | module_function
3 |
4 | # Returns the version of the currently loaded SpreeRecentlyViewed as a
5 | # Gem::Version.
6 | def version
7 | Gem::Version.new VERSION::STRING
8 | end
9 |
10 | module VERSION
11 | MAJOR = 3
12 | MINOR = 3
13 | TINY = 0
14 |
15 | STRING = [MAJOR, MINOR, TINY].compact.join('.')
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/.hound.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # Too picky.
3 | LineLength:
4 | Enabled: false
5 |
6 | # This should truly be on for well documented gems.
7 | Documentation:
8 | Enabled: false
9 |
10 | # Neatly aligned code is too swell.
11 | SpaceBeforeFirstArg:
12 | Enabled: false
13 |
14 | # Don't mess with RSpec DSL.
15 | Blocks:
16 | Exclude:
17 | - 'spec/**/*'
18 |
19 | # Avoid contradictory style rules by enforce single quotes.
20 | StringLiterals:
21 | EnforcedStyle: single_quotes
22 |
--------------------------------------------------------------------------------
/lib/generators/spree_recently_viewed/install/install_generator.rb:
--------------------------------------------------------------------------------
1 | module SpreeRecentlyViewed
2 | module Generators
3 | class InstallGenerator < Rails::Generators::Base
4 | def self.source_paths
5 | paths = self.superclass.source_paths
6 | paths.flatten
7 | end
8 |
9 | def add_javascripts
10 | append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_recently_viewed\n"
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/app/views/spree/products/recently_viewed.html.erb:
--------------------------------------------------------------------------------
1 | <% if cached_recently_viewed_products.any? %>
2 |
3 |
<%= Spree.t(:recently_viewed_products) %>
4 |
5 |
6 | <% cached_recently_viewed_products.each do |product| %>
7 | - <%= link_to product.name, product %>
8 | <% end %>
9 |
10 |
11 | <% end %>
12 |
--------------------------------------------------------------------------------
/spec/support/database_cleaner.rb:
--------------------------------------------------------------------------------
1 | require 'database_cleaner'
2 |
3 | RSpec.configure do |config|
4 | config.before(:suite) do
5 | DatabaseCleaner.clean_with :truncation
6 | end
7 |
8 | config.before do
9 | DatabaseCleaner.strategy = :transaction
10 | end
11 |
12 | config.before(:each, :js) do
13 | DatabaseCleaner.strategy = :truncation
14 | end
15 |
16 | config.before do
17 | DatabaseCleaner.start
18 | end
19 |
20 | config.after do
21 | DatabaseCleaner.clean
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/spec/support/capybara.rb:
--------------------------------------------------------------------------------
1 | require 'capybara/rspec'
2 | require 'capybara/rails'
3 | require 'capybara-screenshot/rspec'
4 | require 'selenium-webdriver'
5 |
6 | RSpec.configure do |config|
7 | Capybara.save_and_open_page_path = ENV['CIRCLE_ARTIFACTS'] if ENV['CIRCLE_ARTIFACTS']
8 |
9 | Capybara.register_driver :chrome do |app|
10 | Capybara::Selenium::Driver.new app,
11 | browser: :chrome,
12 | options: Selenium::WebDriver::Chrome::Options.new(args: %w[disable-popup-blocking headless disable-gpu window-size=1920,1080])
13 | end
14 |
15 | Capybara.javascript_driver = :chrome
16 | end
17 |
--------------------------------------------------------------------------------
/Appraisals:
--------------------------------------------------------------------------------
1 | appraise 'spree-3-5' do
2 | gem 'spree', '~> 3.5.0'
3 | gem 'spree_auth_devise', '~> 3.3.0'
4 | gem 'rails-controller-testing'
5 | end
6 |
7 | appraise 'spree-3-7' do
8 | gem 'spree', '~> 3.7.0'
9 | gem 'spree_auth_devise', '~> 3.5'
10 | gem 'rails-controller-testing'
11 | end
12 |
13 | appraise 'spree-4-0' do
14 | gem 'spree', '~> 4.0.0.rc2'
15 | gem 'spree_auth_devise', '~> 4.0'
16 | gem 'rails-controller-testing'
17 | end
18 |
19 | appraise 'spree-master' do
20 | gem 'spree', github: 'spree/spree', branch: 'master'
21 | gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
22 | gem 'rails-controller-testing'
23 | end
24 |
--------------------------------------------------------------------------------
/spec/features/recently_viewed_spec.rb:
--------------------------------------------------------------------------------
1 | RSpec.feature 'Recently Viewed Products', :js do
2 | background do
3 | %w(Mug Shirt Jersey).each { |name| create(:product, name: name.to_s) }
4 | create(:store, default: true)
5 | end
6 |
7 | scenario 'keep track of recently viewed products', js: true do
8 | if Spree.version.to_f < 4.1
9 | visit spree.root_path
10 | click_link 'Mug'
11 | wait_for_ajax
12 | click_link 'Home'
13 | click_link 'Jersey'
14 | wait_for_ajax
15 | click_link 'Home'
16 | within(:css, 'ul#recently_viewed_products') do
17 | expect(page).to have_text 'Mug'
18 | expect(page).to have_text 'Jersey'
19 | end
20 | end
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require 'simplecov'
2 | SimpleCov.start 'rails'
3 |
4 | ENV['RAILS_ENV'] ||= 'test'
5 |
6 | begin
7 | require File.expand_path('../dummy/config/environment', __FILE__)
8 | rescue LoadError
9 | puts 'Could not load dummy application. Please ensure you have run `bundle exec rake test_app`'
10 | exit
11 | end
12 |
13 | require 'rspec/rails'
14 | require 'ffaker'
15 |
16 | RSpec.configure do |config|
17 | config.infer_spec_type_from_file_location!
18 | config.raise_errors_for_deprecations!
19 | config.use_transactional_fixtures = false
20 | config.mock_with :rspec
21 |
22 | config.expect_with :rspec do |expectations|
23 | expectations.syntax = :expect
24 | end
25 | end
26 |
27 | Dir[File.join(File.dirname(__FILE__), '/support/**/*.rb')].each { |file| require file }
28 |
--------------------------------------------------------------------------------
/lib/spree_recently_viewed/engine.rb:
--------------------------------------------------------------------------------
1 | module SpreeRecentlyViewed
2 | class Engine < Rails::Engine
3 | require 'spree/core'
4 | isolate_namespace Spree
5 | engine_name 'spree_recently_viewed'
6 |
7 | config.autoload_paths += %W(#{config.root}/lib)
8 |
9 | initializer 'spree.recently_viewed.environment', before: :load_config_initializers do
10 | Spree::RecentlyViewed::Config = Spree::RecentlyViewedSetting.new
11 | end
12 |
13 | def self.activate
14 | cache_klasses = %W(#{config.root}/app/**/*_decorator*.rb #{config.root}/app/overrides/*.rb)
15 | Dir.glob(cache_klasses) do |klass|
16 | Rails.configuration.cache_classes ? require(klass) : load(klass)
17 | end
18 | end
19 |
20 | config.to_prepare(&method(:activate).to_proc)
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/spec/models/spree/product_decorator_spec.rb:
--------------------------------------------------------------------------------
1 | RSpec.describe Spree::Product, type: :model do
2 | before do
3 | 3.times { create(:product) }
4 | end
5 |
6 | describe '.find_by_array_of_ids' do
7 | it 'returns the products specified in the array of product ids' do
8 | product_ids = Spree::Product.limit(2).map(&:id)
9 | products = Spree::Product.find_by_array_of_ids(product_ids)
10 | expect(products.size).to be(2)
11 | end
12 |
13 | it 'ignores nonexistant product ids and still return correctly specified products' do
14 | product_ids = Spree::Product.limit(2).map(&:id) << 200
15 | products = Spree::Product.find_by_array_of_ids(product_ids)
16 | expect(products.size).to be(2)
17 | end
18 |
19 | it 'returns an empty array when no valid ids are specified' do
20 | products = Spree::Product.find_by_array_of_ids([200])
21 | expect(products).to eq([])
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/app/controllers/spree/products_controller_decorator.rb:
--------------------------------------------------------------------------------
1 | module Spree::ProductsControllerDecorator
2 | def self.prepended(base)
3 | base.include Spree::RecentlyViewedProductsHelper
4 | base.helper_method [:cached_recently_viewed_products, :cached_recently_viewed_products_ids]
5 | base.before_action :set_current_order, except: :recently_viewed
6 | base.after_action :save_recently_viewed, only: :recently_viewed
7 | end
8 |
9 | def recently_viewed
10 | render 'spree/products/recently_viewed', layout: false
11 | end
12 |
13 | private
14 |
15 | def save_recently_viewed
16 | id = params[:product_id]
17 | return unless id.present?
18 |
19 | rvp = (cookies['recently_viewed_products'] || '').split(', ')
20 | rvp.delete(id)
21 | rvp << id unless rvp.include?(id.to_s)
22 | rvp_max_count = Spree::RecentlyViewed::Config.preferred_recently_viewed_products_max_count
23 | rvp.delete_at(0) if rvp.size > rvp_max_count.to_i
24 | cookies['recently_viewed_products'] = rvp.join(', ')
25 | end
26 | end
27 |
28 | Spree::ProductsController.prepend Spree::ProductsControllerDecorator
29 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
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.6
19 |
20 | env:
21 | - DB=mysql
22 | - DB=postgres
23 |
24 | gemfile:
25 | - gemfiles/spree_3_7.gemfile
26 | - gemfiles/spree_4_0.gemfile
27 | - gemfiles/spree_4_1.gemfile
28 | - gemfiles/spree_master.gemfile
29 |
30 | jobs:
31 | allow_failures:
32 | - gemfile: gemfiles/spree_master.gemfile
33 |
34 | before_install:
35 | - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
36 |
37 | before_script:
38 | - CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
39 | - CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
40 | - curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
41 | - unzip chromedriver_linux64.zip -d ~/bin
42 | - nvm install 14
43 |
44 | script:
45 | - bundle exec rake test_app
46 | - bundle exec rake spec
47 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009-2015 Roman Smirnov, Brian Quinn and contributors
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.
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Spree Recently Viewed
2 |
3 | [](https://travis-ci.org/spree-contrib/spree_recently_viewed)
4 | [](https://codeclimate.com/github/spree-contrib/spree_recently_viewed)
5 |
6 | This extension maintains and displays a list of the products a user has recently viewed.
7 |
8 | ## Installation
9 |
10 | 1. Add this extension to your Gemfile with this line:
11 | ```ruby
12 | gem 'spree_recently_viewed', github: 'spree-contrib/spree_recently_viewed'
13 | ```
14 |
15 | 2. Install the gem using Bundler:
16 | ```ruby
17 | bundle install
18 | ```
19 |
20 | 3. Copy & run migrations
21 | ```ruby
22 | bundle exec rails g spree_recently_viewed: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 | ---
30 |
31 | ## Contributing
32 |
33 | See corresponding [guidelines][4]
34 |
35 | ---
36 |
37 | Copyright (c) 2009-2020 [Roman Smirnov][6], [Brian Quinn][7] and other [contributors][8], released under the [New BSD License][3]
38 |
39 | [1]: http://www.fsf.org/licensing/essays/free-sw.html
40 | [2]: https://github.com/spree-contrib/spree_recently_viewed/issues
41 | [3]: https://github.com/spree-contrib/spree_recently_viewed/blob/master/LICENSE.md
42 | [4]: https://github.com/spree-contrib/spree_recently_viewed/blob/master/CONTRIBUTING.md
43 | [6]: https://github.com/romul
44 | [7]: https://github.com/BDQ
45 | [8]: https://github.com/spree-contrib/spree_recently_viewed/graphs/contributors
46 |
--------------------------------------------------------------------------------
/spree_recently_viewed.gemspec:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | lib = File.expand_path('../lib/', __FILE__)
3 | $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
4 |
5 | require 'spree_recently_viewed/version'
6 |
7 | Gem::Specification.new do |s|
8 | s.platform = Gem::Platform::RUBY
9 | s.name = 'spree_recently_viewed'
10 | s.version = SpreeRecentlyViewed.version
11 | s.summary = 'Adds recently viewed products to Spree'
12 | s.description = s.summary
13 | s.required_ruby_version = '>= 2.5.0'
14 |
15 | s.authors = ['Roman Smirnov', 'Brian Quinn']
16 | s.email = 'brian@railsdog.com'
17 | s.license = 'BSD-3'
18 |
19 | s.files = `git ls-files`.split("\n")
20 | s.test_files = `git ls-files -- spec/*`.split("\n")
21 | s.require_path = 'lib'
22 | s.requirements << 'none'
23 |
24 | spree_version = '>= 3.5.0', '< 5.0'
25 | s.add_dependency 'spree_core', spree_version
26 | s.add_dependency 'spree_frontend', spree_version
27 | s.add_runtime_dependency 'spree_extension'
28 | s.add_dependency 'deface', '~> 1.0'
29 |
30 | s.add_development_dependency 'rspec-rails', '~> 4.0.0'
31 | s.add_development_dependency 'factory_bot', '~> 4.7'
32 | s.add_development_dependency 'capybara'
33 | s.add_development_dependency 'capybara-screenshot'
34 | s.add_development_dependency 'selenium-webdriver'
35 | s.add_development_dependency 'sqlite3'
36 | s.add_development_dependency 'simplecov'
37 | s.add_development_dependency 'coffee-rails'
38 | s.add_development_dependency 'sass-rails'
39 | s.add_development_dependency 'database_cleaner'
40 | s.add_development_dependency 'ffaker'
41 | s.add_development_dependency 'pry-rails'
42 | s.add_development_dependency 'rubocop'
43 | s.add_development_dependency 'sprockets-rails'
44 | s.add_development_dependency 'mysql2'
45 | s.add_development_dependency 'pg'
46 | s.add_development_dependency 'appraisal'
47 | s.add_development_dependency 'puma'
48 | end
49 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Spree Recently Viewed is an open source project and we encourage contributions. Please see the [contributors guidelines](http://spreecommerce.com/documentation/contributing_to_spree.html) for more information before contributing.
4 |
5 | In the spirit of [free software][1], **everyone** is encouraged to help improve this project.
6 |
7 | Here are some ways *you* can contribute:
8 |
9 | * by using prerelease versions
10 | * by reporting [bugs][2]
11 | * by suggesting new features
12 | * by writing [translations][3]
13 | * by writing or editing documentation
14 | * by writing specifications
15 | * by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
16 | * by refactoring code
17 | * by resolving [issues][2]
18 | * by reviewing patches
19 |
20 | ---
21 |
22 | ## Filing an issue
23 |
24 | When filing an issue on this extension, please first do these things:
25 |
26 | * Verify you can reproduce this issue in a brand new application.
27 | * Run through the steps to reproduce the issue again.
28 |
29 | In the issue itself please provide:
30 |
31 | * A comprehensive list of steps to reproduce the issue.
32 | * What you're *expecting* to happen compared with what's *actually* happening.
33 | * The version of Spree *and* the version of Rails.
34 | * A list of all extensions.
35 | * Any relevant stack traces ("Full trace" preferred)
36 | * Your `Gemfile`
37 |
38 | In 99% of cases, this information is enough to determine the cause and solution to the problem that is being described.
39 |
40 | ---
41 |
42 | ## Pull requests
43 |
44 | We gladly accept pull requests to fix bugs and, in some circumstances, add new features to this extension.
45 |
46 | Here's a quick guide:
47 |
48 | 1. Fork the repo.
49 |
50 | 2. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate.
51 |
52 | 3. Create new branch then make changes and add tests for your changes. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, we need tests!
53 |
54 | 4. Push to your fork and submit a pull request. If the changes will apply cleanly to the latest stable branches and master branch, you will only need to submit one pull request.
55 |
56 | At this point you're waiting on us. We may suggest some changes or improvements or alternatives.
57 |
58 | Some things that will increase the chance that your pull request is accepted, taken straight from the Ruby on Rails guide:
59 |
60 | * Use Rails idioms and helpers.
61 | * Include tests that fail without your code, and pass with it.
62 | * Update the documentation, the surrounding one, examples elsewhere, guides, whatever is affected by your contribution.
63 |
64 | ---
65 |
66 | ## TL;DR
67 |
68 | * Fork the repo
69 | * Clone your repo
70 | * Run `bundle install`
71 | * Run `bundle exec rake test_app` to create the test application in `spec/dummy`
72 | * Make your changes
73 | * Ensure specs pass by running `bundle exec rspec spec`
74 | * Ensure all syntax ok by running `rubocop .`
75 | * Submit your pull request
76 |
77 | And in case we didn't emphasize it enough: **we love tests!**
78 |
79 | [1]: http://www.fsf.org/licensing/essays/free-sw.html
80 | [2]: https://github.com/spree-contrib/spree_recently_viewed/issues
81 | [3]: https://github.com/spree-contrib/spree_recently_viewed/tree/master/config/locales
82 |
--------------------------------------------------------------------------------