Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…o game
  • Loading branch information...
commit df8a56d3a9819f2910aad2957f2bf8e356201683 1 parent e5d3797
@ryanb authored
View
2  app/controllers/games_controller.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
4 app/models/game.rb
@@ -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
View
7 spec/controllers/games_controller_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.