Fix more tests
These are mainly because the fixture's UUIDs are deterministic rather than time-sortable, and more places where we need to correct the fixture IDs as well.
This commit is contained in:
committed by
Mike Dalessio
parent
c97ea9131f
commit
1959e15f7e
@@ -2,6 +2,6 @@ module Account::Seedeable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def setup_customer_template
|
||||
Account::Seeder.new(self, User.active.first).seed
|
||||
Account::Seeder.new(self, users.active.first).seed
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ class Account::Seeder
|
||||
|
||||
private
|
||||
def session
|
||||
creator.identity.sessions.last
|
||||
creator.identity.sessions.order(created_at: :desc).first
|
||||
end
|
||||
|
||||
def populate
|
||||
|
||||
@@ -55,6 +55,6 @@ class Card::ActivitySpike::Detector
|
||||
end
|
||||
|
||||
def last_event
|
||||
card.events.last
|
||||
card.events.order(created_at: :desc).first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ class Boards::ColumnsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
assert_equal "New Column", boards(:writebook).columns.last.name
|
||||
assert_equal "New Column", boards(:writebook).columns.order(created_at: :desc).first.name
|
||||
end
|
||||
|
||||
test "update" do
|
||||
|
||||
@@ -20,7 +20,7 @@ class BoardsControllerTest < ActionDispatch::IntegrationTest
|
||||
post boards_path, params: { board: { name: "Remodel Punch List" } }
|
||||
end
|
||||
|
||||
board = Board.last
|
||||
board = Board.order(created_at: :desc).first
|
||||
assert_redirected_to board_path(board)
|
||||
assert_includes board.users, users(:kevin)
|
||||
assert_equal "Remodel Punch List", board.name
|
||||
|
||||
@@ -26,7 +26,8 @@ class Cards::PublishesControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
assert Card.last.drafted?
|
||||
assert_redirected_to Card.last
|
||||
new_card = Card.order(created_at: :desc).first
|
||||
assert new_card.drafted?
|
||||
assert_redirected_to new_card
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,8 +20,9 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
|
||||
post board_cards_path(boards(:writebook))
|
||||
end
|
||||
|
||||
assert Card.last.drafted?
|
||||
assert_redirected_to Card.last
|
||||
card = Card.order(created_at: :desc).first
|
||||
assert card.drafted?
|
||||
assert_redirected_to card
|
||||
end
|
||||
|
||||
test "create resumes existing draft if it exists" do
|
||||
|
||||
@@ -16,7 +16,7 @@ class FiltersControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
assert_response :success
|
||||
|
||||
filter = Filter.last
|
||||
filter = Filter.order(created_at: :desc).first
|
||||
assert_predicate filter.indexed_by, :closed?
|
||||
assert_predicate filter.assignment_status, :unassigned?
|
||||
assert_equal [ tags(:mobile) ], filter.tags
|
||||
|
||||
@@ -35,7 +35,7 @@ class WebhooksControllerTest < ActionDispatch::IntegrationTest
|
||||
}
|
||||
end
|
||||
|
||||
webhook = Webhook.order(id: :desc).first
|
||||
webhook = Webhook.order(created_at: :desc).first
|
||||
|
||||
assert_redirected_to board_webhook_path(webhook.board, webhook)
|
||||
assert_equal board, webhook.board
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
logo_card_david_mention_by_jz:
|
||||
id: <%= ActiveRecord::FixtureSet.identify("logo_card_david_mention_by_jz", :uuid) %>
|
||||
source: logo_uuid_uuid (Card)
|
||||
source: logo_uuid (Card)
|
||||
mentioner: jz_uuid
|
||||
mentionee: david_uuid
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -6,4 +6,4 @@ logo_kevin:
|
||||
shipping_kevin:
|
||||
id: <%= ActiveRecord::FixtureSet.identify("shipping_kevin_pin", :uuid) %>
|
||||
card: shipping_uuid
|
||||
user: kevin
|
||||
user: kevin_uuid
|
||||
Vendored
+4
-4
@@ -1,11 +1,11 @@
|
||||
kevin:
|
||||
id: <%= ActiveRecord::FixtureSet.identify("kevin_reaction", :uuid) %>
|
||||
content: "👍"
|
||||
comment: logo_agreement_jz
|
||||
reacter: kevin
|
||||
comment: logo_agreement_jz_uuid
|
||||
reacter: kevin_uuid
|
||||
|
||||
david:
|
||||
id: <%= ActiveRecord::FixtureSet.identify("david_reaction", :uuid) %>
|
||||
content: "👍"
|
||||
comment: logo_agreement_jz
|
||||
reacter: david
|
||||
comment: logo_agreement_jz_uuid
|
||||
reacter: david_uuid
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
active:
|
||||
id: <%= ActiveRecord::FixtureSet.identify("active_webhook", :uuid) %>
|
||||
id: <%= ActiveRecord::FixtureSet.identify("active", :uuid) %>
|
||||
active: true
|
||||
name: Production API
|
||||
url: https://api.example.com/webhooks
|
||||
@@ -9,7 +9,7 @@ active:
|
||||
account: 37s_uuid
|
||||
|
||||
inactive:
|
||||
id: <%= ActiveRecord::FixtureSet.identify("inactive_webhook", :uuid) %>
|
||||
id: <%= ActiveRecord::FixtureSet.identify("inactive", :uuid) %>
|
||||
active: false
|
||||
name: Test Webhook
|
||||
url: https://test.example.com/webhooks
|
||||
|
||||
@@ -68,7 +68,7 @@ class AccessTest < ActiveSupport::TestCase
|
||||
test "watches are destroyed when access is lost" do
|
||||
kevin = users(:kevin)
|
||||
board = boards(:writebook)
|
||||
card = board.cards.first
|
||||
card = cards(:logo) # Kevin watches this card
|
||||
|
||||
assert card.watched_by?(kevin)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Card::CloseableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
assert cards(:logo).closed?
|
||||
assert cards(:logo).events.last.action.card_closed?
|
||||
assert cards(:logo).events.order(created_at: :desc).first.action.card_closed?
|
||||
assert_equal users(:kevin), cards(:logo).closed_by
|
||||
end
|
||||
|
||||
@@ -29,6 +29,6 @@ class Card::CloseableTest < ActiveSupport::TestCase
|
||||
cards(:shipping).reopen
|
||||
end
|
||||
assert cards(:shipping).reload.open?
|
||||
assert cards(:shipping).events.last.action.card_reopened?
|
||||
assert cards(:shipping).events.order(created_at: :desc).first.action.card_reopened?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,8 +45,9 @@ class Card::Eventable::SystemCommenterTest < ActiveSupport::TestCase
|
||||
def assert_system_comment(expected_comment)
|
||||
assert_difference -> { @card.comments.count }, 1 do
|
||||
yield
|
||||
assert @card.comments.last.creator.system?
|
||||
assert_match Regexp.new(expected_comment.strip, Regexp::IGNORECASE), @card.comments.last.body.to_plain_text.strip
|
||||
comment = @card.comments.order(created_at: :desc).first
|
||||
assert comment.creator.system?
|
||||
assert_match Regexp.new(expected_comment.strip, Regexp::IGNORECASE), comment.body.to_plain_text.strip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ class Card::PostponableTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
assert_equal users(:david), card.not_now.user
|
||||
assert card.events.last.action.card_postponed?
|
||||
assert card.events.order(created_at: :desc).first.action.card_postponed?
|
||||
|
||||
assert_changes -> { card.reload.postponed? }, to: false do
|
||||
card.resume
|
||||
@@ -42,7 +42,7 @@ class Card::PostponableTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
assert card.events.last.action.card_auto_postponed?
|
||||
assert card.events.order(created_at: :desc).first.action.card_auto_postponed?
|
||||
end
|
||||
|
||||
test "scopes" do
|
||||
|
||||
@@ -34,8 +34,9 @@ class Card::StatusesTest < ActiveSupport::TestCase
|
||||
@card = boards(:writebook).cards.create! creator: users(:kevin), title: "Published Card", status: :published
|
||||
end
|
||||
|
||||
assert_equal @card, Event.last.eventable
|
||||
assert_equal "card_published", Event.last.action
|
||||
event = Event.order(created_at: :desc).first
|
||||
assert_equal @card, event.eventable
|
||||
assert_equal "card_published", event.action
|
||||
end
|
||||
|
||||
test "an event is created when a card is published" do
|
||||
@@ -46,7 +47,8 @@ class Card::StatusesTest < ActiveSupport::TestCase
|
||||
card.publish
|
||||
end
|
||||
|
||||
assert_equal card, Event.last.eventable
|
||||
assert_equal "card_published", Event.last.action
|
||||
event = Event.order(created_at: :desc).first
|
||||
assert_equal card, event.eventable
|
||||
assert_equal "card_published", event.action
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class Card::TaggableTest < ActiveSupport::TestCase
|
||||
@card.toggle_tag_with "ruby"
|
||||
end
|
||||
|
||||
assert_equal "ruby", @card.tags.last.title
|
||||
assert_equal "ruby", @card.tags.order(created_at: :desc).first.title
|
||||
|
||||
assert_difference -> { @card.tags.count }, -1 do
|
||||
@card.toggle_tag_with "ruby"
|
||||
|
||||
+12
-10
@@ -23,7 +23,7 @@ class CardTest < ActiveSupport::TestCase
|
||||
cards(:logo).comments.create!(body: "Agreed.")
|
||||
end
|
||||
|
||||
assert_equal "Agreed.", cards(:logo).comments.last.body.to_plain_text.chomp
|
||||
assert_equal "Agreed.", cards(:logo).comments.order(created_at: :desc).first.body.to_plain_text.chomp
|
||||
end
|
||||
|
||||
test "assignment states" do
|
||||
@@ -38,15 +38,17 @@ class CardTest < ActiveSupport::TestCase
|
||||
cards(:logo).toggle_assignment users(:kevin)
|
||||
end
|
||||
assert_not cards(:logo).assigned_to?(users(:kevin))
|
||||
assert_equal "card_unassigned", Event.last.action
|
||||
assert_equal [ users(:kevin) ], Event.last.assignees
|
||||
unassign_event = Event.order(created_at: :desc).first
|
||||
assert_equal "card_unassigned", unassign_event.action
|
||||
assert_equal [ users(:kevin) ], unassign_event.assignees
|
||||
|
||||
assert_difference %w[ cards(:logo).assignees.count Event.count ], +1 do
|
||||
cards(:logo).toggle_assignment users(:kevin)
|
||||
end
|
||||
assert cards(:logo).assigned_to?(users(:kevin))
|
||||
assert_equal "card_assigned", Event.last.action
|
||||
assert_equal [ users(:kevin) ], Event.last.assignees
|
||||
assign_event = Event.order(created_at: :desc).first
|
||||
assert_equal "card_assigned", assign_event.action
|
||||
assert_equal [ users(:kevin) ], assign_event.assignees
|
||||
end
|
||||
|
||||
test "tagged states" do
|
||||
@@ -85,24 +87,24 @@ class CardTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "open" do
|
||||
assert_same_elements cards(:logo, :layout, :text, :buy_domain), Card.open
|
||||
assert_equal cards(:logo, :layout, :text, :buy_domain).to_set, Card.open.to_set
|
||||
end
|
||||
|
||||
test "card_unassigned" do
|
||||
assert_same_elements cards(:shipping, :text, :buy_domain), Card.unassigned
|
||||
assert_equal cards(:shipping, :text, :buy_domain).to_set, Card.unassigned.to_set
|
||||
end
|
||||
|
||||
test "assigned to" do
|
||||
assert_same_elements cards(:logo, :layout), Card.assigned_to(users(:jz))
|
||||
assert_equal cards(:logo, :layout).to_set, Card.assigned_to(users(:jz)).to_set
|
||||
end
|
||||
|
||||
test "assigned by" do
|
||||
assert_same_elements cards(:layout, :logo), Card.assigned_by(users(:david))
|
||||
assert_equal cards(:layout, :logo).to_set, Card.assigned_by(users(:david)).to_set
|
||||
end
|
||||
|
||||
test "in board" do
|
||||
new_board = Board.create! name: "New Board", creator: users(:david)
|
||||
assert_same_elements cards(:logo, :shipping, :layout, :text, :buy_domain), Card.where(board: boards(:writebook))
|
||||
assert_equal cards(:logo, :shipping, :layout, :text, :buy_domain).to_set, Card.where(board: boards(:writebook)).to_set
|
||||
assert_empty Card.where(board: new_board)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user