c8330a7be8
Instead: - Always let you create drafts when pressing "Add card" - Prevent creations of published cards via API - Prevent publication of cards in all cases when the limit is exceeded
44 lines
1.4 KiB
Ruby
44 lines
1.4 KiB
Ruby
require "test_helper"
|
|
|
|
class Card::LimitedCreationTest < ActionDispatch::IntegrationTest
|
|
test "cannot create cards via JSON when card limit exceeded" do
|
|
sign_in_as :mike
|
|
|
|
accounts(:initech).update_column(:cards_count, 1001)
|
|
|
|
assert_no_difference -> { Card.count } do
|
|
post board_cards_path(boards(:miltons_wish_list), script_name: accounts(:initech).slug, format: :json)
|
|
end
|
|
|
|
assert_response :forbidden
|
|
end
|
|
|
|
test "can create cards via HTML when card limit exceeded but they are drafts" do
|
|
sign_in_as :mike
|
|
|
|
accounts(:initech).update_column(:cards_count, 1001)
|
|
boards(:miltons_wish_list).cards.drafted.where(creator: users(:mike)).destroy_all
|
|
|
|
assert_difference -> { Card.count } do
|
|
post board_cards_path(boards(:miltons_wish_list), script_name: accounts(:initech).slug)
|
|
end
|
|
|
|
assert_response :redirect
|
|
assert Card.last.drafted?
|
|
end
|
|
|
|
test "cannot force published status via HTML when card limit exceeded" do
|
|
sign_in_as :mike
|
|
|
|
accounts(:initech).update_column(:cards_count, 1001)
|
|
boards(:miltons_wish_list).cards.drafted.where(creator: users(:mike)).destroy_all
|
|
|
|
assert_difference -> { Card.count } do
|
|
post board_cards_path(boards(:miltons_wish_list), script_name: accounts(:initech).slug), params: { card: { status: "published" } }
|
|
end
|
|
|
|
assert_response :redirect
|
|
assert Card.last.drafted?
|
|
end
|
|
end
|