Permalink
Browse files

send email move notification even when receipient is online because i…

…t caused some confusion as to why it sometimes wouldn't send
  • Loading branch information...
1 parent 14b6c73 commit e5d3797500653fe8892014bfd38122a603bfe807 @ryanb committed Jun 20, 2011
Showing with 39 additions and 3 deletions.
  1. +5 −0 Gemfile
  2. +13 −0 Gemfile.lock
  3. +17 −0 Guardfile
  4. +1 −1 app/controllers/moves_controller.rb
  5. +3 −2 spec/controllers/moves_controller_spec.rb
View
5 Gemfile
@@ -25,3 +25,8 @@ group :development do
gem 'mongrel', '1.2.0.pre2'
gem 'nifty-generators'
end
+
+group :test do
+ gem 'guard'
+ gem 'guard-rspec'
+end
View
13 Gemfile.lock
@@ -57,6 +57,7 @@ GEM
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.0.0)
chunky_png (0.10.5)
+ configuration (1.2.0)
daemons (1.0.10)
diff-lcs (1.1.2)
erubis (2.6.6)
@@ -69,11 +70,19 @@ GEM
addressable (>= 2.1.1)
rack (>= 1.0.1)
gem_plugin (0.2.3)
+ guard (0.3.0)
+ open_gem (~> 1.4.2)
+ thor (~> 0.14.6)
+ guard-rspec (0.2.0)
+ guard (>= 0.2.2)
highline (1.6.1)
i18n (0.5.0)
jquery-rails (0.2.4)
rails (~> 3.0)
json_pure (1.4.6)
+ launchy (0.3.7)
+ configuration (>= 0.0.5)
+ rake (>= 0.8.1)
mail (2.2.12)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@@ -132,6 +141,8 @@ GEM
oa-enterprise (= 0.1.5)
oa-oauth (= 0.1.5)
oa-openid (= 0.1.5)
+ open_gem (1.4.2)
+ launchy (~> 0.3.5)
polyglot (0.3.1)
pyu-ruby-sasl (0.0.3.2)
rack (1.2.1)
@@ -197,6 +208,8 @@ DEPENDENCIES
exception_notification!
factory_girl_rails
go_gtp (= 0.0.4)!
+ guard
+ guard-rspec
jquery-rails
mocha
mongrel (= 1.2.0.pre2)
View
17 Guardfile
@@ -0,0 +1,17 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb})
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch('spec/spec_helper.rb') { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ watch(%r{^spec/.+_spec\.rb})
+ watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+end
View
2 app/controllers/moves_controller.rb
@@ -8,7 +8,7 @@ def create
@game = Game.find(params[:game_id])
@game.move(params[:move], current_user)
@game.queue_computer_move
- Notifications.move(@game).deliver if @game.current_player && @game.current_player.email.present? && @game.current_player.email_on_move? && !@game.current_player.online?
+ Notifications.move(@game).deliver if @game.current_player && @game.current_player.email.present? && @game.current_player.email_on_move?
rescue GameEngine::IllegalMove
flash[:alert] = "That is an illegal move."
rescue GameEngine::OutOfTurn
View
5 spec/controllers/moves_controller_spec.rb
@@ -29,13 +29,14 @@
Notifications.deliveries.size.should == 0
end
- it "should not send move email when user is online" do
+ # It used to not behave this way but it caused some confusion as to why it sometimes wouldn't send notifications
+ it "should send move email even when user is online" do
game = Factory(:game)
game.opponent.update_attribute(:email_on_move, true)
game.opponent.update_attribute(:last_request_at, Time.now)
@controller.stubs(:current_user).returns(game.current_player)
post "create", :game_id => game.id, :format => "js", :move => "aa"
response.should be_success
- Notifications.deliveries.size.should == 0
+ Notifications.deliveries.size.should == 1
end
end

0 comments on commit e5d3797

Please sign in to comment.