Skip to content

Allow application to be eager loaded without ActionCable#201

Open
adamsosterics wants to merge 1 commit intosimukappu:masterfrom
adamsosterics:action_cable_eager_load
Open

Allow application to be eager loaded without ActionCable#201
adamsosterics wants to merge 1 commit intosimukappu:masterfrom
adamsosterics:action_cable_eager_load

Conversation

@adamsosterics
Copy link

Issue #, if available: #200

Summary

The files in app/channels/activity_notification triggered Zeitwerk errors when the app didn't use ActionCable.
This PR changes these files, so the classes are always defined, no matter if ActioneCable is defined or not.

Other Information

When Zeitwerk loads these files it expects classes defined in them
even if ActionCable is not used.
@adamsosterics
Copy link
Author

I'm not 100% sure if this is the best solution but these modifications allowed me to load the gem.

@coveralls
Copy link

Coverage Status

coverage: 99.732% (-0.03%) from 99.759%
when pulling bd62785 on adamsosterics:action_cable_eager_load
into 8443d2b on simukappu:master.

@adamsosterics
Copy link
Author

I tried to write a test which eager loads the gem with and without ActionCable included, but it didn't really work out.
I added this test:

it 'eager loads all files' do
   expect{ Zeitwerk::Loader.eager_load_all }.not_to raise_error
end

But then I needed a way to initialize the app with and without ActionCable, but as you load the app in the spec_helper, I'm not sure hot to do it properly.
Should I try to test it? Do you have a recommendation for that?
Or the coverage drop is acceptable?
Or are you looking at a totally different solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants