Skip to content

Commit

Permalink
fix(test): include rails 6.0.6.1
Browse files Browse the repository at this point in the history
- added Eraser model for testing
- add many entities of Eraser inside the test when doing actables test
  • Loading branch information
bivanalhar committed Jul 23, 2024
1 parent 11d5137 commit 6b1de5b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Appraisals
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
source "https://rubygems.org"

gem "coveralls", require: false
gem "rails", "~> 6.0"
gem "rails", "6.0.6.1"

gemspec path: "../"
8 changes: 7 additions & 1 deletion spec/acts_as_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions spec/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6b1de5b

Please sign in to comment.