models: rename post/pool archives to post/pool versions.

This commit is contained in:
evazion
2020-02-15 06:52:10 -06:00
parent 51f3f7338a
commit 60ff2ae929
27 changed files with 71 additions and 84 deletions

View File

@@ -4,11 +4,11 @@ module PoolArchiveTestHelper
def send_message(msg, *options)
_, json = msg.split(/\n/)
json = JSON.parse(json)
prev = PoolArchive.where(pool_id: json["pool_id"]).order("id desc").first
prev = PoolVersion.where(pool_id: json["pool_id"]).order("id desc").first
if merge?(prev, json)
prev.update_columns(json)
else
PoolArchive.create(json)
PoolVersion.create(json)
end
end
@@ -17,14 +17,14 @@ module PoolArchiveTestHelper
end
end
PoolArchive.stubs(:sqs_service).returns(mock_sqs_service.new)
PoolVersion.stubs(:sqs_service).returns(mock_sqs_service.new)
end
def start_pool_archive_transaction
PoolArchive.connection.begin_transaction joinable: false
PoolVersion.connection.begin_transaction joinable: false
end
def rollback_pool_archive_transaction
PoolArchive.connection.rollback_transaction
PoolVersion.connection.rollback_transaction
end
end

View File

@@ -18,8 +18,8 @@ module PostArchiveTestHelper
_, json = msg.split(/\n/)
json = JSON.parse(json)
json.delete("created_at")
json["version"] = 1 + PostArchive.where(post_id: json["post_id"]).count
prev = PostArchive.where(post_id: json["post_id"]).order("id desc").first
json["version"] = 1 + PostVersion.where(post_id: json["post_id"]).count
prev = PostVersion.where(post_id: json["post_id"]).order("id desc").first
if prev
json["added_tags"] = json["tags"].scan(/\S+/) - prev.tags.scan(/\S+/)
json["removed_tags"] = prev.tags.scan(/\S+/) - json["tags"].scan(/\S+/)
@@ -32,7 +32,7 @@ module PostArchiveTestHelper
if merge?(prev, json)
prev.update_columns(json)
else
PostArchive.create(json)
PostVersion.create(json)
end
end
@@ -41,14 +41,14 @@ module PostArchiveTestHelper
end
end
PostArchive.stubs(:sqs_service).returns(mock_sqs_service.new)
PostVersion.stubs(:sqs_service).returns(mock_sqs_service.new)
end
def start_post_archive_transaction
PostArchive.connection.begin_transaction joinable: false
PostVersion.connection.begin_transaction joinable: false
end
def rollback_post_archive_transaction
PostArchive.connection.rollback_transaction
PostVersion.connection.rollback_transaction
end
end