Files
fizzy/test/models/bubble/engageable_test.rb
T
Jorge Manrubia 2af619176e Format
2025-04-03 18:16:21 +02:00

50 lines
1.2 KiB
Ruby

require "test_helper"
class Bubble::EngageableTest < ActiveSupport::TestCase
setup do
Current.session = sessions(:david)
end
test "check the engagement status of a bubble" do
assert bubbles(:logo).doing?
assert_not bubbles(:text).doing?
assert_not bubbles(:logo).considering?
assert bubbles(:text).considering?
end
test "change the engagement" do
assert_changes -> { bubbles(:text).reload.doing? }, to: true do
bubbles(:text).engage
end
assert_changes -> { bubbles(:logo).reload.doing? }, to: false do
bubbles(:logo).reconsider
end
end
test "engaging with popped bubbles" do
bubbles(:text).pop!
assert_not bubbles(:text).considering?
assert_not bubbles(:text).doing?
bubbles(:text).engage
assert_not bubbles(:text).reload.popped?
assert bubbles(:text).doing?
bubbles(:text).pop!
bubbles(:text).reconsider
assert_not bubbles(:text).reload.popped?
assert bubbles(:text).considering?
end
test "scopes" do
assert_includes Bubble.doing, bubbles(:logo)
assert_not_includes Bubble.doing, bubbles(:text)
assert_includes Bubble.considering, bubbles(:text)
assert_not_includes Bubble.considering, bubbles(:logo)
end
end