make integration test work

This commit is contained in:
wvengen 2013-07-24 12:37:20 +02:00
parent 8af04e0112
commit 62682b7e64
5 changed files with 21 additions and 34 deletions

View File

@ -71,6 +71,6 @@ group :development, :test do
gem 'factory_girl_rails', '~> 4.0' gem 'factory_girl_rails', '~> 4.0'
gem 'faker' gem 'faker'
gem 'capybara' gem 'capybara'
gem 'poltergeist' # webkit and poltergeist don't seem to work yet
gem 'database_cleaner' gem 'database_cleaner'
end end

View File

@ -106,8 +106,6 @@ GEM
railties (>= 3.0.0) railties (>= 3.0.0)
faker (1.1.2) faker (1.1.2)
i18n (~> 0.5) i18n (~> 0.5)
faye-websocket (0.4.7)
eventmachine (>= 0.12.0)
ffi (1.4.0) ffi (1.4.0)
haml (3.1.7) haml (3.1.7)
haml-rails (0.3.5) haml-rails (0.3.5)
@ -119,7 +117,6 @@ GEM
hashery (2.0.1) hashery (2.0.1)
highline (1.6.19) highline (1.6.19)
hike (1.2.1) hike (1.2.1)
http_parser.rb (0.5.3)
i18n (0.6.1) i18n (0.6.1)
inherited_resources (1.3.1) inherited_resources (1.3.1)
has_scope (~> 0.5.0) has_scope (~> 0.5.0)
@ -172,10 +169,6 @@ GEM
Ascii85 (~> 1.0.0) Ascii85 (~> 1.0.0)
hashery (~> 2.0) hashery (~> 2.0)
ruby-rc4 ruby-rc4
poltergeist (1.1.2)
capybara (~> 2.0.1)
faye-websocket (~> 0.4.4)
http_parser.rb (~> 0.5.3)
polyamorous (0.5.0) polyamorous (0.5.0)
activerecord (~> 3.0) activerecord (~> 3.0)
polyglot (0.3.3) polyglot (0.3.3)
@ -328,7 +321,6 @@ DEPENDENCIES
mailcatcher mailcatcher
meta_search meta_search
mysql2 mysql2
poltergeist
prawn prawn
quiet_assets quiet_assets
rails (~> 3.2.9) rails (~> 3.2.9)

View File

@ -27,6 +27,9 @@ FactoryGirl.define do
factory :ordergroup do factory :ordergroup do
type 'Ordergroup' type 'Ordergroup'
sequence(:name) {|n| "Order group ##{n}"} sequence(:name) {|n| "Order group ##{n}"}
# workaround to avoid needing to save the ordergroup
# avoids e.g. error after logging in related to applebar
after :create do |group| Ordergroup.find(group.id).update_stats! end
end end
end end

View File

@ -14,35 +14,35 @@ describe 'product distribution', :type => :feature do
# gruppe a bestellt 2(3), weil sie auf jeden fall was von x bekommen will # gruppe a bestellt 2(3), weil sie auf jeden fall was von x bekommen will
login user_a login user_a
visit new_group_order_path(:order_id => order.id) visit new_group_order_path(:order_id => order.id)
find("[data-increase_quantity='#{oa.id}']").click 2.times { find("[data-increase_quantity='#{oa.id}']").click }
find("[data-increase_quantity='#{oa.id}']").click 3.times { find("[data-increase_tolerance='#{oa.id}']").click }
find("[data-increase_tolerance='#{oa.id}']").click
find("[data-increase_tolerance='#{oa.id}']").click
find("[data-increase_tolerance='#{oa.id}']").click
find('input[type=submit]').click find('input[type=submit]').click
expect(page).to have_selector('body')
# gruppe b bestellt 2(0) # gruppe b bestellt 2(0)
login user_b login user_b
visit new_group_order_path(:order_id => order.id) visit new_group_order_path(:order_id => order.id)
find("[data-increase_quantity='#{oa.id}']").click 2.times { find("[data-increase_quantity='#{oa.id}']").click }
find("[data-increase_quantity='#{oa.id}']").click
find('input[type=submit]').click find('input[type=submit]').click
expect(page).to have_selector('body')
# gruppe a faellt ein dass sie doch noch mehr braucht von x und aendert auf 4(1). # gruppe a faellt ein dass sie doch noch mehr braucht von x und aendert auf 4(1).
login user_a login user_a
visit edit_group_order_path(order.group_order(user_a.ordergroup), :order_id => order.id) visit edit_group_order_path(order.group_order(user_a.ordergroup), :order_id => order.id)
find("[data-increase_quantity='#{oa.id}']").click 2.times { find("[data-increase_quantity='#{oa.id}']").click }
find("[data-increase_quantity='#{oa.id}']").click 2.times { find("[data-decrease_tolerance='#{oa.id}']").click }
find("[data-decrease_tolerance='#{oa.id}']").click find('input[type=submit]').click
find("[data-decrease_tolerance='#{oa.id}']").click expect(page).to have_selector('body')
# die zuteilung # die zuteilung
order.close!(admin) order.finish!(admin)
oa.reload
# Endstand: insg. Bestellt wurden 6(1) # Endstand: insg. Bestellt wurden 6(1)
expect(oa.result).to == 6 expect(oa.quantity).to eq(6)
expect(oa.tolerance).to eq(1)
# Gruppe a bekommt 3 einheiten. # Gruppe a bekommt 3 einheiten.
goa_a = oa.group_order_articles.where(:ordergroup_id => user_a.ordergroup.id).first goa_a = oa.group_order_articles.joins(:group_order).where(:group_orders => {:ordergroup_id => user_a.ordergroup.id}).first
expect(goa_a.result).to == 3 expect(goa_a.result).to eq(3)
# gruppe b bekommt 2 einheiten. # gruppe b bekommt 2 einheiten.
goa_b = oa.group_order_articles.where(:ordergroup_id => user_b.ordergroup.id).first goa_b = oa.group_order_articles.joins(:group_order).where(:group_orders => {:ordergroup_id => user_b.ordergroup.id}).first
expect(goa_b.result).to == 2 expect(goa_b.result).to eq(2)
end end
end end

View File

@ -6,8 +6,6 @@ require 'rspec/autorun'
require 'capybara/rails' require 'capybara/rails'
require 'capybara/rspec' require 'capybara/rspec'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
# Requires supporting ruby files with custom matchers and macros, etc, # Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories. # in spec/support/ and its subdirectories.
@ -66,9 +64,3 @@ ActionDispatch::Integration::Runner.class_eval do
{foodcoop: FoodsoftConfig.scope}.merge(options) {foodcoop: FoodsoftConfig.scope}.merge(options)
end end
end end
# debug driver for tests requiring javascript
#Capybara.javascript_driver = :poltergeist_debug
#Capybara.register_driver :poltergeist_debug do |app|
# Capybara::Poltergeist::Driver.new(app, :debug => true, :inspector => true)
#end