solidus_auction 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +15 -0
- data/.rspec +1 -0
- data/.rubocop.yml +246 -0
- data/.travis.yml +5 -0
- data/Gemfile +5 -0
- data/auction_edit.png +0 -0
- data/auction_in_cart.png +0 -0
- data/auction_show.png +0 -0
- data/auctions_admin_index.png +0 -0
- data/auctions_index.png +0 -0
- data/bin/rails +7 -0
- data/lib/solidus_auction/version.rb +1 -1
- data/solidus_auction.gemspec +37 -0
- data/spec/controllers/admin/auctions_controller_spec.rb +146 -0
- data/spec/controllers/auctions_controller_spec.rb +45 -0
- data/spec/controllers/bids_controller_spec.rb +114 -0
- data/spec/features/auctions_spec.rb +4 -0
- data/spec/models/auction_ability_spec.rb +37 -0
- data/spec/models/auction_spec.rb +834 -0
- data/spec/models/bid_spec.rb +81 -0
- data/spec/spec_helper.rb +97 -0
- metadata +32 -4
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Spree::Bid, type: :model do
|
4
|
+
context 'initializes' do
|
5
|
+
let(:bidder) { create(:user) }
|
6
|
+
let(:bid) { create(:bid, { bidder: bidder }) }
|
7
|
+
|
8
|
+
it 'has an amount' do
|
9
|
+
expect(bid.amount).to eq 26.00
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'has a bidder' do
|
13
|
+
expect(bid.bidder).to be bidder
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has no visibility or acceptance by default' do
|
17
|
+
expect(bid.visible).to be false
|
18
|
+
expect(bid.accepted).to be false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'changes state during auction reception' do
|
23
|
+
let(:creator) { create(:user) }
|
24
|
+
let(:product) { create(:product) }
|
25
|
+
let!(:auction) {
|
26
|
+
create(:auction, {
|
27
|
+
product: product,
|
28
|
+
creator: creator,
|
29
|
+
starting_price: 25.00,
|
30
|
+
bid_increment: 1.00
|
31
|
+
})}
|
32
|
+
let(:bidder) { create(:user) }
|
33
|
+
let(:bidder1) { create(:user) }
|
34
|
+
let(:bidder2) { create(:user) }
|
35
|
+
|
36
|
+
it 'is visible and accepted as the highest bid within increment' do
|
37
|
+
bid = create(:bid, amount: 26.00, auction: auction, bidder: bidder)
|
38
|
+
|
39
|
+
auction.receive_bid(bid)
|
40
|
+
expect(auction.current_price).to eq 26.00
|
41
|
+
bid.reload
|
42
|
+
expect(bid.visible).to be true
|
43
|
+
expect(bid.accepted).to be true
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'is invisible and unaccepted if it is below current price' do
|
47
|
+
bid = create(:bid, amount: 15.00, auction: auction, bidder: bidder)
|
48
|
+
|
49
|
+
auction.receive_bid(bid)
|
50
|
+
expect(auction.current_price).to eq 25.00
|
51
|
+
bid.reload
|
52
|
+
expect(bid.visible).to be false
|
53
|
+
expect(bid.accepted).to be false
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'is invisible and accepted as the highest bid exceeding increment' do
|
57
|
+
bid = create(:bid, amount: 50.00, auction: auction, bidder: bidder)
|
58
|
+
|
59
|
+
auction.receive_bid(bid)
|
60
|
+
expect(auction.current_price).to eq 26.00
|
61
|
+
bid.reload
|
62
|
+
expect(bid.visible).to be false
|
63
|
+
expect(bid.accepted).to be true
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'is visible and accepted even when out-autobid' do
|
67
|
+
bid1 = create(:bid, amount: 50.00, auction: auction, bidder: bidder1)
|
68
|
+
|
69
|
+
auction.receive_bid(bid1)
|
70
|
+
expect(auction.current_price).to eq 26.00
|
71
|
+
|
72
|
+
bid2 = create(:bid, amount: 30.00, auction: auction, bidder: bidder2)
|
73
|
+
auction.receive_bid(bid2)
|
74
|
+
expect(auction.current_price).to eq 31.00
|
75
|
+
|
76
|
+
bid2.reload
|
77
|
+
expect(bid2.visible).to be true
|
78
|
+
expect(bid2.accepted).to be true
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# Run Coverage report
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter 'spec/dummy'
|
5
|
+
add_group 'Controllers', 'app/controllers'
|
6
|
+
add_group 'Helpers', 'app/helpers'
|
7
|
+
add_group 'Mailers', 'app/mailers'
|
8
|
+
add_group 'Models', 'app/models'
|
9
|
+
add_group 'Views', 'app/views'
|
10
|
+
add_group 'Libraries', 'lib'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Configure Rails Environment
|
14
|
+
ENV['RAILS_ENV'] = 'test'
|
15
|
+
|
16
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
17
|
+
|
18
|
+
require 'rspec/rails'
|
19
|
+
require 'database_cleaner'
|
20
|
+
require 'ffaker'
|
21
|
+
require 'awesome_print'
|
22
|
+
require 'rails-controller-testing'
|
23
|
+
|
24
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
25
|
+
# in spec/support/ and its subdirectories.
|
26
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
27
|
+
|
28
|
+
# Requires factories and other useful helpers defined in spree_core.
|
29
|
+
require 'spree/testing_support/authorization_helpers'
|
30
|
+
require 'spree/testing_support/capybara_ext'
|
31
|
+
require 'spree/testing_support/controller_requests'
|
32
|
+
require 'spree/testing_support/factories'
|
33
|
+
require 'spree/testing_support/url_helpers'
|
34
|
+
|
35
|
+
# Requires factories defined in lib/solidus_auction/factories.rb
|
36
|
+
require 'solidus_auction/factories'
|
37
|
+
|
38
|
+
RSpec.configure do |config|
|
39
|
+
config.include FactoryBot::Syntax::Methods
|
40
|
+
require 'solidus_auction/factories'
|
41
|
+
|
42
|
+
# Infer an example group's spec type from the file location.
|
43
|
+
config.infer_spec_type_from_file_location!
|
44
|
+
|
45
|
+
# == URL Helpers
|
46
|
+
#
|
47
|
+
# Allows access to Spree's routes in specs:
|
48
|
+
#
|
49
|
+
# visit spree.admin_path
|
50
|
+
# current_path.should eql(spree.products_path)
|
51
|
+
config.include Spree::TestingSupport::UrlHelpers
|
52
|
+
config.include Spree::TestingSupport::ControllerRequests, type: :controller
|
53
|
+
|
54
|
+
# == Mock Framework
|
55
|
+
#
|
56
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
57
|
+
#
|
58
|
+
# config.mock_with :mocha
|
59
|
+
# config.mock_with :flexmock
|
60
|
+
# config.mock_with :rr
|
61
|
+
config.mock_with :rspec
|
62
|
+
config.color = true
|
63
|
+
|
64
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
65
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
66
|
+
|
67
|
+
# Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
|
68
|
+
# to cleanup after each test instead. Without transactional fixtures set to false the records created
|
69
|
+
# to setup a test will be unavailable to the browser, which runs under a separate server instance.
|
70
|
+
config.use_transactional_fixtures = false
|
71
|
+
|
72
|
+
# Ensure Suite is set to use transactions for speed.
|
73
|
+
config.before :suite do
|
74
|
+
DatabaseCleaner.strategy = :transaction
|
75
|
+
DatabaseCleaner.clean_with :truncation
|
76
|
+
end
|
77
|
+
|
78
|
+
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
|
79
|
+
config.before :each do
|
80
|
+
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
|
81
|
+
DatabaseCleaner.start
|
82
|
+
end
|
83
|
+
|
84
|
+
# After each spec clean the database.
|
85
|
+
config.after :each do
|
86
|
+
DatabaseCleaner.clean
|
87
|
+
end
|
88
|
+
|
89
|
+
config.fail_fast = ENV['FAIL_FAST'] || false
|
90
|
+
config.order = 'random'
|
91
|
+
|
92
|
+
%i{controller view request}.each do |type|
|
93
|
+
config.include ::Rails::Controller::Testing::TestProcess, type: type
|
94
|
+
config.include ::Rails::Controller::Testing::TemplateAssertions, type: type
|
95
|
+
config.include ::Rails::Controller::Testing::Integration, type: type
|
96
|
+
end
|
97
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_auction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey Gu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus
|
@@ -255,6 +255,11 @@ executables: []
|
|
255
255
|
extensions: []
|
256
256
|
extra_rdoc_files: []
|
257
257
|
files:
|
258
|
+
- ".gitignore"
|
259
|
+
- ".rspec"
|
260
|
+
- ".rubocop.yml"
|
261
|
+
- ".travis.yml"
|
262
|
+
- Gemfile
|
258
263
|
- LICENSE
|
259
264
|
- README.md
|
260
265
|
- Rakefile
|
@@ -346,6 +351,12 @@ files:
|
|
346
351
|
- app/views/spree/shared/_variant_stock_item_disable.html.erb
|
347
352
|
- app/views/spree/shared/_votes.html.erb
|
348
353
|
- app/views/spree/votes/index.html.erb
|
354
|
+
- auction_edit.png
|
355
|
+
- auction_in_cart.png
|
356
|
+
- auction_show.png
|
357
|
+
- auctions_admin_index.png
|
358
|
+
- auctions_index.png
|
359
|
+
- bin/rails
|
349
360
|
- config/locales/en.yml
|
350
361
|
- config/routes.rb
|
351
362
|
- db/migrate/20180225234309_create_auctions.rb
|
@@ -379,6 +390,15 @@ files:
|
|
379
390
|
- lib/solidus_auction/engine.rb
|
380
391
|
- lib/solidus_auction/factories.rb
|
381
392
|
- lib/solidus_auction/version.rb
|
393
|
+
- solidus_auction.gemspec
|
394
|
+
- spec/controllers/admin/auctions_controller_spec.rb
|
395
|
+
- spec/controllers/auctions_controller_spec.rb
|
396
|
+
- spec/controllers/bids_controller_spec.rb
|
397
|
+
- spec/features/auctions_spec.rb
|
398
|
+
- spec/models/auction_ability_spec.rb
|
399
|
+
- spec/models/auction_spec.rb
|
400
|
+
- spec/models/bid_spec.rb
|
401
|
+
- spec/spec_helper.rb
|
382
402
|
homepage: https://github.com/jgujgu/solidus_auction
|
383
403
|
licenses:
|
384
404
|
- BSD-3-Clause
|
@@ -399,8 +419,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
399
419
|
version: '0'
|
400
420
|
requirements: []
|
401
421
|
rubyforge_project:
|
402
|
-
rubygems_version: 2.
|
422
|
+
rubygems_version: 2.6.14
|
403
423
|
signing_key:
|
404
424
|
specification_version: 4
|
405
425
|
summary: Adds auction functionality to a Solidus store
|
406
|
-
test_files:
|
426
|
+
test_files:
|
427
|
+
- spec/controllers/admin/auctions_controller_spec.rb
|
428
|
+
- spec/controllers/auctions_controller_spec.rb
|
429
|
+
- spec/controllers/bids_controller_spec.rb
|
430
|
+
- spec/features/auctions_spec.rb
|
431
|
+
- spec/models/auction_ability_spec.rb
|
432
|
+
- spec/models/auction_spec.rb
|
433
|
+
- spec/models/bid_spec.rb
|
434
|
+
- spec/spec_helper.rb
|