From 3fbbbf7a6141c28af4bf84edb6fd2e09843b06a4 Mon Sep 17 00:00:00 2001 From: Florian Lentsch Date: Sun, 28 Apr 2024 11:47:16 +0200 Subject: [PATCH] On #8: Fixes failing tests on github --- spec/models/article_version_spec.rb | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/spec/models/article_version_spec.rb b/spec/models/article_version_spec.rb index 6a9f302e..ad54f786 100644 --- a/spec/models/article_version_spec.rb +++ b/spec/models/article_version_spec.rb @@ -26,21 +26,37 @@ end it 'keeps the properties of article versions in closed orders' do - original_version_id = article_version.id - original_version = article_version.dup + oa = order.order_articles.first + current_article_version = oa.reload.article_version + original_version_id = current_article_version.id + original_version = current_article_version.dup new_version = create(:article_version) new_attributes = new_version.attributes.except('updated_at', 'created_at', 'id', 'article_id') order.finish!(admin) + puts 'IDS: ' + described_class.all.map(&:id).join(',') + + puts 'Updating...' article.update(latest_article_version_attributes: new_attributes.merge(id: article_version.id)) + new_version = article.latest_article_version + version_in_order = oa.reload.article_version + + puts 'IDS: ' + described_class.all.map(&:id).join(',') + + puts "ID: #{original_version_id} <-> #{version_in_order.id} vs #{new_version.id}" + new_version.attributes.except('id').each_key do |key| + puts "#{original_version[key] == version_in_order[key] ? 'EQ' : 'NEQ'}: '#{key}': {#{original_version[key]}} <-> {#{version_in_order[key]}}" + end + + expect(original_version_id).not_to eq new_version.id + expect(original_version_id).to eq version_in_order.id new_attributes.each do |key, value| - expect(article.latest_article_version[key]).to eq value - expect(order.order_articles.first.article_version[key]).to eq original_version[key] + expect(new_version[key]).to eq value + expect(version_in_order[key]).to eq(original_version[key]), "'#{key}' property changed: Old {#{original_version[key]}} <-> Current {#{version_in_order[key]}}" end - expect(original_version_id).not_to eq article.latest_article_version.id end end