Skip to content

Commit

Permalink
On #8: Fixes failing tests on github
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Apr 28, 2024
1 parent 0773a13 commit 3fbbbf7
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions spec/models/article_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3fbbbf7

Please sign in to comment.