From 6b1de5bf3d44449077b9eb4fb6e96889a7f0bacb Mon Sep 17 00:00:00 2001 From: bivanalhar Date: Mon, 3 Jun 2024 10:23:23 +0800 Subject: [PATCH] fix(test): include rails 6.0.6.1 - added Eraser model for testing - add many entities of Eraser inside the test when doing actables test --- Appraisals | 2 +- gemfiles/rails_6.0.gemfile | 2 +- spec/acts_as_spec.rb | 8 +++++++- spec/models.rb | 9 +++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Appraisals b/Appraisals index f307c24..a7c1e05 100644 --- a/Appraisals +++ b/Appraisals @@ -1,5 +1,5 @@ appraise "rails-6.0" do - gem 'rails', '~> 6.0' + gem 'rails', '6.0.6.1' end appraise "rails-6.1" do diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile index ea48f46..3135523 100644 --- a/gemfiles/rails_6.0.gemfile +++ b/gemfiles/rails_6.0.gemfile @@ -3,6 +3,6 @@ source "https://rubygems.org" gem "coveralls", require: false -gem "rails", "~> 6.0" +gem "rails", "6.0.6.1" gemspec path: "../" diff --git a/spec/acts_as_spec.rb b/spec/acts_as_spec.rb index e1cbff3..a47fe6c 100644 --- a/spec/acts_as_spec.rb +++ b/spec/acts_as_spec.rb @@ -4,7 +4,9 @@ subject { Pen } let(:pen_attributes) { {name: 'pen', price: 0.8, color: 'red'} } + let(:eraser_attributes) { {name: 'eraser', price: 1.2, strength: 3} } let(:pen) { Pen.new pen_attributes } + let(:eraser) { Eraser.new eraser_attributes } let(:isolated_pen) { IsolatedPen.new color: 'red' } let(:store) { Store.new name: 'biggerman' } let(:product) { Product.new store: store } @@ -399,13 +401,17 @@ end describe ".actables" do - before(:each) { clear_database } + before { clear_database } it "returns a query for the actable records" do red_pen = Pen.create!(name: 'red pen', price: 0.8, color: 'red') blue_pen = Pen.create!(name: 'blue pen', price: 0.8, color: 'blue') _black_pen = Pen.create!(name: 'black pen', price: 0.9, color: 'black') + 20.times do + Eraser.create!(name: 'eraser', price: 1.2, strength: 3) + end + actables = Pen.where(price: 0.8).actables expect(actables).to be_kind_of(ActiveRecord::Relation) diff --git a/spec/models.rb b/spec/models.rb index 5837ea6..caaf041 100644 --- a/spec/models.rb +++ b/spec/models.rb @@ -58,6 +58,10 @@ def pen_instance_method end end +class Eraser < ActiveRecord::Base + acts_as :product +end + class Buyer < ActiveRecord::Base belongs_to :product end @@ -118,6 +122,11 @@ def initialize_schema t.integer :pen_collection_id end + create_table :erasers do |t| + t.integer :strength + t.datetime :designed_at + end + create_table :products do |t| t.string :name t.float :price