From 8e8e699788ddeba39a13b85d70fcc1df25b8174a Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 7 Jan 2014 16:01:36 +0000 Subject: [PATCH 1/3] * fixing nil.publish test in mq_router.spec --- ruby/spec/jam_ruby/mq_router_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ruby/spec/jam_ruby/mq_router_spec.rb b/ruby/spec/jam_ruby/mq_router_spec.rb index 2e1b36750..4de2f124c 100644 --- a/ruby/spec/jam_ruby/mq_router_spec.rb +++ b/ruby/spec/jam_ruby/mq_router_spec.rb @@ -31,12 +31,25 @@ describe MQRouter do music_session_member1 = FactoryGirl.create(:connection, :user => user1, :music_session => music_session, :ip_address => "1.1.1.1", :client_id => "1") music_session_member2 = FactoryGirl.create(:connection, :user => user2, :music_session => music_session, :ip_address => "2.2.2.2", :client_id => "2") + + # this is necessary because other tests will call EM.schedule indirectly as they fiddle with AR models, since some of our + # notifications are tied to model activity. So, the issue here is that you'll have an unknown known amount of + # queued up messages ready to be sent to MQRouter (because EM.schedule will put deferred blocks onto @next_tick_queue), + # resulting in messages from other tests being sent to client_exchange or user_exchange + + # there is no API I can see to clear out the EM queue. so just open up the EM module and do it manually + module EM + @next_tick_queue = [] + end + EM.run do # mock up exchange MQRouter.client_exchange = double("client_exchange") + MQRouter.user_exchange = double("user_exchange") MQRouter.client_exchange.should_receive(:publish).with("a message", :routing_key => "client.#{music_session_member2.client_id}") + MQRouter.user_exchange.should_not_receive(:publish) @mq_router.user_publish_to_session(music_session, user1, "a message", :client_id => music_session_member1.client_id) From 9045e82530badb667a1d648178f52d6ac17be3b5 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 7 Jan 2014 16:20:52 +0000 Subject: [PATCH 2/3] * make runweb and update use login shell for better support with rvm --- runweb | 2 +- update | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runweb b/runweb index 8bb4a626d..885bc8de1 100755 --- a/runweb +++ b/runweb @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l pushd web # run jam-web rails server diff --git a/update b/update index 50b3c776b..4f27fa127 100755 --- a/update +++ b/update @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l set -e From 8b3d1abd5c44dc511a9d2d1ad180e359da457e09 Mon Sep 17 00:00:00 2001 From: Anthony Davis Date: Tue, 7 Jan 2014 13:40:26 -0600 Subject: [PATCH 3/3] VRFS-923 - pushing a pretend delete. will review Jenkins --- ruby/spec/spec_helper.rb | 4 ++++ ruby/spec/support/utilities.rb | 15 ++++++++++++++- web/spec/spec_helper.rb | 12 +++++++----- web/spec/support/utilities.rb | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/ruby/spec/spec_helper.rb b/ruby/spec/spec_helper.rb index 9a43ca42f..77cdf2ddd 100644 --- a/ruby/spec/spec_helper.rb +++ b/ruby/spec/spec_helper.rb @@ -78,6 +78,10 @@ Spork.prefork do DatabaseCleaner.clean end + config.after(:suite) do + wipe_s3_test_bucket + end + # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. diff --git a/ruby/spec/support/utilities.rb b/ruby/spec/support/utilities.rb index 822d07c51..9a22c1b8d 100644 --- a/ruby/spec/support/utilities.rb +++ b/ruby/spec/support/utilities.rb @@ -1,8 +1,9 @@ +JAMKAZAM_TESTING_BUCKET = 'jamkazam-testing' # cuz i'm not comfortable using aws_bucket accessor directly def app_config klass = Class.new do def aws_bucket - 'jamkazam-testing' + JAMKAZAM_TESTING_BUCKET end def aws_access_key_id @@ -15,4 +16,16 @@ def app_config end return klass.new +end + +def wipe_s3_test_bucket + test_config = app_config + s3 = AWS::S3.new(:access_key_id => test_config.aws_access_key_id, + :secret_access_key => test_config.aws_secret_access_key) + test_bucket = s3.buckets[JAMKAZAM_TESTING_BUCKET] + + if test_bucket.name == JAMKAZAM_TESTING_BUCKET + puts "Ruby - Pretending to delete all contents of #{test_bucket.name}" + #test_bucket.delete_all + end end \ No newline at end of file diff --git a/web/spec/spec_helper.rb b/web/spec/spec_helper.rb index 968e32400..aa70cebc0 100644 --- a/web/spec/spec_helper.rb +++ b/web/spec/spec_helper.rb @@ -99,10 +99,11 @@ Spork.prefork do config.include Snapshot config.before(:suite) do + set_up_snapshot end config.before(:all) do - set_up_snapshot + end config.before(:each) do @@ -120,10 +121,6 @@ Spork.prefork do config.before(:each, :js => true) do end - config.before(:each) do - - end - config.append_after(:each) do Capybara.reset_sessions! @@ -144,7 +141,12 @@ Spork.prefork do end config.after(:all) do + + end + + config.after(:suite) do tear_down_snapshot + wipe_s3_test_bucket end end end diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index c8a076009..f755a6e48 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -29,6 +29,39 @@ def cookie_jar Capybara.current_session.driver.browser.current_session.instance_variable_get(:@rack_mock_session).cookie_jar end +#these S3 functions copied from ruby/spec/support/utilities.rb +JAMKAZAM_TESTING_BUCKET = 'jamkazam-testing' # cuz i'm not comfortable using aws_bucket accessor directly + +def app_config + klass = Class.new do + def aws_bucket + JAMKAZAM_TESTING_BUCKET + end + + def aws_access_key_id + 'AKIAJESQY24TOT542UHQ' + end + + def aws_secret_access_key + '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' + end + end + + return klass.new +end + +def wipe_s3_test_bucket + test_config = app_config + s3 = AWS::S3.new(:access_key_id => test_config.aws_access_key_id, + :secret_access_key => test_config.aws_secret_access_key) + test_bucket = s3.buckets[JAMKAZAM_TESTING_BUCKET] + + if test_bucket.name == JAMKAZAM_TESTING_BUCKET + puts "Web - Pretending to delete all contents of #{test_bucket.name}" + #test_bucket.delete_all + end +end +# --end of S3 methods copied from ruby/spec/support/utilities.rb def sign_in(user)