Skip to content

Commit

Permalink
fixup! fixup! Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavSokov committed Jul 1, 2024
1 parent 0ceffa9 commit a970630
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/controllers/actual_db_schema/migrations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,32 @@ def active_record_setup
test "GET #index returns a successful response" do
get :index
assert_response :success
assert_equal(2, @controller.instance_variable_get(:@migrations).count)
assert_equal(2, @controller.instance_variable_get(:@migrations).count { |migration| migration[:status] == "up" })
assert_equal(0, @controller.instance_variable_get(:@migrations).count do |migration|
migration[:status] == "down"
end)
end

test "GET #show returns a successful response" do
get :show, params: { id: "20130906111511", database: "tmp/primary.sqlite3" }
assert_response :success
assert_equal "20130906111511", @controller.instance_variable_get(:@migration)[:version]
assert_equal "up", @controller.instance_variable_get(:@migration)[:status]
assert_equal "First", @controller.instance_variable_get(:@migration)[:name]
assert_select "h2", text: "Migration First Details"
end

test "POST #rollback returns a successful response" do
test "POST #rollback changes migration status to down" do
post :rollback, params: { id: "20130906111511", database: "tmp/primary.sqlite3" }
assert_response :redirect
get :index
assert_equal(1, @controller.instance_variable_get(:@migrations).count { |migration| migration[:status] == "up" })
assert_equal(1, @controller.instance_variable_get(:@migrations).count do |migration|
migration[:status] == "down"
end)
get :show, params: { id: "20130906111511", database: "tmp/primary.sqlite3" }
assert_equal "down", @controller.instance_variable_get(:@migration)[:status]
end
end
end

0 comments on commit a970630

Please sign in to comment.