spree-point-of-sale 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -2
- data/.rspec +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -6
- data/README.md +26 -3
- data/Rakefile +4 -3
- data/app/assets/javascripts/admin/spree_pos.js +1 -0
- data/app/controllers/spree/admin/barcode_controller.rb +2 -2
- data/app/controllers/spree/admin/checkout_controller_decorator.rb +1 -1
- data/app/controllers/spree/admin/pos_controller.rb +17 -16
- data/app/controllers/spree/admin/stock_locations_controller_decorator.rb +2 -1
- data/app/models/spree/order_decorator.rb +4 -4
- data/app/models/spree/payment_decorator.rb +1 -1
- data/app/models/spree/stock/pos_availability_validator.rb +1 -1
- data/app/models/spree/stock_location_decorator.rb +3 -3
- data/app/overrides/pos_tab.rb +2 -2
- data/app/views/spree/admin/pos/show.html.erb +1 -1
- data/app/views/spree/admin/pos/update_stock_location.js.erb +1 -1
- data/config/initializers/spree.rb +3 -0
- data/config/routes.rb +16 -18
- data/spec/controllers/spree/admin/pos_controller_spec.rb +8 -9
- data/spec/models/spree/order_decorator_spec.rb +2 -5
- data/spec/models/spree/payment_decorator_spec.rb +0 -2
- data/spec/models/spree/stock/pos_availability_validator_spec.rb +7 -5
- data/spec/models/spree/stock_location_decorator_spec.rb +3 -3
- data/spec/models/spree/user_decorator_spec.rb +5 -4
- data/spec/models/spree/{varaint_decorator_spec.rb → variant_decorator_spec.rb} +3 -3
- data/spec/spec_helper.rb +1 -1
- data/spree-point-of-sale.gemspec +6 -6
- metadata +91 -75
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
|
-
gem 'rails', '
|
2
|
+
gem 'rails', '4.0.2'
|
3
3
|
gem 'mysql2'
|
4
4
|
|
5
5
|
|
6
|
-
gem 'spree', :git => 'git://github.com/spree/spree.git', :tag => 'v2.
|
7
|
-
gem 'spree_html_invoice' , :git => 'git://github.com/dancinglightning/spree-html-invoice.git'
|
6
|
+
gem 'spree', :git => 'git://github.com/spree/spree.git', :tag => 'v2.1.4'
|
7
|
+
# gem 'spree_html_invoice' , :git => 'git://github.com/dancinglightning/spree-html-invoice.git'
|
8
8
|
|
9
9
|
# Provides basic authentication functionality for testing parts of your engine
|
10
|
-
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', :branch => '2-
|
10
|
+
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', :branch => '2-1-stable'
|
11
11
|
|
12
12
|
gemspec
|
13
13
|
|
14
14
|
group :test do
|
15
|
-
gem 'rspec-rails'
|
16
|
-
gem 'shoulda-matchers'
|
15
|
+
gem 'rspec-rails'
|
16
|
+
gem 'shoulda-matchers'
|
17
17
|
gem 'simplecov', :require => false
|
18
18
|
gem 'database_cleaner'
|
19
19
|
gem 'rspec-html-matchers'
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Spree Pos [![Code Climate](https://codeclimate.com/github/vinsol/spree-point-of-sale.png)](https://codeclimate.com/github/vinsol/spree-point-of-sale)
|
1
|
+
Spree Pos [![Code Climate](https://codeclimate.com/github/vinsol/spree-point-of-sale.png)](https://codeclimate.com/github/vinsol/spree-point-of-sale) [![Build Status](https://travis-ci.org/vinsol/spree-point-of-sale.png?branch=master)](https://travis-ci.org/vinsol/spree-point-of-sale)
|
2
2
|
=========
|
3
3
|
SpreePos hooks into the Admin Tab and is meant to be used to sell at a shop.
|
4
4
|
|
@@ -28,7 +28,14 @@ Add spree-point-of-sale to your Gemfile:
|
|
28
28
|
```ruby
|
29
29
|
gem "spree-point-of-sale", require: 'spree_pos'
|
30
30
|
```
|
31
|
-
|
31
|
+
|
32
|
+
If you're still using Spree 2.0.x, you should do this instead:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
gem "spree-point-of-sale", '1.0.3', require: 'spree_pos'
|
36
|
+
```
|
37
|
+
|
38
|
+
|
32
39
|
If you DONT change the :pos_printing config as described above, you must also add
|
33
40
|
|
34
41
|
```ruby
|
@@ -79,4 +86,20 @@ Barcode printing relies on sku to be provided for variants.
|
|
79
86
|
|
80
87
|
There are links provided to print barcodes for individual variants in the variants index for a product or barcodes for all variants can be printed from the product listings as well.
|
81
88
|
|
82
|
-
|
89
|
+
|
90
|
+
Testing
|
91
|
+
---------
|
92
|
+
Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
|
93
|
+
```ruby
|
94
|
+
bundle
|
95
|
+
bundle exec rake test_app
|
96
|
+
bundle exec rspec spec
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
Credits
|
101
|
+
-------
|
102
|
+
|
103
|
+
[![vinsol.com: Ruby on Rails, iOS and Android developers](http://vinsol.com/vin_logo.png "Ruby on Rails, iOS and Android developers")](http://vinsol.com)
|
104
|
+
|
105
|
+
Copyright (c) 2014 [vinsol.com](http://vinsol.com "Ruby on Rails, iOS and Android developers"), released under the New MIT License
|
data/Rakefile
CHANGED
@@ -3,13 +3,13 @@ require 'rake/testtask'
|
|
3
3
|
require 'rake/packagetask'
|
4
4
|
require 'rubygems/package_task'
|
5
5
|
require 'rspec/core/rake_task'
|
6
|
-
require '
|
6
|
+
require 'spree/testing_support/common_rake'
|
7
7
|
|
8
8
|
RSpec::Core::RakeTask.new
|
9
9
|
|
10
10
|
task :default => [:spec, :cucumber ]
|
11
11
|
|
12
|
-
spec = eval(File.read('
|
12
|
+
spec = eval(File.read('spree-point-of-sale.gemspec'))
|
13
13
|
|
14
14
|
Gem::PackageTask.new(spec) do |p|
|
15
15
|
p.gem_spec = spec
|
@@ -24,6 +24,7 @@ end
|
|
24
24
|
|
25
25
|
desc "Generates a dummy app for testing"
|
26
26
|
task :test_app do
|
27
|
-
ENV['
|
27
|
+
ENV['DB'] = 'mysql'
|
28
|
+
ENV['LIB_NAME'] = 'spree-point-of-sale'
|
28
29
|
Rake::Task['common:test_app'].invoke
|
29
30
|
end
|
@@ -8,8 +8,8 @@ require 'barby/outputter/png_outputter'
|
|
8
8
|
class Spree::Admin::BarcodeController < Spree::Admin::BaseController
|
9
9
|
include Admin::BarcodeHelper
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
before_action :load, :only => [:print]
|
12
|
+
before_action :load_product_and_variants, :only => [:print_variants_barcodes]
|
13
13
|
layout :false
|
14
14
|
|
15
15
|
def print_variants_barcodes
|
@@ -1,14 +1,14 @@
|
|
1
1
|
class Spree::Admin::PosController < Spree::Admin::BaseController
|
2
|
-
|
2
|
+
before_action :load_order, :ensure_pos_order, :ensure_unpaid_order, :except => [:new]
|
3
3
|
helper_method :user_stock_locations
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
before_action :load_variant, :only => [:add, :remove]
|
5
|
+
before_action :ensure_active_store, :ensure_pos_shipping_method
|
6
|
+
before_action :ensure_payment_method, :only => [:update_payment]
|
7
|
+
before_action :ensure_existing_user, :only => [:associate_user]
|
8
|
+
before_action :check_unpaid_pos_order, :only => :new
|
9
|
+
before_action :check_discount_request, :only => :apply_discount
|
10
|
+
before_action :load_line_item, :only => [:update_line_item_quantity, :apply_discount]
|
11
|
+
before_action :clean_and_reload_order, :only => [:update_stock_location]
|
12
12
|
|
13
13
|
def new
|
14
14
|
init_pos
|
@@ -17,8 +17,8 @@ class Spree::Admin::PosController < Spree::Admin::BaseController
|
|
17
17
|
|
18
18
|
def find
|
19
19
|
init_search
|
20
|
-
|
21
|
-
stock_location = @order.
|
20
|
+
#TODO -> create one method for last_shipment in order_model as it is used in verious locations.
|
21
|
+
stock_location = @order.shipments.last.stock_location
|
22
22
|
@search = Spree::Variant.includes([:product]).available_at_stock_location(stock_location.id).ransack(params[:q])
|
23
23
|
@variants = @search.result(:distinct => true).page(params[:page]).per(PRODUCTS_PER_SEARCH_PAGE)
|
24
24
|
end
|
@@ -31,7 +31,7 @@ class Spree::Admin::PosController < Spree::Admin::BaseController
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def remove
|
34
|
-
line_item = @order.contents.remove(@variant, 1, @order.
|
34
|
+
line_item = @order.contents.remove(@variant, 1, @order.shipments.last)
|
35
35
|
@order.assign_shipment_for_pos if @order.reload.shipments.blank?
|
36
36
|
flash.notice = line_item.quantity.zero? ? Spree.t('product_removed') : 'Quantity Updated'
|
37
37
|
redirect_to admin_pos_show_order_path(:number => @order.number)
|
@@ -82,11 +82,12 @@ class Spree::Admin::PosController < Spree::Admin::BaseController
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def update_stock_location
|
85
|
-
@
|
86
|
-
|
85
|
+
@shipment = @order.shipments.last
|
86
|
+
@shipment.stock_location = user_stock_locations(spree_current_user).where(:id => params[:stock_location_id]).first
|
87
|
+
if @shipment.save
|
87
88
|
flash[:notice] = "Updated Successfully"
|
88
89
|
else
|
89
|
-
flash[:error] = @
|
90
|
+
flash[:error] = @shipment.errors.full_messages.to_sentence
|
90
91
|
end
|
91
92
|
redirect_to admin_pos_show_order_path(:number => @order.number)
|
92
93
|
end
|
@@ -185,7 +186,7 @@ class Spree::Admin::PosController < Spree::Admin::BaseController
|
|
185
186
|
end
|
186
187
|
|
187
188
|
def add_variant var , quant = 1
|
188
|
-
line_item = @order.contents.add(var, quant, nil, @order.
|
189
|
+
line_item = @order.contents.add(var, quant, nil, @order.shipments.last)
|
189
190
|
var.product.save
|
190
191
|
line_item
|
191
192
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
Spree::Admin::StockLocationsController.class_eval do
|
2
|
+
#TODO -> Is this method different from resource_controller update action ?
|
2
3
|
def update
|
3
|
-
if @stock_location.update_attributes(
|
4
|
+
if @stock_location.update_attributes(permitted_resource_params)
|
4
5
|
flash[:success] = flash_message_for(@object, :successfully_updated)
|
5
6
|
respond_with(@object) do |format|
|
6
7
|
format.html { redirect_to location_after_save }
|
@@ -1,13 +1,13 @@
|
|
1
1
|
Spree::Order.class_eval do
|
2
|
-
attr_accessible :state, :is_pos, :completed_at, :payment_state
|
2
|
+
# attr_accessible :state, :is_pos, :completed_at, :payment_state
|
3
3
|
|
4
|
-
scope :pos, where(:is_pos => true)
|
5
|
-
scope :unpaid, where("payment_state != 'paid'")
|
4
|
+
scope :pos, -> { where(:is_pos => true) }
|
5
|
+
scope :unpaid, -> { where("payment_state != 'paid'") }
|
6
6
|
scope :unpaid_pos_order, ->{ pos.unpaid }
|
7
7
|
|
8
8
|
def clean!
|
9
9
|
payments.delete_all
|
10
|
-
line_items.each { |line_item| contents.remove(line_item.variant, line_item.quantity,
|
10
|
+
line_items.each { |line_item| contents.remove(line_item.variant, line_item.quantity, shipments.last) }
|
11
11
|
#shipment is removed on removing all items, so initializing a new shipment
|
12
12
|
assign_shipment_for_pos
|
13
13
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
Spree::Payment.class_eval do
|
2
|
-
attr_accessible :card_name
|
2
|
+
# attr_accessible :card_name
|
3
3
|
validates :payment_method, :presence => true, :if => ["order.is_pos?"]
|
4
4
|
validates :card_name, :presence => true, :if => [:payment_method, "order.is_pos? && payment_method.name.scan(/card/i).present?"]
|
5
5
|
validate :no_card_name, :if => [:payment_method, "payment_method.name.scan(/card/i).blank?"]
|
@@ -3,7 +3,7 @@ module Spree
|
|
3
3
|
class PosAvailabilityValidator < ActiveModel::Validator
|
4
4
|
def validate(line_item)
|
5
5
|
variant = line_item.variant
|
6
|
-
stock_location = line_item.order.
|
6
|
+
stock_location = line_item.order.shipments.last.try(:stock_location)
|
7
7
|
quantity_required = line_item.quantity - line_item.quantity_was.to_i
|
8
8
|
if !stock_location || !stock_location.active? || !stock_location.store?
|
9
9
|
line_item.errors[:stock_location] << 'No Active Store Associated'
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Spree
|
2
2
|
StockLocation.class_eval do
|
3
|
-
attr_accessible :store
|
3
|
+
# attr_accessible :store
|
4
4
|
belongs_to :address
|
5
5
|
|
6
6
|
before_validation :associate_address
|
7
7
|
|
8
|
-
scope :stores, where(:store => true)
|
9
|
-
scope :not_store, where('store != ?', true)
|
8
|
+
scope :stores, -> { where(:store => true) }
|
9
|
+
scope :not_store, -> { where('store != ?', true) }
|
10
10
|
|
11
11
|
validates_associated :address
|
12
12
|
|
data/app/overrides/pos_tab.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
Deface::Override.new(:virtual_path => "spree/
|
1
|
+
Deface::Override.new(:virtual_path => "spree/admin/shared/_menu",
|
2
2
|
:name => "Add Pos tab to menu",
|
3
|
-
:insert_bottom => "[data-hook='admin_tabs']
|
3
|
+
:insert_bottom => "[data-hook='admin_tabs']",
|
4
4
|
:text => " <%= tab( :pos , :url => admin_pos_path) %>",
|
5
5
|
:sequence => {:after => "promo_admin_tabs"},
|
6
6
|
:disabled => false)
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<legend>Change Stock Location</legend>
|
7
7
|
<%= form_tag "/admin/pos/update_stock_location/#{@order.number}", :class => 'modify_stock_location_form' do %>
|
8
8
|
<% user_stock_locations(spree_current_user).all.each do |stock_location| %>
|
9
|
-
<%= radio_button_tag :stock_location_id, stock_location.id, (stock_location.id == @order.
|
9
|
+
<%= radio_button_tag :stock_location_id, stock_location.id, (stock_location.id == @order.shipments.last.stock_location.id), :id => "stock_location_#{ stock_location.id }", :class => 'stock_location_checkbox' %><%= stock_location.name %><br />
|
10
10
|
<% end %>
|
11
11
|
<br />
|
12
12
|
<%= submit_tag 'Update', :confirm => 'The Order will be cleaned. Are you sure?' %>
|
data/config/routes.rb
CHANGED
@@ -1,21 +1,19 @@
|
|
1
|
-
Spree::Core::Engine.routes.
|
2
|
-
|
3
|
-
|
4
|
-
match "barcode/print/:id" => "barcode#print"
|
1
|
+
Spree::Core::Engine.routes.draw do
|
2
|
+
get "admin/barcode/print_variants_barcodes/:id", to: "admin/barcode#print_variants_barcodes"
|
3
|
+
get "admin/barcode/print/:id", to: "admin/barcode#print"
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
get "admin/pos/new" , to: "admin/pos#new"
|
6
|
+
get "admin/pos/show/:number" , to: "admin/pos#show", as: :admin_pos_show_order
|
7
|
+
post "admin/pos/clean/:number" , to: "admin/pos#clean_order", as: :admin_pos_clean_order
|
8
|
+
get "admin/pos/find/:number" , to: "admin/pos#find"
|
9
|
+
get "admin/pos/add/:number/:item" , to: "admin/pos#add"
|
10
|
+
get "admin/pos/remove/:number/:item" , to: "admin/pos#remove"
|
11
|
+
post "admin/pos/associate_user/:number" , to: "admin/pos#associate_user"
|
12
|
+
post "admin/pos/update_payment/:number" , to: "admin/pos#update_payment"
|
13
|
+
post "admin/pos/update_line_item_quantity/:number" , to: "admin/pos#update_line_item_quantity"
|
14
|
+
post "admin/pos/apply_discount/:number" , to: "admin/pos#apply_discount"
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
16
|
+
get "admin/pos/index" , to: "admin/pos#new"
|
17
|
+
post "admin/pos/update_stock_location/:number" , to: "admin/pos#update_stock_location"
|
18
|
+
get "admin/pos" , to: "admin/pos#new"
|
21
19
|
end
|
@@ -503,7 +503,7 @@ describe Spree::Admin::PosController do
|
|
503
503
|
@orders.stub(:includes).with([{ :line_items => [{ :variant => [:default_price, { :product => [:master] } ] }] } , { :adjustments => :adjustable }]).and_return(@orders)
|
504
504
|
@stock_location = mock_model(Spree::StockLocation)
|
505
505
|
@shipment = mock_model(Spree::Shipment)
|
506
|
-
order.stub(:
|
506
|
+
order.stub(:shipments).and_return([@shipment])
|
507
507
|
@shipment.stub(:stock_location).and_return(@stock_location)
|
508
508
|
@variants = [variant]
|
509
509
|
@variants.stub(:result).with(:distinct => true).and_return(@variants)
|
@@ -519,7 +519,7 @@ describe Spree::Admin::PosController do
|
|
519
519
|
it { controller.should_receive(:ensure_pos_shipping_method).and_return(true) }
|
520
520
|
it { controller.should_receive(:ensure_active_store).and_return(true) }
|
521
521
|
it { controller.should_not_receive(:ensure_payment_method) }
|
522
|
-
it { order.should_receive(:
|
522
|
+
it { order.should_receive(:shipments).and_return([@shipment]) }
|
523
523
|
it { @shipment.should_receive(:stock_location).and_return(@stock_location) }
|
524
524
|
it { Spree::Variant.should_receive(:ransack).with({"product_name_cont"=>"test-product", "meta_sort"=>"product_name asc", "deleted_at_null"=>"1", "product_deleted_at_null"=>"1", "published_at_not_null"=>"1"}).and_return(@variants) }
|
525
525
|
it { @variants.should_receive(:result).with(:distinct => true).and_return(@variants) }
|
@@ -563,7 +563,7 @@ describe Spree::Admin::PosController do
|
|
563
563
|
Spree::Variant.stub(:where).with(:id => variant.id.to_s).and_return([variant])
|
564
564
|
@order_contents = double(Spree::OrderContents)
|
565
565
|
@shipment = mock_model(Spree::Shipment)
|
566
|
-
order.stub(:
|
566
|
+
order.stub(:shipments).and_return([@shipment])
|
567
567
|
order.stub(:contents).and_return(@order_contents)
|
568
568
|
@order_contents.stub(:add).with(variant, 1, nil, @shipment).and_return(line_item)
|
569
569
|
end
|
@@ -629,7 +629,6 @@ describe Spree::Admin::PosController do
|
|
629
629
|
Spree::Variant.stub(:where).with(:id => variant.id.to_s).and_return([variant])
|
630
630
|
@order_contents = double(Spree::OrderContents)
|
631
631
|
@shipment = mock_model(Spree::Shipment)
|
632
|
-
order.stub(:shipment).and_return(@shipment)
|
633
632
|
order.stub(:shipments).and_return([@shipment])
|
634
633
|
order.stub(:assign_shipment_for_pos).and_return(true)
|
635
634
|
order.stub(:contents).and_return(@order_contents)
|
@@ -669,15 +668,15 @@ describe Spree::Admin::PosController do
|
|
669
668
|
end
|
670
669
|
end
|
671
670
|
|
672
|
-
context 'shipment is destroyed on empty order' do
|
671
|
+
context 'shipment is not destroyed on empty order' do
|
673
672
|
it 'assigns shipment' do
|
674
673
|
order.should_not_receive(:assign_shipment_for_pos)
|
675
674
|
send_request(:number => order.number, :item => variant.id)
|
676
675
|
end
|
677
676
|
end
|
678
677
|
|
679
|
-
context 'shipment
|
680
|
-
before { order.
|
678
|
+
context 'shipment destroyed after remove' do
|
679
|
+
before { order.stub_chain(:shipments, :blank?).and_return(true) }
|
681
680
|
|
682
681
|
it 'assigns shipment' do
|
683
682
|
order.should_receive(:assign_shipment_for_pos).and_return(true)
|
@@ -875,7 +874,7 @@ describe Spree::Admin::PosController do
|
|
875
874
|
@shipment.stub(:stock_location=).with(@stock_location).and_return(@stock_location)
|
876
875
|
@shipment.stub(:stock_location).and_return(@stock_location)
|
877
876
|
|
878
|
-
order.stub(:
|
877
|
+
order.stub(:shipments).and_return([@shipment])
|
879
878
|
order.stub(:save).and_return(true)
|
880
879
|
@shipment.stub(:save).and_return(true)
|
881
880
|
end
|
@@ -884,7 +883,7 @@ describe Spree::Admin::PosController do
|
|
884
883
|
it { order.should_receive(:clean!).and_return(true) }
|
885
884
|
it { controller.should_receive(:load_order).twice.and_return(true) }
|
886
885
|
it { @shipment.should_receive(:stock_location=).with(@stock_location).and_return(@stock_location) }
|
887
|
-
it { order.should_receive(:
|
886
|
+
it { order.should_receive(:shipments).and_return([@shipment]) }
|
888
887
|
it { @shipment.should_receive(:save).and_return(true) }
|
889
888
|
it { controller.should_receive(:ensure_pos_shipping_method).and_return(true) }
|
890
889
|
it { controller.should_receive(:ensure_active_store).and_return(true) }
|
@@ -6,10 +6,6 @@ describe Spree::Order do
|
|
6
6
|
let(:country) { Spree::Country.create!(:name => 'mk_country', :iso_name => "mk") }
|
7
7
|
let(:state) { country.states.create!(:name => 'mk_state') }
|
8
8
|
let(:store) { Spree::StockLocation.create!(:name => 'store', :store => true, :address1 => "home", :address2 => "town", :city => "delhi", :zipcode => "110034", :country_id => country.id, :state_id => state.id, :phone => "07777676767") }
|
9
|
-
|
10
|
-
[:state, :is_pos, :completed_at, :payment_state].each do |attribute|
|
11
|
-
it { should allow_mass_assignment_of attribute }
|
12
|
-
end
|
13
9
|
|
14
10
|
before do
|
15
11
|
@order = Spree::Order.create!(:is_pos => true)
|
@@ -29,7 +25,8 @@ describe Spree::Order do
|
|
29
25
|
|
30
26
|
context 'scopes' do
|
31
27
|
before :each do
|
32
|
-
@paid_order = Spree::Order.create!
|
28
|
+
@paid_order = Spree::Order.create!
|
29
|
+
@paid_order.update_column(:total,100)
|
33
30
|
@paid_order.update_column(:payment_state,'paid')
|
34
31
|
@unpaid_pos_order = Spree::Order.create!(:is_pos => true, :payment_state => 'checkout')
|
35
32
|
@paid_pos_order = Spree::Order.create!(:is_pos => true, :payment_state => 'paid')
|
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::Payment do
|
4
|
-
it { should allow_mass_assignment_of :card_name }
|
5
|
-
|
6
4
|
let(:payment_method) { Spree::PaymentMethod.create!(:name => 'test-method') }
|
7
5
|
let(:card_payment_method) { Spree::PaymentMethod.create!(:name => 'card-payment')}
|
8
6
|
let(:order) { Spree::Order.create! }
|
@@ -4,20 +4,22 @@ describe Spree::Stock::PosAvailabilityValidator do
|
|
4
4
|
let(:country) { Spree::Country.create!(:name => 'mk_country', :iso_name => "mk") }
|
5
5
|
let(:state) { country.states.create!(:name => 'mk_state') }
|
6
6
|
let(:store) { Spree::StockLocation.create!(:name => 'store', :store => true, :address1 => "home", :address2 => "town", :city => "delhi", :zipcode => "110034", :country_id => country.id, :state_id => state.id, :phone => "07777676767") }
|
7
|
-
|
7
|
+
let(:shipping_category) { Spree::ShippingCategory.create!(:name => 'test-shipping') }
|
8
|
+
|
8
9
|
before do
|
9
10
|
@order = Spree::Order.create!(:is_pos => true)
|
10
|
-
@product = Spree::Product.create!(:name => 'test-product', :price => 10)
|
11
|
+
@product = Spree::Product.create!(:name => 'test-product', :price => 10, :shipping_category => shipping_category)
|
11
12
|
@variant = @product.master
|
12
|
-
@line_item = @order.line_items.build(:variant_id => @variant.id, :
|
13
|
+
@line_item = @order.line_items.build(:variant_id => @variant.id, :quantity => 3)
|
14
|
+
@line_item.price = @product.price
|
13
15
|
@shipment = @order.shipments.create!
|
14
16
|
@line_item.stub(:order).and_return(@order)
|
15
|
-
@order.stub(:
|
17
|
+
@order.stub(:shipments).and_return([@shipment])
|
16
18
|
end
|
17
19
|
|
18
20
|
describe 'ensures stock location' do
|
19
21
|
it 'presence' do
|
20
|
-
@line_item.order.
|
22
|
+
@line_item.order.shipments.last.stock_location.should be_nil
|
21
23
|
@line_item.save
|
22
24
|
@line_item.errors[:stock_location].should eq(['No Active Store Associated'])
|
23
25
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Spree::StockLocation do
|
4
|
-
it { should allow_mass_assignment_of :store }
|
5
4
|
it { should belong_to :address }
|
6
5
|
|
7
6
|
let(:country) { Spree::Country.create!(:name => 'mk_country', :iso_name => "mk") }
|
8
7
|
let(:state) { country.states.create!(:name => 'mk_state') }
|
9
8
|
let(:store) { Spree::StockLocation.create!(:name => 'store', :store => true, :address1 => "home", :address2 => "town", :city => "delhi", :zipcode => "110034", :country_id => country.id, :state_id => state.id, :phone => "07777676767") }
|
10
9
|
let(:stock_location) { Spree::StockLocation.create!(:name => 'stock', :address1 => "home", :address2 => "town", :city => "delhi", :zipcode => "110034", :country_id => country.id, :state_id => state.id, :phone => "07777676767") }
|
11
|
-
|
10
|
+
let(:shipping_category) { Spree::ShippingCategory.create!(:name => 'test-shipping') }
|
11
|
+
|
12
12
|
context 'scopes' do
|
13
13
|
it 'stores' do
|
14
14
|
Spree::StockLocation.stores.should include(store)
|
@@ -43,7 +43,7 @@ describe Spree::StockLocation do
|
|
43
43
|
|
44
44
|
describe '#can_supply?' do
|
45
45
|
before do
|
46
|
-
@product = Spree::Product.create!(:name => 'test-product', :price => 10)
|
46
|
+
@product = Spree::Product.create!(:name => 'test-product', :price => 10, :shipping_category => shipping_category)
|
47
47
|
@variant = @product.master
|
48
48
|
@stock_item = store.stock_items.where(:variant_id => @variant.id).first
|
49
49
|
@stock_item.update_column(:count_on_hand, 2)
|
@@ -4,12 +4,13 @@ describe Spree::User do
|
|
4
4
|
let(:user) { Spree::User.create!(:email => 'test-user@pos.com', :password => 'testuser') }
|
5
5
|
describe 'unpaid_pos_orders' do
|
6
6
|
before do
|
7
|
-
@paid_order = user.orders.create!
|
7
|
+
@paid_order = user.orders.create!
|
8
|
+
@paid_order.update_column(:total,100)
|
8
9
|
@paid_order.update_column(:payment_state,'paid')
|
9
|
-
@unpaid_pos_order = user.orders.create!(:
|
10
|
-
@paid_pos_order = user.orders.create!(:
|
10
|
+
@unpaid_pos_order = user.orders.create!(:is_pos => true, :payment_state => 'checkout')
|
11
|
+
@paid_pos_order = user.orders.create!(:is_pos => true, :payment_state => 'paid')
|
11
12
|
@paid_pos_order.update_column(:payment_state,'paid')
|
12
|
-
@unpaid_order = user.orders.create!(:
|
13
|
+
@unpaid_order = user.orders.create!(:payment_state => 'checkout')
|
13
14
|
end
|
14
15
|
|
15
16
|
it { user.unpaid_pos_orders.should eq([@unpaid_pos_order]) }
|
@@ -2,13 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Spree::Variant do
|
4
4
|
let(:shipping_category) { Spree::ShippingCategory.create!(:name => 'test-shipping') }
|
5
|
-
let(:product) { Spree::Product.create!( :name => 'new_product', :price => 10, :
|
5
|
+
let(:product) { Spree::Product.create!( :name => 'new_product', :price => 10, :available_on => 'Fri, 19 Jul 2013 08:11:06 UTC +00:00', :shipping_category_id => shipping_category.id ) }
|
6
6
|
|
7
7
|
describe 'scopes' do
|
8
8
|
describe 'available_at_stock_location' do
|
9
9
|
before do
|
10
|
-
@variant = product.variants.create!(:sku => "M12343"
|
11
|
-
@unavailable_variant = product.variants.create!(:sku => "M12344"
|
10
|
+
@variant = product.variants.create!(:sku => "M12343")
|
11
|
+
@unavailable_variant = product.variants.create!(:sku => "M12344")
|
12
12
|
|
13
13
|
@stock_location1 = Spree::StockLocation.create!(:name => 'test_location')
|
14
14
|
@stock_location2 = Spree::StockLocation.create!(:name => 'test_location')
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
2
|
ENV["RAILS_ENV"] ||= 'test'
|
3
|
-
require File.expand_path(
|
3
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
4
4
|
require 'rspec/rails'
|
5
5
|
# require 'rspec/autorun'
|
6
6
|
|
data/spree-point-of-sale.gemspec
CHANGED
@@ -3,28 +3,28 @@
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.name = "spree-point-of-sale"
|
6
|
-
s.version = "1.0
|
6
|
+
s.version = "1.1.0"
|
7
7
|
|
8
|
-
s.
|
8
|
+
s.author = ["Torsten R, Nishant Tuteja, Manish Kangia"]
|
9
9
|
|
10
10
|
|
11
11
|
s.email = 'info@vinsol.com'
|
12
12
|
s.homepage = 'http://vinsol.com'
|
13
|
+
s.license = 'MIT'
|
13
14
|
|
14
15
|
s.files = `git ls-files`.split("\n")
|
15
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
|
17
|
-
s.
|
17
|
+
s.require_path = ["lib"]
|
18
18
|
s.required_ruby_version = ">= 1.9.3"
|
19
19
|
|
20
|
-
s.requirements
|
20
|
+
s.requirements << "none"
|
21
21
|
s.rubygems_version = "2.0.3"
|
22
22
|
|
23
23
|
s.summary = "Point of sale screen for Spree"
|
24
24
|
s.description = "Extend functionality for spree to give shop like ordering ability through admin end"
|
25
25
|
|
26
26
|
|
27
|
-
s.add_dependency('spree_core', '~> 2.
|
27
|
+
s.add_dependency('spree_core', '~> 2.1.0')
|
28
28
|
s.add_dependency('barby', '>= 0')
|
29
29
|
s.add_dependency('prawn', '>=0')
|
30
30
|
s.add_dependency('chunky_png', '>=0')
|
metadata
CHANGED
@@ -1,88 +1,92 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree-point-of-sale
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 1.1.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Torsten R, Nishant Tuteja, Manish Kangia
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2014-03-07 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: spree_core
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 2.0.0
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
|
-
requirements:
|
25
|
+
requirements:
|
27
26
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 11
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
version: 2.1.0
|
38
34
|
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: barby
|
39
38
|
prerelease: false
|
40
|
-
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
54
48
|
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: prawn
|
55
52
|
prerelease: false
|
56
|
-
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: chunky_png
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
65
54
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
70
62
|
type: :runtime
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: chunky_png
|
71
66
|
prerelease: false
|
72
|
-
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
68
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
type: :runtime
|
77
|
+
version_requirements: *id004
|
78
|
+
description: Extend functionality for spree to give shop like ordering ability through admin end
|
80
79
|
email: info@vinsol.com
|
81
80
|
executables: []
|
81
|
+
|
82
82
|
extensions: []
|
83
|
+
|
83
84
|
extra_rdoc_files: []
|
84
|
-
|
85
|
+
|
86
|
+
files:
|
85
87
|
- .gitignore
|
88
|
+
- .rspec
|
89
|
+
- .travis.yml
|
86
90
|
- Gemfile
|
87
91
|
- LICENSE
|
88
92
|
- README.md
|
@@ -132,6 +136,7 @@ files:
|
|
132
136
|
- config/application.rb
|
133
137
|
- config/boot.rb
|
134
138
|
- config/initializers/constants.rb
|
139
|
+
- config/initializers/spree.rb
|
135
140
|
- config/locales/codes-fi.yml
|
136
141
|
- config/locales/en.yml
|
137
142
|
- config/locales/fi.yml
|
@@ -156,32 +161,43 @@ files:
|
|
156
161
|
- spec/models/spree/stock/pos_availability_validator_spec.rb
|
157
162
|
- spec/models/spree/stock_location_decorator_spec.rb
|
158
163
|
- spec/models/spree/user_decorator_spec.rb
|
159
|
-
- spec/models/spree/
|
164
|
+
- spec/models/spree/variant_decorator_spec.rb
|
160
165
|
- spec/spec_helper.rb
|
161
166
|
- spree-point-of-sale.gemspec
|
162
167
|
homepage: http://vinsol.com
|
163
|
-
licenses:
|
168
|
+
licenses:
|
169
|
+
- MIT
|
164
170
|
post_install_message:
|
165
171
|
rdoc_options: []
|
166
|
-
|
167
|
-
|
168
|
-
|
172
|
+
|
173
|
+
require_paths:
|
174
|
+
- - lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
176
|
none: false
|
170
|
-
requirements:
|
171
|
-
- -
|
172
|
-
- !ruby/object:Gem::Version
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
hash: 53
|
181
|
+
segments:
|
182
|
+
- 1
|
183
|
+
- 9
|
184
|
+
- 3
|
173
185
|
version: 1.9.3
|
174
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
187
|
none: false
|
176
|
-
requirements:
|
177
|
-
- -
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
|
180
|
-
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
hash: 3
|
192
|
+
segments:
|
193
|
+
- 0
|
194
|
+
version: "0"
|
195
|
+
requirements:
|
181
196
|
- none
|
182
197
|
rubyforge_project:
|
183
|
-
rubygems_version: 1.8.
|
198
|
+
rubygems_version: 1.8.24
|
184
199
|
signing_key:
|
185
200
|
specification_version: 3
|
186
201
|
summary: Point of sale screen for Spree
|
187
202
|
test_files: []
|
203
|
+
|