From a14687d5688d266412d59ee2c81211bcb01aee32 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Sat, 1 Dec 2012 13:20:39 +0100 Subject: [PATCH] fix bug for closing lists on preloaded view and add acceptance body --- .rspec | 1 + Gemfile | 5 +--- Gemfile.lock | 10 +++++-- app/controllers/supplier_controller.rb | 1 + app/views/layouts/phone.html.slim | 4 +-- spec/acceptance/acceptance_helper.rb | 4 +++ .../supplier_main_board_spec.rb_spec.rb | 17 +++++++++++ spec/acceptance/support/helpers.rb | 30 +++++++++++++++++++ spec/acceptance/support/paths.rb | 9 ++++++ 9 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 .rspec create mode 100644 spec/acceptance/acceptance_helper.rb create mode 100644 spec/acceptance/supplier_main_board_spec.rb_spec.rb create mode 100644 spec/acceptance/support/helpers.rb create mode 100644 spec/acceptance/support/paths.rb diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..4e1e0d2f --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--color diff --git a/Gemfile b/Gemfile index a5f732dd..b1e78b35 100644 --- a/Gemfile +++ b/Gemfile @@ -52,12 +52,9 @@ group :development do end group :test do - gem 'rspec-rails' - #gem 'minitest' + gem 'steak' gem 'pry' gem 'factory_girl_rails' - gem 'selenium-webdriver' #, '2.21.1' # 2.21.2 gives trouble, remove this line when this is solved since this is a dependency of capybara - gem 'capybara' end # Use unicorn as the app server diff --git a/Gemfile.lock b/Gemfile.lock index bbd8bd91..f48f5728 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,6 +46,7 @@ GEM activesupport (3.2.9) i18n (~> 0.6) multi_json (~> 1.0) + addressable (2.3.2) arel (3.0.2) bcrypt-ruby (3.0.1) builder (3.0.4) @@ -123,7 +124,8 @@ GEM actionpack (>= 3.1) less (~> 2.2.0) libv8 (3.3.10.4) - libwebsocket (0.1.6.1) + libwebsocket (0.1.7.1) + addressable websocket mail (2.4.4) i18n (>= 0.4.0) @@ -211,6 +213,9 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) + steak (2.0.0) + capybara (>= 1.0.0) + rspec-rails (>= 2.5.0) subexec (0.2.2) temple (0.5.5) therubyracer (0.10.2) @@ -242,7 +247,6 @@ PLATFORMS ruby DEPENDENCIES - capybara coffee-rails (~> 3.2.1) compass-rails couch_potato! @@ -262,9 +266,9 @@ DEPENDENCIES rqrcode rspec-rails sass-rails (~> 3.2.3) - selenium-webdriver simply_stored! slim-rails + steak therubyracer thin twitter-bootstrap-rails diff --git a/app/controllers/supplier_controller.rb b/app/controllers/supplier_controller.rb index 788ea290..f1578f1f 100644 --- a/app/controllers/supplier_controller.rb +++ b/app/controllers/supplier_controller.rb @@ -51,6 +51,7 @@ class SupplierController < ApplicationController ho[:table_number] = order.table_number ho[:section_title] = order.list.table.section.try(:title) ho[:id] = order.id + ho[:list_id] = order.list_id list_total += ho[:total_amount] h[:orders] << ho end diff --git a/app/views/layouts/phone.html.slim b/app/views/layouts/phone.html.slim index e311c3d7..d1fb7f5d 100644 --- a/app/views/layouts/phone.html.slim +++ b/app/views/layouts/phone.html.slim @@ -25,7 +25,7 @@ html lang="en" - unless ENV['QWAITER_MOBILE_EXPORT'] == 'yes' javascript: #{Rails.env.production? ? '' : "data_host = 'http://qwaiter.dev';"} - //var data_host = 'http://localhost:3000'; + var data_host = 'http://localhost:3000'; QMobile || (QMobile = { scanQr: function(){window.location = '/select_qrcode'}, activateRotation: function(){}, @@ -76,7 +76,7 @@ html lang="en" .span12 = yield = javascript_include_tag "user/application" - script#alert-template[type="text/html"]= render 'alert.mustache' + script#alert-template[type="text/html"]= render 'user/alert.mustache' = yield :footer javascript: jQuery(function(){#{onload_javascript}}); diff --git a/spec/acceptance/acceptance_helper.rb b/spec/acceptance/acceptance_helper.rb new file mode 100644 index 00000000..71946ade --- /dev/null +++ b/spec/acceptance/acceptance_helper.rb @@ -0,0 +1,4 @@ +require 'spec_helper' + +# Put your acceptance spec helpers inside spec/acceptance/support +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} \ No newline at end of file diff --git a/spec/acceptance/supplier_main_board_spec.rb_spec.rb b/spec/acceptance/supplier_main_board_spec.rb_spec.rb new file mode 100644 index 00000000..89e43e61 --- /dev/null +++ b/spec/acceptance/supplier_main_board_spec.rb_spec.rb @@ -0,0 +1,17 @@ +require 'acceptance/acceptance_helper' + +feature 'Supplier main board spec.rb', %q{ + In order to manage active orders + As a supplier + I want to have control +} do + background do + create_supplier 'supplier@qwaiter.com' + create_user 'user@qwaiter.com' + end + + scenario 'loaded orders should have a list_id present for handling actions' do + login_supplier_as 'supplier@qwaiter.com' + end + +end diff --git a/spec/acceptance/support/helpers.rb b/spec/acceptance/support/helpers.rb new file mode 100644 index 00000000..bf7e2989 --- /dev/null +++ b/spec/acceptance/support/helpers.rb @@ -0,0 +1,30 @@ +module HelperMethods + # Put helper methods you need to be available in all acceptance specs here. + + def create_user(email, password='secret') + @user = User.find_by_email(email) || FactoryGirl.create(:user, email: email, password: password) + end + def create_supplier(email, password='secret') + @supplier = Supplier.find_by_email(email) || FactoryGirl.create(:supplier, email: email, password: password) + end + + def login_user_as(email) + visit "/users/sign_in" + fill_in "user_email", with: email + fill_in "user_password", with: "secret" + submit_form + end + + def login_supplier_as(email) + visit "/suppliers/sign_in" + fill_in "supplier_email", with: email + fill_in "supplier_password", with: "secret" + submit_form + end + + def submit_form + find("[type=submit]").click + end +end + +RSpec.configuration.include HelperMethods, :type => :acceptance diff --git a/spec/acceptance/support/paths.rb b/spec/acceptance/support/paths.rb new file mode 100644 index 00000000..e3b83074 --- /dev/null +++ b/spec/acceptance/support/paths.rb @@ -0,0 +1,9 @@ +module NavigationHelpers + # Put helper methods related to the paths in your application here. + + def homepage + "/" + end +end + +RSpec.configuration.include NavigationHelpers, :type => :acceptance \ No newline at end of file