solidus_auction 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: df131228829603b7884ec7fabf7419dc7f9d7b0b
|
|
4
|
+
data.tar.gz: d0c6aaef46255a495f88a9ab0f01dd1666e9d5b4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 13a52317f888f1774d9062e91173cf6237c921a9f1a429efd0dd343b018ff7353ef3932563767eadab23a148e0db1cf4817c7ef245d8addd075b751470b1b8b3
|
|
7
|
+
data.tar.gz: acc34fc044f7fa75b3baea05744f7dc40a1557b861c1d076a73d91e232e77066c9b16c46077ffe3c563c3701dff66d22ebf87137b1d8bafc6d958c5ccea55a50
|
data/.gitignore
ADDED
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--color
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Relaxed.Ruby.Style
|
|
2
|
+
|
|
3
|
+
AllCops:
|
|
4
|
+
Exclude:
|
|
5
|
+
- 'solidus_auction.gemspec'
|
|
6
|
+
- 'spec/dummy/**/*'
|
|
7
|
+
- 'vendor/bundle/**/*'
|
|
8
|
+
- 'app/controllers/spree/helpers/local_time_helper.rb'
|
|
9
|
+
- 'db/migrate/20180410025053_acts_as_votable_migration.rb'
|
|
10
|
+
TargetRubyVersion: 2.1
|
|
11
|
+
|
|
12
|
+
# Sometimes I believe this reads better
|
|
13
|
+
# This also causes spacing issues on multi-line fixes
|
|
14
|
+
Style/BracesAroundHashParameters:
|
|
15
|
+
Enabled: false
|
|
16
|
+
|
|
17
|
+
# We use class vars and will have to continue doing so for compatability
|
|
18
|
+
Style/ClassVars:
|
|
19
|
+
Enabled: false
|
|
20
|
+
|
|
21
|
+
# We need these names for backwards compatability
|
|
22
|
+
Naming/PredicateName:
|
|
23
|
+
Enabled: false
|
|
24
|
+
|
|
25
|
+
Naming/AccessorMethodName:
|
|
26
|
+
Enabled: false
|
|
27
|
+
|
|
28
|
+
# This has been used for customization
|
|
29
|
+
Style/MutableConstant:
|
|
30
|
+
Enabled: false
|
|
31
|
+
|
|
32
|
+
Style/ClassAndModuleChildren:
|
|
33
|
+
Enabled: false
|
|
34
|
+
|
|
35
|
+
Style/GuardClause:
|
|
36
|
+
Enabled: false
|
|
37
|
+
|
|
38
|
+
Style/WordArray:
|
|
39
|
+
Enabled: false
|
|
40
|
+
|
|
41
|
+
Style/ConditionalAssignment:
|
|
42
|
+
Enabled: false
|
|
43
|
+
|
|
44
|
+
Performance/Count:
|
|
45
|
+
Enabled: false
|
|
46
|
+
|
|
47
|
+
Style/RaiseArgs:
|
|
48
|
+
Enabled: false
|
|
49
|
+
|
|
50
|
+
Style/DateTime:
|
|
51
|
+
Enabled: false
|
|
52
|
+
|
|
53
|
+
Naming/BinaryOperatorParameterName:
|
|
54
|
+
Enabled: false
|
|
55
|
+
|
|
56
|
+
# We can use good judgement here
|
|
57
|
+
Style/RegexpLiteral:
|
|
58
|
+
Enabled: false
|
|
59
|
+
|
|
60
|
+
# Unicode comments are useful
|
|
61
|
+
Style/AsciiComments:
|
|
62
|
+
Enabled: false
|
|
63
|
+
|
|
64
|
+
Layout/EndAlignment:
|
|
65
|
+
Enabled: false
|
|
66
|
+
|
|
67
|
+
Layout/ElseAlignment:
|
|
68
|
+
Enabled: false
|
|
69
|
+
|
|
70
|
+
Layout/IndentationWidth:
|
|
71
|
+
Enabled: false
|
|
72
|
+
|
|
73
|
+
Layout/AlignParameters:
|
|
74
|
+
Enabled: false
|
|
75
|
+
|
|
76
|
+
Layout/ClosingParenthesisIndentation:
|
|
77
|
+
Enabled: false
|
|
78
|
+
|
|
79
|
+
Layout/MultilineMethodCallIndentation:
|
|
80
|
+
Enabled: false
|
|
81
|
+
|
|
82
|
+
Layout/IndentArray:
|
|
83
|
+
Enabled: false
|
|
84
|
+
|
|
85
|
+
Layout/IndentHash:
|
|
86
|
+
Enabled: false
|
|
87
|
+
|
|
88
|
+
Layout/AlignHash:
|
|
89
|
+
Enabled: false
|
|
90
|
+
|
|
91
|
+
# From http://relaxed.ruby.style/
|
|
92
|
+
|
|
93
|
+
Style/Alias:
|
|
94
|
+
Enabled: false
|
|
95
|
+
StyleGuide: http://relaxed.ruby.style/#stylealias
|
|
96
|
+
|
|
97
|
+
Style/BeginBlock:
|
|
98
|
+
Enabled: false
|
|
99
|
+
StyleGuide: http://relaxed.ruby.style/#stylebeginblock
|
|
100
|
+
|
|
101
|
+
Style/BlockDelimiters:
|
|
102
|
+
Enabled: false
|
|
103
|
+
StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
|
|
104
|
+
|
|
105
|
+
Style/Documentation:
|
|
106
|
+
Enabled: false
|
|
107
|
+
StyleGuide: http://relaxed.ruby.style/#styledocumentation
|
|
108
|
+
|
|
109
|
+
Layout/DotPosition:
|
|
110
|
+
Enabled: false
|
|
111
|
+
StyleGuide: http://relaxed.ruby.style/#styledotposition
|
|
112
|
+
|
|
113
|
+
Style/DoubleNegation:
|
|
114
|
+
Enabled: false
|
|
115
|
+
StyleGuide: http://relaxed.ruby.style/#styledoublenegation
|
|
116
|
+
|
|
117
|
+
Style/EndBlock:
|
|
118
|
+
Enabled: false
|
|
119
|
+
StyleGuide: http://relaxed.ruby.style/#styleendblock
|
|
120
|
+
|
|
121
|
+
Style/FormatString:
|
|
122
|
+
Enabled: false
|
|
123
|
+
StyleGuide: http://relaxed.ruby.style/#styleformatstring
|
|
124
|
+
|
|
125
|
+
Style/IfUnlessModifier:
|
|
126
|
+
Enabled: false
|
|
127
|
+
StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
|
|
128
|
+
|
|
129
|
+
Style/Lambda:
|
|
130
|
+
Enabled: false
|
|
131
|
+
StyleGuide: http://relaxed.ruby.style/#stylelambda
|
|
132
|
+
|
|
133
|
+
Style/ModuleFunction:
|
|
134
|
+
Enabled: false
|
|
135
|
+
StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
|
|
136
|
+
|
|
137
|
+
Style/MultilineBlockChain:
|
|
138
|
+
Enabled: false
|
|
139
|
+
StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
|
|
140
|
+
|
|
141
|
+
Style/NegatedIf:
|
|
142
|
+
Enabled: false
|
|
143
|
+
StyleGuide: http://relaxed.ruby.style/#stylenegatedif
|
|
144
|
+
|
|
145
|
+
Style/NegatedWhile:
|
|
146
|
+
Enabled: false
|
|
147
|
+
StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
|
|
148
|
+
|
|
149
|
+
Style/ParallelAssignment:
|
|
150
|
+
Enabled: false
|
|
151
|
+
StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
|
|
152
|
+
|
|
153
|
+
Style/PercentLiteralDelimiters:
|
|
154
|
+
Enabled: false
|
|
155
|
+
StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
|
|
156
|
+
|
|
157
|
+
Style/PerlBackrefs:
|
|
158
|
+
Enabled: false
|
|
159
|
+
StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
|
|
160
|
+
|
|
161
|
+
Style/Semicolon:
|
|
162
|
+
Enabled: false
|
|
163
|
+
StyleGuide: http://relaxed.ruby.style/#stylesemicolon
|
|
164
|
+
|
|
165
|
+
Style/SignalException:
|
|
166
|
+
Enabled: false
|
|
167
|
+
StyleGuide: http://relaxed.ruby.style/#stylesignalexception
|
|
168
|
+
|
|
169
|
+
Style/SingleLineBlockParams:
|
|
170
|
+
Enabled: false
|
|
171
|
+
StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
|
|
172
|
+
|
|
173
|
+
Style/SingleLineMethods:
|
|
174
|
+
Enabled: false
|
|
175
|
+
StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
|
|
176
|
+
|
|
177
|
+
Layout/SpaceBeforeBlockBraces:
|
|
178
|
+
Enabled: false
|
|
179
|
+
StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces
|
|
180
|
+
|
|
181
|
+
Layout/SpaceInsideParens:
|
|
182
|
+
Enabled: false
|
|
183
|
+
StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens
|
|
184
|
+
|
|
185
|
+
Style/SpecialGlobalVars:
|
|
186
|
+
Enabled: false
|
|
187
|
+
StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
|
|
188
|
+
|
|
189
|
+
Style/StringLiterals:
|
|
190
|
+
Enabled: false
|
|
191
|
+
StyleGuide: http://relaxed.ruby.style/#stylestringliterals
|
|
192
|
+
|
|
193
|
+
Style/SymbolProc:
|
|
194
|
+
Enabled: false
|
|
195
|
+
|
|
196
|
+
Style/WhileUntilModifier:
|
|
197
|
+
Enabled: false
|
|
198
|
+
StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
|
|
199
|
+
|
|
200
|
+
Lint/AmbiguousRegexpLiteral:
|
|
201
|
+
Enabled: false
|
|
202
|
+
StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
|
|
203
|
+
|
|
204
|
+
Lint/AssignmentInCondition:
|
|
205
|
+
Enabled: false
|
|
206
|
+
StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
|
|
207
|
+
|
|
208
|
+
Lint/HandleExceptions:
|
|
209
|
+
Exclude:
|
|
210
|
+
- 'Rakefile'
|
|
211
|
+
|
|
212
|
+
Metrics/AbcSize:
|
|
213
|
+
Enabled: false
|
|
214
|
+
|
|
215
|
+
Metrics/BlockNesting:
|
|
216
|
+
Enabled: false
|
|
217
|
+
|
|
218
|
+
Metrics/BlockLength:
|
|
219
|
+
Enabled: false
|
|
220
|
+
|
|
221
|
+
Metrics/ClassLength:
|
|
222
|
+
Enabled: false
|
|
223
|
+
|
|
224
|
+
Metrics/ModuleLength:
|
|
225
|
+
Enabled: false
|
|
226
|
+
|
|
227
|
+
Metrics/CyclomaticComplexity:
|
|
228
|
+
Enabled: false
|
|
229
|
+
|
|
230
|
+
Metrics/LineLength:
|
|
231
|
+
Enabled: false
|
|
232
|
+
|
|
233
|
+
Metrics/MethodLength:
|
|
234
|
+
Enabled: false
|
|
235
|
+
|
|
236
|
+
Metrics/ParameterLists:
|
|
237
|
+
Enabled: false
|
|
238
|
+
|
|
239
|
+
Metrics/PerceivedComplexity:
|
|
240
|
+
Enabled: false
|
|
241
|
+
|
|
242
|
+
Style/ExpandPathArguments:
|
|
243
|
+
Enabled: false
|
|
244
|
+
|
|
245
|
+
Style/TrailingUnderscoreVariable:
|
|
246
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/auction_edit.png
ADDED
|
Binary file
|
data/auction_in_cart.png
ADDED
|
Binary file
|
data/auction_show.png
ADDED
|
Binary file
|
|
Binary file
|
data/auctions_index.png
ADDED
|
Binary file
|
data/bin/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/solidus_auction/engine', __FILE__)
|
|
5
|
+
|
|
6
|
+
require 'rails/all'
|
|
7
|
+
require 'rails/engine/commands'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
3
|
+
require 'solidus_auction/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = 'solidus_auction'
|
|
7
|
+
s.version = "0.0.5"
|
|
8
|
+
s.summary = 'Adds auction functionality to a Solidus store'
|
|
9
|
+
s.description = 'Add auctions and bidding to a Solidus store - adds consumer frontend and admin pages'
|
|
10
|
+
s.license = 'BSD-3-Clause'
|
|
11
|
+
s.required_ruby_version = ">= 2.1"
|
|
12
|
+
|
|
13
|
+
s.author = "Jeffrey Gu"
|
|
14
|
+
s.homepage = "https://github.com/jgujgu/solidus_auction"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
|
18
|
+
|
|
19
|
+
s.add_dependency 'solidus'
|
|
20
|
+
s.add_dependency 'deface'
|
|
21
|
+
s.add_dependency 'acts_as_votable'
|
|
22
|
+
|
|
23
|
+
s.add_development_dependency 'awesome_print'
|
|
24
|
+
s.add_development_dependency 'capybara'
|
|
25
|
+
s.add_development_dependency 'coffee-rails'
|
|
26
|
+
s.add_development_dependency 'database_cleaner'
|
|
27
|
+
s.add_development_dependency 'factory_bot_rails'
|
|
28
|
+
s.add_development_dependency 'ffaker'
|
|
29
|
+
s.add_development_dependency 'poltergeist'
|
|
30
|
+
s.add_development_dependency 'rails-controller-testing'
|
|
31
|
+
s.add_development_dependency 'rspec-rails'
|
|
32
|
+
s.add_development_dependency 'rubocop'
|
|
33
|
+
s.add_development_dependency 'rubocop-rspec'
|
|
34
|
+
s.add_development_dependency 'sass-rails'
|
|
35
|
+
s.add_development_dependency 'simplecov'
|
|
36
|
+
s.add_development_dependency 'sqlite3'
|
|
37
|
+
end
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Spree::Admin::AuctionsController do
|
|
4
|
+
stub_authorization!
|
|
5
|
+
|
|
6
|
+
let(:auction) { create(:auction) }
|
|
7
|
+
let(:product) { create(:product) }
|
|
8
|
+
let(:admin_user) { create(:admin_user) }
|
|
9
|
+
let(:user) { create(:user) }
|
|
10
|
+
let(:auction_params) {
|
|
11
|
+
{ auction: {
|
|
12
|
+
title: FFaker::Book.title,
|
|
13
|
+
description: FFaker::Book.description,
|
|
14
|
+
starting_datetime: Time.now,
|
|
15
|
+
planned_end_datetime: Time.now + 1.day,
|
|
16
|
+
starting_price: Random.rand(4000),
|
|
17
|
+
product_id: product.id
|
|
18
|
+
} }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
before do
|
|
22
|
+
controller.stub spree_current_user: admin_user
|
|
23
|
+
controller.stub spree_user_signed_in?: true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
context '#index' do
|
|
27
|
+
it 'lists auctions' do
|
|
28
|
+
auctions = [
|
|
29
|
+
create(:auction),
|
|
30
|
+
create(:auction),
|
|
31
|
+
create(:auction)
|
|
32
|
+
]
|
|
33
|
+
get :index
|
|
34
|
+
expect(assigns[:auctions]).to match_array auctions
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'renders the index template' do
|
|
38
|
+
get :index
|
|
39
|
+
expect(response.status).to eq 200
|
|
40
|
+
expect(response).to render_template :index
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context '#show' do
|
|
45
|
+
it 'redirects to #edit' do
|
|
46
|
+
get :show, params: { id: auction.id }
|
|
47
|
+
expect(response.status).to eq 302
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context '#new' do
|
|
52
|
+
it 'assigns an auction instance variable' do
|
|
53
|
+
get :new
|
|
54
|
+
expect(assigns[:object]).to be_a_kind_of Spree::Auction
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'assigns an auction instance variable' do
|
|
58
|
+
get :new
|
|
59
|
+
expect(assigns[:auction]).to be_a_kind_of Spree::Auction
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'renders the new template' do
|
|
63
|
+
get :new
|
|
64
|
+
expect(response.status).to eq 200
|
|
65
|
+
expect(response).to render_template :new
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
context '#create' do
|
|
70
|
+
it 'creates an auction' do
|
|
71
|
+
expect {
|
|
72
|
+
post :create, params: auction_params
|
|
73
|
+
}.to change(Spree::Auction, :count).by(1)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'fails if the user is not authorized to create a review' do
|
|
77
|
+
controller.stub spree_current_user: user
|
|
78
|
+
controller.stub spree_user_signed_in?: true
|
|
79
|
+
controller.stub(:authorize!) { raise }
|
|
80
|
+
expect{
|
|
81
|
+
post :create, params: auction_params
|
|
82
|
+
}.to raise_error RuntimeError
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'creates an auction connected to the signed in admin user' do
|
|
86
|
+
post :create, params: auction_params
|
|
87
|
+
expect(Spree::Auction.first.creator).to eq admin_user
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'flashes a success' do
|
|
91
|
+
post :create, params: auction_params
|
|
92
|
+
expect(flash[:success]).to eq "Auction has been successfully created!"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it 'redirects to #show then #edit' do
|
|
96
|
+
post :create, params: auction_params
|
|
97
|
+
expect(response.status).to eq 302
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
context '#edit' do
|
|
102
|
+
it 'assigns an auction instance variable' do
|
|
103
|
+
get :edit, params: { id: auction.id }
|
|
104
|
+
expect(assigns[:auction]).to be_a_kind_of Spree::Auction
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'renders the edit template' do
|
|
108
|
+
get :edit, params: { id: auction.id }
|
|
109
|
+
expect(response.status).to eq 200
|
|
110
|
+
expect(response).to render_template :edit
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
context '#update' do
|
|
115
|
+
let(:auction) { create(:auction, creator: admin_user) }
|
|
116
|
+
let(:update_auction_params) {
|
|
117
|
+
{ id: auction.id, auction: {
|
|
118
|
+
title: FFaker::Book.title,
|
|
119
|
+
description: FFaker::Book.description,
|
|
120
|
+
starting_price: Random.rand(4000),
|
|
121
|
+
time_increment: Random.rand(60),
|
|
122
|
+
bid_increment: Random.rand(100),
|
|
123
|
+
countdown: 600
|
|
124
|
+
} }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
it 'updates the auction' do
|
|
128
|
+
put :update, params: update_auction_params
|
|
129
|
+
auction.reload
|
|
130
|
+
update_auction_params[:auction].each do |k, v|
|
|
131
|
+
expect(auction[k]).to eq v
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'flashes a successfully updated notice' do
|
|
136
|
+
put :update, params: update_auction_params
|
|
137
|
+
expect(flash[:success]).to eq("Auction has been successfully updated!")
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'flashes an unsuccessfully updated notice for a nonexisting id number' do
|
|
141
|
+
update_auction_params[:id] = auction.id + 10
|
|
142
|
+
put :update, params: update_auction_params
|
|
143
|
+
expect(flash[:error]).to eq("Auction is not found")
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|