From e396401a4a6833e1a66bb1ebfe78ab82d634af54 Mon Sep 17 00:00:00 2001 From: benji Date: Tue, 2 Feb 2016 14:42:02 +0100 Subject: [PATCH 1/6] Fix some stuff --- Gemfile | 1 - Gemfile.lock | 56 ++++++++----------- app/jobs/tab_api_job.rb | 6 ++ app/models/barcode.rb | 1 - ...ove_encrypted_password_from_users_again.rb | 5 ++ db/schema.rb | 3 +- 6 files changed, 35 insertions(+), 37 deletions(-) create mode 100644 db/migrate/20160202133903_remove_encrypted_password_from_users_again.rb diff --git a/Gemfile b/Gemfile index a861767..76c740f 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,6 @@ end group :development, :test do gem 'factory_girl_rails' gem 'faker', '1.4.2' - gem 'pry-rails' end # Airbrake diff --git a/Gemfile.lock b/Gemfile.lock index a8d04da..4e14ad5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,7 +36,7 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - airbrake (4.3.4) + airbrake (4.3.5) builder multi_json annotate (2.7.0) @@ -60,10 +60,10 @@ GEM sshkit (~> 1.2) capistrano-passenger (0.2.0) capistrano (~> 3.0) - capistrano-rails (1.1.5) + capistrano-rails (1.1.6) capistrano (~> 3.1) capistrano-bundler (~> 1.1) - capistrano-rbenv (2.0.3) + capistrano-rbenv (2.0.4) capistrano (~> 3.1) sshkit (~> 1.3) capistrano-rvm (0.1.2) @@ -76,7 +76,6 @@ GEM climate_control (>= 0.0.3, < 1.0) codeclimate-test-reporter (0.4.8) simplecov (>= 0.7.1, < 1.0.0) - coderay (1.1.0) coffee-rails (4.1.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.1.x) @@ -97,7 +96,7 @@ GEM delayed_job_active_record (4.1.0) activerecord (>= 3.0, < 5) delayed_job (>= 3.0, < 5) - devise (3.5.3) + devise (3.5.6) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) @@ -106,7 +105,7 @@ GEM warden (~> 1.2.3) diff-lcs (1.2.5) docile (1.1.5) - domain_name (0.5.25) + domain_name (0.5.20160128) unf (>= 0.0.5, < 1.0.0) erubis (2.7.0) execjs (2.6.0) @@ -147,21 +146,20 @@ GEM i18n (0.7.0) identicon (0.0.5) chunky_png - jquery-rails (4.0.5) + jquery-rails (4.1.0) rails-dom-testing (~> 1.0) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.3) - jwt (1.5.2) + jwt (1.5.1) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.3) mime-types (>= 1.16, < 3) - method_source (0.8.2) mime-types (2.99) mimemagic (0.3.0) mini_portile2 (2.0.0) - minitest (5.8.3) + minitest (5.8.4) multi_json (1.11.2) multi_xml (0.5.5) multipart-post (2.0.0) @@ -171,16 +169,16 @@ GEM net-ssh (>= 2.6.5) net-ssh (3.0.2) netrc (0.11.0) - nokogiri (1.6.7.1) + nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) - nokogiri (1.6.7.1-x64-mingw32) + nokogiri (1.6.7.2-x64-mingw32) mini_portile2 (~> 2.0.0.rc2) - oauth2 (1.0.0) + oauth2 (1.1.0) faraday (>= 0.8, < 0.10) - jwt (~> 1.0) + jwt (~> 1.0, < 1.5.2) multi_json (~> 1.3) multi_xml (~> 0.5) - rack (~> 1.2) + rack (>= 1.2, < 3) omniauth (1.3.1) hashie (>= 1.2, < 4) rack (>= 1.0, < 3) @@ -188,18 +186,12 @@ GEM oauth2 (~> 1.0) omniauth (~> 1.2) orm_adapter (0.5.0) - paperclip (4.3.2) + paperclip (4.3.3) activemodel (>= 3.2.0) activesupport (>= 3.2.0) cocaine (~> 0.5.5) mime-types mimemagic (= 0.3.0) - pry (0.10.3) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - pry-rails (0.3.4) - pry (>= 0.9.10) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) @@ -220,14 +212,14 @@ GEM activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) + rails-html-sanitizer (1.0.3) loofah (~> 2.0) railties (4.2.4) actionpack (= 4.2.4) activesupport (= 4.2.4) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) + rake (10.5.0) rdoc (4.2.1) json (~> 1.4) responders (2.1.1) @@ -241,15 +233,15 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) - rspec-core (3.4.1) + rspec-core (3.4.2) rspec-support (~> 3.4.0) rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) - rspec-mocks (3.4.0) + rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) - rspec-rails (3.4.0) + rspec-rails (3.4.1) actionpack (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3) railties (>= 3.0, < 4.3) @@ -258,7 +250,7 @@ GEM rspec-mocks (~> 3.4.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - ruby_parser (3.7.2) + ruby_parser (3.7.3) sexp_processor (~> 4.1) sass (3.2.19) sass-rails (4.0.5) @@ -269,14 +261,13 @@ GEM sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - sexp_processor (4.6.0) + sexp_processor (4.6.1) simplecov (0.11.1) docile (~> 1.1.0) json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) - slop (3.6.0) - spring (1.6.1) + spring (1.6.2) sprockets (2.12.4) hike (~> 1.2) multi_json (~> 1.0) @@ -308,7 +299,7 @@ GEM unf_ext unf_ext (0.0.7.1) unf_ext (0.0.7.1-x64-mingw32) - warden (1.2.4) + warden (1.2.6) rack (>= 1.0) will_paginate (3.0.7) @@ -343,7 +334,6 @@ DEPENDENCIES mysql2 omniauth-oauth2 (= 1.3.1) paperclip - pry-rails rails (= 4.2.4) rspec-rails sass-rails (~> 4.0.3) diff --git a/app/jobs/tab_api_job.rb b/app/jobs/tab_api_job.rb index e9cda89..263547c 100644 --- a/app/jobs/tab_api_job.rb +++ b/app/jobs/tab_api_job.rb @@ -19,6 +19,12 @@ TabApiJob = Struct.new(:order_id) do end end + def headers + { + "Authorization" => "Token token=#{Rails.application.secrets.tab_api_key}" + } + end + def error(job, exception) Airbrake.notify(exception) end diff --git a/app/models/barcode.rb b/app/models/barcode.rb index 1e03f54..c6fdd7a 100644 --- a/app/models/barcode.rb +++ b/app/models/barcode.rb @@ -15,6 +15,5 @@ class Barcode < ActiveRecord::Base belongs_to :product - validates :product, presence: true validates :code, presence: true, uniqueness: true end diff --git a/db/migrate/20160202133903_remove_encrypted_password_from_users_again.rb b/db/migrate/20160202133903_remove_encrypted_password_from_users_again.rb new file mode 100644 index 0000000..cf04542 --- /dev/null +++ b/db/migrate/20160202133903_remove_encrypted_password_from_users_again.rb @@ -0,0 +1,5 @@ +class RemoveEncryptedPasswordFromUsersAgain < ActiveRecord::Migration + def change + remove_column :users, :encrypted_password, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 3640807..9b20310 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151028223229) do +ActiveRecord::Schema.define(version: 20160202133903) do create_table "barcodes", force: :cascade do |t| t.integer "product_id" @@ -84,7 +84,6 @@ ActiveRecord::Schema.define(version: 20151028223229) do t.integer "orders_count", default: 0 t.boolean "koelkast", default: false t.string "name" - t.string "encrypted_password", default: "", null: false t.boolean "private", default: false end From 6aec736c5296c507fc9b08e077d92cd1197d16ee Mon Sep 17 00:00:00 2001 From: benji Date: Tue, 2 Feb 2016 15:20:04 +0100 Subject: [PATCH 2/6] Little bug with user order --- app/controllers/orders_controller.rb | 4 +++- config/application.rb | 2 +- config/environments/development.rb | 1 + config/secrets.yml | 2 +- lib/tasks/devseeds.rake | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 2516cdf..c863a32 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -1,6 +1,7 @@ class OrdersController < ApplicationController load_resource :user - load_and_authorize_resource :order, through: :user, shallow: true + load_and_authorize_resource :order, through: :user, shallow: true, only: [:overview, :destroy] + load_and_authorize_resource :order, through: :user, only: [:new, :create] def new @products = Product.all.for_sale.order(:name) @@ -8,6 +9,7 @@ class OrdersController < ApplicationController end def create + @order.user = @user if @order.save flash[:success] = @order.flash_success redirect_to root_path diff --git a/config/application.rb b/config/application.rb index 440e031..6c4e407 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,6 +21,6 @@ module Tab002 # config.i18n.default_locale = :de config.active_record.raise_in_transactional_callbacks = true config.active_job.queue_adapter = :delayed_job - config.call_api_after = 5.minutes + config.call_api_after = 5.seconds end end diff --git a/config/environments/development.rb b/config/environments/development.rb index 6c0915c..a35e5e9 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -40,4 +40,5 @@ Rails.application.configure do config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } config.api_url = "http://localhost:3001" + Delayed::Worker.logger = Rails.logger end diff --git a/config/secrets.yml b/config/secrets.yml index 84248ce..388228d 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -15,7 +15,7 @@ development: omniauth_client_id: tomtest omniauth_client_secret: blargh access_token: "token" - tab_api_key: "HriaktSIhRaB5CJzD71uLQ==" + tab_api_key: "o6UIYc0r0cvsy0Ohaohqsw==" koelkast_token: "token" test: diff --git a/lib/tasks/devseeds.rake b/lib/tasks/devseeds.rake index 3d6dbf8..b26cbe4 100644 --- a/lib/tasks/devseeds.rake +++ b/lib/tasks/devseeds.rake @@ -2,7 +2,7 @@ unless Rails.env.production? require 'factory_girl' require 'faker' task :sow => :environment do - FactoryGirl.create_list(:user, 20) + # FactoryGirl.create_list(:user, 20) FactoryGirl.create_list(:product, 20) end end From 0ee070d27e13bf3a2843e1d9820a992bb921bf64 Mon Sep 17 00:00:00 2001 From: benji Date: Tue, 2 Feb 2016 17:50:22 +0100 Subject: [PATCH 3/6] Make link of balance --- app/views/layouts/_header.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 94ebeb0..f406204 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -32,6 +32,7 @@ %li= link_to "Edit profile", edit_user_path(current_user) %li %p.navbar-text - Balance: #{euro_from_cents(current_user.balance)} + Balance: + = link_to euro_from_cents(current_user.balance), "https://zeus.ugent.be/tab/users/#{current_user.name}" .visible-xs.navbar-form = render 'layouts/session_button' From 969ae541a14710bb68d0e7f792fee01dd94926c8 Mon Sep 17 00:00:00 2001 From: benji Date: Tue, 2 Feb 2016 18:35:32 +0100 Subject: [PATCH 4/6] Fix failing test --- spec/models/order_spec.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 0c49692..a11d064 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -55,13 +55,6 @@ describe Order do expect(@order).to_not be_valid end end - - describe 'products' do - it 'should be present' do - @order.products.clear - expect(@order).to_not be_valid - end - end end ############### From e07cf3898699ab980b9381e50803a4cb1dcafaf5 Mon Sep 17 00:00:00 2001 From: benji Date: Tue, 2 Feb 2016 18:46:05 +0100 Subject: [PATCH 5/6] Revert "Fix failing test" This reverts commit d210ff9da21e0185c2f0dc9d116ce90b2d2beffb. --- spec/models/order_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index a11d064..0c49692 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -55,6 +55,13 @@ describe Order do expect(@order).to_not be_valid end end + + describe 'products' do + it 'should be present' do + @order.products.clear + expect(@order).to_not be_valid + end + end end ############### From 1c52891210895b7d37260200d33dfff969b5b652 Mon Sep 17 00:00:00 2001 From: benji Date: Tue, 2 Feb 2016 18:49:22 +0100 Subject: [PATCH 6/6] remove the right test --- spec/models/barcode_spec.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spec/models/barcode_spec.rb b/spec/models/barcode_spec.rb index 77acc1a..eb6787e 100644 --- a/spec/models/barcode_spec.rb +++ b/spec/models/barcode_spec.rb @@ -34,12 +34,5 @@ describe Barcode do expect(barcode).to_not be_valid end end - - describe 'product' do - it 'should be present' do - @barcode.product = nil - expect(@barcode).to_not be_valid - end - end end end