Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Fix individual post view #507

Merged
merged 2 commits into from
Mar 27, 2022
Merged

Fix individual post view #507

merged 2 commits into from
Mar 27, 2022

Conversation

edwardloveall
Copy link
Owner

I first thought this was markdown so I updated the feature post spec (it's now improved but unrelated to the fix). Then I discovered that it's because InternalPostsController was using the default application layout instead of the blog layout. Easy fix, but what about the test?

I first tried to use a controller test. However, asserting that a specific layout is used is deprecated: rails/rails#20138 Then I tried a feature spec. This works, but I'm still just testing things unrelated to what I care about. In particular, the main navigation exists in the application layout, but not in the blog layout. That works for now, but it still didn't feel like the right way to test if a post has the correct styles applied to it.

I landed on actually asserting on the styles using Capybara's matches_style matcher. This requires that I use a non-headless browser to render the CSS styles of a page.

Adding a test for markdown and also updating it to match modern style
prefs
I first thought this was markdown so I updated the feature post spec (it's now improved but unrelated to the fix). Then I discovered that it's because InternalPostsController was using the default application layout instead of the blog layout. Easy fix, but what about the test?

I first tried to use a controller test. However, asserting that a specific layout is used is deprecated: rails/rails#20138 Then I tried a feature spec. This works, but I'm still just testing things unrelated to what I care about. In particular, the main navigation (About Projects Music) exists in the application layout, but not in the blog layout. That works for now, but it still didn't feel like the right way to test if a post has the correct styles applied to it.

I landed on actually asserting on the styles using Capybara's [matches_style] matcher. This requires that I use a non-headless browser to render the CSS styles of a page.

[matches_style]: https://rubydoc.info/github/teamcapybara/capybara/master/Capybara%2FNode%2FMatchers:matches_style%3F
@edwardloveall edwardloveall merged commit a79cb69 into main Mar 27, 2022
@edwardloveall edwardloveall deleted the el-fix-post-markdown branch March 27, 2022 01:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant