Permalink
Browse files

fixing bug where it would try to send an invitation email for a govsg…

…o game
  • Loading branch information...
1 parent e5d3797 commit df8a56d3a9819f2910aad2957f2bf8e356201683 @ryanb committed Jul 1, 2011
Showing with 12 additions and 1 deletion.
  1. +1 −1 app/controllers/games_controller.rb
  2. +4 −0 app/models/game.rb
  3. +7 −0 spec/controllers/games_controller_spec.rb
@@ -41,7 +41,7 @@ def create
@game.prepare
if @game.save
@game.queue_computer_move
- Notifications.invitation(@game).deliver if @game.current_player && @game.current_player.email.present? && @game.current_player.email_on_invitation?
+ Notifications.invitation(@game).deliver if @game.send_invitation_email?
flash[:notice] = "Game started. Click on a point below to place your stone."
redirect_to @game
else
View
@@ -278,4 +278,8 @@ def opponent(player = current_player)
def player?(user)
black_player == user || white_player == user
end
+
+ def send_invitation_email?
+ black_player && white_player && current_player && current_player.email.present? && current_player.email_on_invitation?
+ end
end
@@ -74,6 +74,13 @@
Notifications.deliveries.size.should == 0
end
+ it "create action should not send email to opponent user when playing against gnugo" do
+ @user.update_attribute(:email_on_invitation, true)
+ post :create, :game => { :chosen_opponent => "gnugo", :chosen_color => "black" }
+ response.should redirect_to(game_url(assigns[:game]))
+ Notifications.deliveries.size.should == 0
+ end
+
it "edit action should render edit javascript template and fill in user attributes" do
game = Factory(:game, :white_player => @user, :current_player => @user)
get :edit, :id => game, :format => :js

0 comments on commit df8a56d

Please sign in to comment.