From fd17f339d4c50fd472f852951c60938e7bec59ac Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Thu, 6 Oct 2022 12:27:34 +0200 Subject: [PATCH] article_spec: add deleted test --- config/environments/test.rb | 6 ++++++ spec/models/article_spec.rb | 5 +++++ spec/models/order_article_spec.rb | 4 ++++ spec/spec_helper.rb | 9 +++++++++ 4 files changed, 24 insertions(+) diff --git a/config/environments/test.rb b/config/environments/test.rb index ccf3767f..86b59a8b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -47,4 +47,10 @@ Rails.application.configure do # Raises error for missing translations # config.action_view.raise_on_missing_translations = true + + # Enable stdout logger + config.logger = Logger.new(STDOUT) + + # Set log level + config.log_level = :DEBUG end diff --git a/spec/models/article_spec.rb b/spec/models/article_spec.rb index 526b5417..8484d713 100644 --- a/spec/models/article_spec.rb +++ b/spec/models/article_spec.rb @@ -9,6 +9,11 @@ describe Article do expect(article2).to be_invalid end + it 'can be deleted' do + article.mark_as_deleted() + expect(article.deleted?).to be true + end + it 'computes the gross price correctly' do article.deposit = 0 article.tax = 12 diff --git a/spec/models/order_article_spec.rb b/spec/models/order_article_spec.rb index 32b280dc..f8f05c7b 100644 --- a/spec/models/order_article_spec.rb +++ b/spec/models/order_article_spec.rb @@ -4,6 +4,10 @@ describe OrderArticle do let(:order) { create :order, article_count: 1 } let(:oa) { order.order_articles.first } + it 'foo' do + oa.update_article_and_price!() + end + it 'is not ordered by default' do expect(OrderArticle.ordered.count).to eq 0 end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6cd41ded..fbf281da 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -68,6 +68,15 @@ if ENV['COVERAGE'] == 'lcov' SimpleCov.formatters = SimpleCov::Formatter::LcovFormatter end +if ENV['COVERAGE'] == 'html' + require 'simplecov-lcov' + SimpleCov::Formatter::LcovFormatter.config do |c| + c.report_with_single_file = true + c.single_report_path = 'coverage/lcov.html' + end + SimpleCov.formatters = SimpleCov::Formatter::HTMLFormatter +end + # include default foodsoft scope in urls, so that *_path works # https://github.com/rspec/rspec-rails/issues/255 class ActionDispatch::Routing::RouteSet