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

Refinery::Admin::PagesController#update error #2487

Closed
mattherick opened this issue Dec 6, 2013 · 17 comments
Closed

Refinery::Admin::PagesController#update error #2487

mattherick opened this issue Dec 6, 2013 · 17 comments

Comments

@mattherick
Copy link
Contributor

If I update an existing page and leave the title blank i get following error:

NoMethodError in Refinery::Admin::PagesController#update
undefined method `to_slug' for nil:NilClass

I use refinerycms 2.1.1

@parndt
Copy link
Member

parndt commented Dec 6, 2013

Hmm, thanks. Could you help us by contributing a failing test case for this? Otherwise, if someone else wants to then great! Or, I'll get to it in a while. :-)

@mattherick
Copy link
Contributor Author

I get the same error in refinerycms 2.1.0 and with one or more locales defined.
Dummy question, but how can I just run the specs of the refinerycms-pages extension?

@parndt
Copy link
Member

parndt commented Dec 6, 2013

You'd have to clone the repository and run bundle exec rspec pages/spec

Or, do you mean within the context of your application?

@mattherick
Copy link
Contributor Author

Ok thx. No I meant within the context of the cms itself.

@mattherick
Copy link
Contributor Author

I cloned the refinerycms repository as you said.

bundle exec rspec pages/spec

causes following error:

/my-path/refinerycms/spec/spec_helper.rb:10:in `require': cannot load such file -- /my-path/refinerycms/spec/dummy/config/environment (LoadError)
from /my-path/refinerycms/spec/spec_helper.rb:10:in `<top (required)>'

@parndt
Copy link
Member

parndt commented Dec 6, 2013

First you have to install the dummy application http://refinerycms.com/guides/contributing-to-refinery#setup

bundle exec rake refinery:testing:dummy_app

@mattherick
Copy link
Contributor Author

ah okay, now I have the setup I need :).

Fresh clone:
Finished in 1 minute 35.71 seconds
513 examples, 4 failures

Finished in 1 minute 52.7 seconds
513 examples, 1 failure

a bit random? :)

But anyway, I´ll try to get a failing test for my scenario - and a possible fix also.

@parndt
Copy link
Member

parndt commented Dec 6, 2013

Yeah, currently we have set --order random so that we can identify tests that leak across to eachother. It makes the tests fail, unfortunately, but it's there to remind us that we need to make the tests properly isolated and less brittle.

@mattherick
Copy link
Contributor Author

hmm, I can´t reproduce my error.

@ugisozols
Copy link
Member

@mattherick any luck reproducing?

@mattherick
Copy link
Contributor Author

Nope. I fixed it through a before filter:
app/decorators/controllers/refinery/admin/pages_controller_decorator.rb

before_filter :title_check, :only => [:update]

private

def title_check
  if params[:page][:title].blank?
    @page.errors.add(:title, I18n.t("errors.messages.blank"))
    @page.title = ""
    render "edit"
  end
end

But I don't know why this happens..

@parndt
Copy link
Member

parndt commented Dec 10, 2013

After reading your code again, I'm taking back what I said about it being dangerous, I see that you're bouncing the user back to the edit template.

When they submit this a second time, do you get the same problem again?

@mattherick
Copy link
Contributor Author

If the title is blank and they submit.. the edit template will be rendered again.. second time, third time, fourth time..always the same behavior. So yes, I always have the same problem.

@parndt
Copy link
Member

parndt commented Dec 10, 2013

Can't you prevent this with:

validates :title, presence: true

I'm very surprised that it's not being caught by our own validation

@mattherick
Copy link
Contributor Author

no, it´s weird.

@MaG21
Copy link

MaG21 commented Feb 17, 2014

I'm having this very same issue. Any progress so far with this issue?

@parndt
Copy link
Member

parndt commented Jul 29, 2014

When I do the same, I get a validation error.

screenshot 2014-07-29 11 52 32

@parndt parndt closed this as completed Jul 29, 2014
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

No branches or pull requests

4 participants