-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Free specs from seeding #927
Conversation
e1504f8
to
c85f196
Compare
Love this: |
# There should always be a current org, but being defensive here helps simplify tests | ||
Organization.instance_owner&.logo_url.presence || asset_pack_path('media/images/logo.png') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I've tripped up on this many times, and this feels to me like a much better home for this conditional than anywhere else it has lived before
9762e39
to
901a630
Compare
1. Move logo defaulting method out of Vue into the backend 2. Accommodate current_organization being nil: intended to support specs without having to seed the test db. 3. Extract helper method to consolidate defaulting logic Note: i don't love adding this to application_helper, particularly since that module is already quite cluttered. Couldn't come up with a better option though.
Allows simpler assertions than a request spec would. Also means the spec doesn't have to rely on a seeded test DB.
Inverting the dependency here allows specs to easily pass in a SystemSetting instance instead of relying on the test db to have been seeded.
Allows for organization to be injected in specs instead of having to mock Organization.instance_owner or relying on it having been seeded.
Allows specs to inject organization instead of having to rely on seeding or class method mocking.
c85f196
to
3539330
Compare
Why
Our ruby specs currently depend on the test database being seeded, which is non-standard and surprising, particularly for new contributors.
What, How
logo_url
logic into a new helper method and make it defensive in case the DB doesn't have aninstance_owner
.shared/_organization_logo
andNavBar.vue
.GenerateLandingPageJson
interactor out ofPublicPagesController.landing_page
to ease testing.LocationType
in a couple of specs instead of relying on one having been seeded.SystemSetting
intoSubmissionMailer
so it can be injected easily in specs.Organization
intoEmailNewSubmission
andEmailPeer
interactors, and the corresponding mailers (SubmissionMailer
,PeerToPeerMatchMailer
)Testing
Relies on existing specs and some manual testing of nav bar, login and signup pages.
Next Steps
Organization.instance_owner
should live inContext
, similar toSystemSetting.current_settings
.Outstanding Questions, Concerns and Other Notes
Note this is built on top of #926 which renamed
Organization.current_organization
to.instance_owner
. However the changes here aren't really dependent on that particular change.Pre-Merge Checklist