Add tests

This commit is contained in:
Jorge Manrubia
2025-04-11 09:36:24 +02:00
parent da7a30203c
commit 1bac0b84b3
4 changed files with 60 additions and 1 deletions
@@ -0,0 +1,27 @@
require "test_helper"
class Cards::GoldenessesControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "create" do
card = cards(:text)
assert_changes -> { card.reload.golden? }, from: false, to: true do
post card_goldeness_url(card)
end
assert_redirected_to collection_card_url(card.collection, card)
end
test "destroy" do
card = cards(:logo)
assert_changes -> { card.reload.golden? }, from: true, to: false do
delete card_goldeness_url(card)
end
assert_redirected_to collection_card_url(card.collection, card)
end
end
+1 -1
View File
@@ -1,2 +1,2 @@
logo_engagement:
logo:
card: logo
+2
View File
@@ -0,0 +1,2 @@
logo:
card: logo
+30
View File
@@ -0,0 +1,30 @@
require "test_helper"
class Card::GoldenTest < ActiveSupport::TestCase
setup do
Current.session = sessions(:david)
end
test "check whether a card is golden" do
assert cards(:logo).golden?
assert_not cards(:text).golden?
end
test "promote and demote from golden" do
assert_changes -> { cards(:text).reload.golden? }, to: true do
cards(:text).promote_to_golden
end
assert_changes -> { cards(:logo).reload.golden? }, to: false do
cards(:logo).demote_from_golden
end
end
test "scopes" do
assert_includes Card.doing, cards(:logo)
assert_not_includes Card.doing, cards(:text)
assert_includes Card.considering, cards(:text)
assert_not_includes Card.considering, cards(:logo)
end
end