You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:store option on :belongs_to association comes from activerecord-jsonb-associations gem and enables saving of foreign ids in properties (event details) jsonb column.
I use counter_culture gem for storing counter of specific events (Downloaded design, Liked design, etc.) on Design model with the help of :store option.
I tracked the issue in activerecord-jsonb-associations and activerecord gems. See for screenshots section below.
To Reproduce
The script below uses
Minitest instead of RSpec
shoulda and lower version of shoulda-matchers for Minitest
You need the replace blog_test string with an unimportant Postgresdatabase name.
I could not reproduce the test failure, the test that should have failed was successful with Minitest. I will try again with RSpec and same version of shoulda-matchers
require"bundler/inline"gemfile(true)dosource"https://rubygems.org"git_source(:github){ |repo| "https://github.com/#{repo}.git"}# Activate the gem you are reporting the issue against.gem"activerecord","5.2.3"gem'minitest'gem'shoulda','~> 3.6'gem'shoulda-matchers','~> 3.0'# gem 'activerecord-jsonb-associations', path: "/Users/sgnydn/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/bundler/gems/activerecord-jsonb-associations-9abe0dd9724a"gem'activerecord-jsonb-associations',github: 'rokumatsumoto/activerecord-jsonb-associations',branch: 'master'gem'pg','>= 0.18','< 2.0'endrequire'pg'require"active_record"require'activerecord/jsonb/associations'require"minitest"require"minitest/autorun"require"shoulda"require'shoulda/matchers'require"logger"ActiveRecord::Base.establish_connection(adapter: 'postgresql',database: 'blog_test'# use an unimportant database)ActiveRecord::Base.logger=Logger.new(STDOUT)# this is the default in RailsActiveRecord::Base.belongs_to_required_by_default=trueActiveRecord::Schema.definedocreate_table:ahoy_visits,force: truedo |t|
endcreate_table:ahoy_events,force: truedo |t|
t.references:visitt.jsonb:propertiesendcreate_table:designs,force: truedo |t|
endendShoulda::Matchers.configuredo |config|
config.integratedo |with|
with.test_framework:minitestwith.library:active_recordwith.library:active_modelendendmoduleAhoyclassVisit < ActiveRecord::Baseself.table_name='ahoy_visits'has_many:events,class_name: 'Ahoy::Event'endendmoduleAhoyclassEvent < ActiveRecord::Baseself.table_name='ahoy_events'belongs_to:visitbelongs_to:design,class_name: 'Design',store: :properties,optional: trueendendclassDesign < ActiveRecord::BaseendmoduleAhoyclassEventTest < ActiveSupport::TestCaseshouldbelong_to(:visit)endend
Expected behavior
Rails belongs_to test should pass
Screenshots
Desktop
OS: macOS Sierra
Browser Google Chrome
Version 80.0.3987.163
The text was updated successfully, but these errors were encountered:
Describe the bug
Adding a belongs_to test to Ahoy::Event Active Record model causes failure
Removing
store: :properties
fromAhoy::Event
model fixes the issue.:store
option on:belongs_to
association comes fromactiverecord-jsonb-associations
gem and enables saving of foreign ids inproperties
(event details)jsonb
column.I use
counter_culture
gem for storing counter of specific events (Downloaded design, Liked design, etc.) onDesign
model with the help of:store
option.I tracked the issue in
activerecord-jsonb-associations
andactiverecord
gems. See for screenshots section below.To Reproduce
The script below uses
Minitest
instead ofRSpec
shoulda
and lower version ofshoulda-matchers
for MinitestYou need the replace
blog_test
string with an unimportantPostgres
database
name.I could not reproduce the test failure, the test that should have failed was successful with
Minitest
. I will try again withRSpec
and same version ofshoulda-matchers
Expected behavior
Rails belongs_to test should pass
Screenshots
Desktop
The text was updated successfully, but these errors were encountered: