Skip to content
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

Merged
merged 3 commits into from
Jun 20, 2017

Conversation

tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Feb 24, 2017

Some more Rails 5 related fixes for the test suite.

Copy link
Contributor

@mamhoff mamhoff left a 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
Copy link
Contributor

@mtomov mtomov Mar 24, 2017

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 👍 !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mtomov

tvdeyen and others added 3 commits June 20, 2017 10:41
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
@tvdeyen tvdeyen force-pushed the refactor-admin-pages-controller-spec branch from 739a6bd to 97a7130 Compare June 20, 2017 08:43

it "should publish the page" do
expect(page).to receive(:publish!)
alchemy_post :publish, { id: page.id }
expect {

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

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]

@tvdeyen
Copy link
Member Author

tvdeyen commented Jun 20, 2017

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.

@mamhoff
Copy link
Contributor

mamhoff commented Jun 20, 2017

Merging even though Hound complains, we're fixing the Hound configuration in #1267 .

@mamhoff mamhoff merged commit 9185b05 into master Jun 20, 2017
@mamhoff mamhoff deleted the refactor-admin-pages-controller-spec branch June 20, 2017 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants