本番デプロイ設定: SSL, Kamal, API環境変数化, テスト修正
This commit is contained in:
@@ -2,7 +2,11 @@ require "test_helper"
|
||||
|
||||
class GamesControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@user = users(:one)
|
||||
login_as(@user)
|
||||
@game = games(:one)
|
||||
# edit/update/destroy には管理者権限が必要
|
||||
@game.participants.create!(user: @user, is_administrator: true) unless @game.participants.exists?(user: @user)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
@@ -17,13 +21,22 @@ class GamesControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
test "should create game" do
|
||||
assert_difference("Game.count") do
|
||||
post games_url, params: { game: { memo: @game.memo, participants_count: @game.participants_count, title: @game.title } }
|
||||
post games_url, params: { game: {
|
||||
title: "New Test Game",
|
||||
memo: @game.memo,
|
||||
participants_count: @game.participants_count,
|
||||
victory_sc_count: 18,
|
||||
scoring_system: "none"
|
||||
} }
|
||||
end
|
||||
|
||||
assert_redirected_to game_url(Game.last)
|
||||
end
|
||||
|
||||
test "should show game" do
|
||||
# showアクションではgame_stateが必要なため、ターンにgame_stateを設定
|
||||
turn = @game.turns.first
|
||||
turn.update(game_state: { "centers" => {}, "units" => {} }) if turn
|
||||
get game_url(@game)
|
||||
assert_response :success
|
||||
end
|
||||
@@ -34,7 +47,13 @@ class GamesControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
test "should update game" do
|
||||
patch game_url(@game), params: { game: { memo: @game.memo, participants_count: @game.participants_count, title: @game.title } }
|
||||
patch game_url(@game), params: { game: {
|
||||
title: @game.title,
|
||||
memo: @game.memo,
|
||||
auto_order_mode: @game.auto_order_mode,
|
||||
victory_sc_count: 18,
|
||||
scoring_system: "none"
|
||||
} }
|
||||
assert_redirected_to game_url(@game)
|
||||
end
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ require "test_helper"
|
||||
|
||||
class TurnsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@user = users(:one)
|
||||
login_as(@user)
|
||||
@turn = turns(:one)
|
||||
end
|
||||
|
||||
@@ -17,7 +19,7 @@ class TurnsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
test "should create turn" do
|
||||
assert_difference("Turn.count") do
|
||||
post turns_url, params: { turn: { game_id: @turn.game_id, game_stat: @turn.game_stat, number: @turn.number, phase: @turn.phase, svg_date: @turn.svg_date } }
|
||||
post turns_url, params: { turn: { game_id: @turn.game_id, game_state: @turn.game_state, number: @turn.number + 10, phase: @turn.phase, svg_date: @turn.svg_date } }
|
||||
end
|
||||
|
||||
assert_redirected_to turn_url(Turn.last)
|
||||
@@ -34,7 +36,7 @@ class TurnsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
test "should update turn" do
|
||||
patch turn_url(@turn), params: { turn: { game_id: @turn.game_id, game_stat: @turn.game_stat, number: @turn.number, phase: @turn.phase, svg_date: @turn.svg_date } }
|
||||
patch turn_url(@turn), params: { turn: { game_id: @turn.game_id, game_state: @turn.game_state, number: @turn.number, phase: @turn.phase, svg_date: @turn.svg_date } }
|
||||
assert_redirected_to turn_url(@turn)
|
||||
end
|
||||
|
||||
|
||||
4
test/fixtures/games.yml
vendored
4
test/fixtures/games.yml
vendored
@@ -5,9 +5,13 @@ one:
|
||||
status: in_progress
|
||||
turn_schedule: "0,12"
|
||||
participants_count: 7
|
||||
victory_sc_count: 18
|
||||
scoring_system: none
|
||||
|
||||
two:
|
||||
title: GameTwo
|
||||
status: recruiting
|
||||
turn_schedule: "0,12"
|
||||
participants_count: 1
|
||||
victory_sc_count: 18
|
||||
scoring_system: none
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
ENV["RAILS_ENV"] ||= "test"
|
||||
require_relative "../test/test_helper"
|
||||
require_relative "../test_helper"
|
||||
|
||||
class RefactoringVerificationTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@game = Game.create!(title: "Refactor Test #{Time.now.to_r}", status: "recruiting", participants_count: 7, is_solo_mode: true)
|
||||
@game = Game.create!(
|
||||
title: "Refactor Test #{Time.now.to_r}",
|
||||
status: "recruiting",
|
||||
participants_count: 7,
|
||||
is_solo_mode: true,
|
||||
victory_sc_count: 18,
|
||||
scoring_system: "none"
|
||||
)
|
||||
end
|
||||
|
||||
# Mock Client Class
|
||||
class MockClient
|
||||
def initialize(initial_state: {}, possible_orders: {}, render_result: "<svg>...</svg>", process_result: nil, auto_orders: nil)
|
||||
def initialize(initial_state: {}, possible_orders: {}, render_result: "<svg>...</svg>", process_result: nil, auto_orders: nil, validate_result: {})
|
||||
@initial_state = initial_state
|
||||
@possible_orders = possible_orders
|
||||
@render_result = render_result
|
||||
@process_result = process_result
|
||||
@auto_orders = auto_orders
|
||||
@validate_result = validate_result
|
||||
end
|
||||
|
||||
def api_game_initial_state(map_name = "standard")
|
||||
@@ -32,6 +40,10 @@ class RefactoringVerificationTest < ActiveSupport::TestCase
|
||||
@process_result
|
||||
end
|
||||
|
||||
def api_calculate_validate(game_state, orders)
|
||||
@validate_result
|
||||
end
|
||||
|
||||
def api_calculate_auto_orders(game_state, power_name)
|
||||
@auto_orders
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user