-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Refactor admin pages controller spec #1242
Conversation
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.
Nice work :)
alchemy_post :publish, { id: page.id } | ||
expect { | ||
post publish_admin_page_path(page) | ||
}.to change { page.reload.published_at } | ||
end |
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.
My suggestion here for MySQL is:
# spec/requests/alchemy/admin/pages_controller_spec.rb:666
- let(:page) { create(:alchemy_page) }
+ let(:page) { create(:alchemy_page, published_at: 3.days.ago) }
edit that should actually fix the only failing spec and get this build to a green one.
else super 👍 !
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.
Feel free to actually directly cherry-pick that:
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.
Thanks @mtomov
The controller spec was bogus. A feature spec for testing what the instance variable actually effects in thew views is preferable.
Rails 5 removes controller specs and request specs are preferred. This also refactors lots of heavy stubbing out of this spec.
- as MySQL only saves times to the db in seconds precision
739a6bd
to
97a7130
Compare
|
||
it "should publish the page" do | ||
expect(page).to receive(:publish!) | ||
alchemy_post :publish, { id: page.id } | ||
expect { |
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.
Parenthesize the param change { page.reload.published_at } to make sure that the block will be associated with the change method call.
} | ||
end | ||
|
||
context "a new page" do |
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.
Block has too many lines. [60/25]
Merging this ignoring hound here for now. I opened another PR that fixes all rubocop issues, but this is rather large, so it will take some time to review. |
Merging even though Hound complains, we're fixing the Hound configuration in #1267 . |
Some more Rails 5 related fixes for the test suite.