File tree Expand file tree Collapse file tree 4 files changed +21
-11
lines changed
Expand file tree Collapse file tree 4 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ See the `Makefile` for all commands.
4848Run ` bundle exec rake` \
4949or if that doesn' t work try `bundle exec rspec`?
5050
51+ #### Linter (rubocop)
52+ - Run `bundle exec rubocop` to lint
53+ - To autocorrect most offences
54+ - safely : `bundle exec rubocop -a`
55+ - unsafely : `bundle exec rubocop -A`
56+
5157## Deploy to production
5258
53591. Make sure your user has access to tap@tap.zeus.gent.
Original file line number Diff line number Diff line change @@ -108,10 +108,12 @@ def quick_order
108108 product = Product . find_by ( id : params [ :product_id ] )
109109
110110 unless product
111- flash [ :error ] = "Product not found!"
111+ flash . now [ :error ] = "Product not found!"
112112 respond_to do |format |
113113 format . html { redirect_back_or_to ( root_path ) }
114- format . json { render json : { message : "Quick order failed for #{ @user . name } . Product not found." } , status : :bad_request }
114+ format . json do
115+ render json : { message : "Quick order failed for #{ @user . name } . Product not found." } , status : :bad_request
116+ end
115117 end
116118 return
117119 end
@@ -135,9 +137,11 @@ def quick_order
135137 flash [ :error ] = order . valid? ? "Something went wrong! Please try again." : order . errors . full_messages . join ( ". " )
136138 respond_to do |format |
137139 format . html { redirect_back_or_to ( root_path ) }
138- format . json { render json : {
139- message : order . errors . full_messages . join ( ". " )
140- } , status : :unprocessable_entity }
140+ format . json do
141+ render json : {
142+ message : order . errors . full_messages . join ( ". " )
143+ } , status : :unprocessable_content
144+ end
141145 end
142146 end
143147 end
Original file line number Diff line number Diff line change @@ -109,11 +109,11 @@ def balance
109109
110110 def last_ordered_products ( amount = 5 )
111111 orders . includes ( :products )
112- . order ( created_at : :desc )
113- . limit ( amount )
114- . flat_map ( &:products )
115- . uniq
116- . first ( amount )
112+ . order ( created_at : :desc )
113+ . limit ( amount )
114+ . flat_map ( &:products )
115+ . uniq
116+ . first ( amount )
117117 end
118118
119119 # Static Users
Original file line number Diff line number Diff line change 225225 context "with an invalid product_id" do
226226 it "does not create an order" do
227227 expect do
228- post :quick_order , params : { id : user . id , product_id : 99999 }
228+ post :quick_order , params : { id : user . id , product_id : 99_999 }
229229 end . not_to change ( Order , :count )
230230 end
231231 end
You can’t perform that action at this time.
0 commit comments