Skip to content

Commit

Permalink
Added game setup validation to controller
Browse files Browse the repository at this point in the history
  • Loading branch information
lisahamm committed Feb 26, 2015
1 parent e02a99b commit bd513c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 36 deletions.
15 changes: 7 additions & 8 deletions tic_tac_toe_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ class TicTacToeController < Sinatra::Base
end

post '/setup' do

if !setup_valid?(params)
@invalid_input_messages = error_messages
@setup = GameSetup.new(params)
if @setup.invalid?
erb :index
else
session[:mark] = params[:player_mark]
session[:opponent] = params[:opponent]
session[:player_order] = params[:player_order]
redirect to('/game')
end

session[:mark] = params[:player_mark]
session[:opponent] = params[:opponent]
session[:player_order] = params[:player_order]
redirect to('/game')
end

get '/game' do
Expand Down
28 changes: 0 additions & 28 deletions tic_tac_toe_controller_spec.rb

This file was deleted.

0 comments on commit bd513c7

Please sign in to comment.