Skip to content

Enable config.active_record.belongs_to_required_by_default #1698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ class Application < Rails::Application
# Fixture paths
config.fixture_paths = [Rails.root.join('spec/fixtures')]

# TODO: The following config should be switched to its default value `true`, but not urgent.
# Rails 5.0: Require `belongs_to` associations by default. Previous versions had false.
# https://railsguides.jp/configuring.html#config-active-record-belongs-to-required-by-default
config.active_record.belongs_to_required_by_default = false

# Rails 8.0: `to_time` will always preserve the full timezone in Rails 8.1.
config.active_support.to_time_preserves_timezone = :zone
end
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/statistics/aggregation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
let(:yaml_provider) { instance_double(EventService::Providers::StaticYaml) }

before do
d1 = create(:dojo, name: 'Dojo1', email: 'info@dojo1.com', description: 'CoderDojo1', tags: %w(CoderDojo1), url: 'https://dojo1.com')
d2 = create(:dojo, name: 'Dojo2', email: 'info@dojo2.com', description: 'CoderDojo2', tags: %w(CoderDojo2), url: 'https://dojo2.com')
d1 = create(:dojo, name: 'Dojo1', email: 'info@dojo1.com', description: 'CoderDojo1', tags: %w(CoderDojo1), url: 'https://dojo1.com', prefecture_id: 13)
d2 = create(:dojo, name: 'Dojo2', email: 'info@dojo2.com', description: 'CoderDojo2', tags: %w(CoderDojo2), url: 'https://dojo2.com', prefecture_id: 13)
create(:dojo_event_service, dojo_id: d1.id, name: :connpass, group_id: 9876)
create(:dojo_event_service, dojo_id: d2.id, name: :doorkeeper, group_id: 5555)

create(:dojo, id: 194, name: 'Dojo194', email: 'info@dojo194.com', description: 'CoderDojo194', tags: %w(CoderDojo194), url: 'https://dojo194.com')
create(:dojo, id: 194, name: 'Dojo194', email: 'info@dojo194.com', description: 'CoderDojo194', tags: %w(CoderDojo194), url: 'https://dojo194.com', prefecture_id: 13)
allow(EventService::Providers::StaticYaml).to receive(:new).and_return(yaml_provider)
allow(yaml_provider).to receive(:fetch_events).and_return([
{ 'dojo_id' => 194, 'event_url' => 'https://example.com/event/12345', 'evented_at' => '2023-12-10 14:00', 'participants' => 1 }
Expand Down Expand Up @@ -153,10 +153,10 @@

context 'find_dojos_by(services)' do
before :each do
@d1 = create(:dojo, name: 'Dojo1', email: 'info@dojo1.com', description: 'CoderDojo1', tags: %w(CoderDojo1), url: 'https://dojo1.com')
@d2 = create(:dojo, name: 'Dojo2', email: 'info@dojo2.com', description: 'CoderDojo2', tags: %w(CoderDojo2), url: 'https://dojo2.com')
@d3 = create(:dojo, name: 'Dojo3', email: 'info@dojo3.com', description: 'CoderDojo3', tags: %w(CoderDojo3), url: 'https://dojo3.com')
@d4 = create(:dojo, name: 'Dojo4', email: 'info@dojo4.com', description: 'CoderDojo4', tags: %w(CoderDojo4), url: 'https://dojo4.com')
@d1 = create(:dojo, name: 'Dojo1', email: 'info@dojo1.com', description: 'CoderDojo1', tags: %w(CoderDojo1), url: 'https://dojo1.com', prefecture_id: 13)
@d2 = create(:dojo, name: 'Dojo2', email: 'info@dojo2.com', description: 'CoderDojo2', tags: %w(CoderDojo2), url: 'https://dojo2.com', prefecture_id: 13)
@d3 = create(:dojo, name: 'Dojo3', email: 'info@dojo3.com', description: 'CoderDojo3', tags: %w(CoderDojo3), url: 'https://dojo3.com', prefecture_id: 13)
@d4 = create(:dojo, name: 'Dojo4', email: 'info@dojo4.com', description: 'CoderDojo4', tags: %w(CoderDojo4), url: 'https://dojo4.com', prefecture_id: 13)
create(:dojo_event_service, dojo_id: @d1.id, name: :connpass, group_id: 9876)
create(:dojo_event_service, dojo_id: @d2.id, name: :doorkeeper, group_id: 5555)
create(:dojo_event_service, dojo_id: @d2.id, name: :connpass, group_id: 9877)
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/upcoming_events/aggregation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

describe '.run' do
before do
@d1 = create(:dojo, name: 'Dojo1', email: 'info@dojo1.com', description: 'CoderDojo1', tags: %w(CoderDojo1), url: 'https://dojo1.com')
@d2 = create(:dojo, name: 'Dojo2', email: 'info@dojo2.com', description: 'CoderDojo2', tags: %w(CoderDojo2), url: 'https://dojo2.com')
@d1 = create(:dojo, name: 'Dojo1', email: 'info@dojo1.com', description: 'CoderDojo1', tags: %w(CoderDojo1), url: 'https://dojo1.com', prefecture_id: 13)
@d2 = create(:dojo, name: 'Dojo2', email: 'info@dojo2.com', description: 'CoderDojo2', tags: %w(CoderDojo2), url: 'https://dojo2.com', prefecture_id: 13)
@es1 = create(:dojo_event_service, dojo_id: @d1.id, name: :connpass, group_id: 9876)
@es2 = create(:dojo_event_service, dojo_id: @d2.id, name: :doorkeeper, group_id: 5555)
end
Expand Down
3 changes: 2 additions & 1 deletion spec/models/dojo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
order: 0, description: "東京都世田谷区で毎週開催",
logo: "https://graph.facebook.com/346407898743580/picture?type=large",
url: "http://tokyo.coderdojo.jp/",
tags: ["Scratch", "Webサイト", "ゲーム"])
tags: ["Scratch", "Webサイト", "ゲーム"],
prefecture_id: 13)
end

subject { @dojo }
Expand Down
4 changes: 4 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
config.include FactoryBot::Syntax::Methods

config.before(:suite) do
Rails.application.load_seed
end
end