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

Separate Question posting form template from regular /post form #910

Closed
jywarren opened this issue Oct 20, 2016 · 6 comments
Closed

Separate Question posting form template from regular /post form #910

jywarren opened this issue Oct 20, 2016 · 6 comments
Assignees
Labels
enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute Ruby

Comments

@jywarren
Copy link
Member

In #904, we're tackling the re-design of the note posting form. But to implement the re-design, we'll need some routing changes.

If you'd like to do this before #904, you can just copy the template at /app/views/editor/post.html.erb to /app/views/editor/question.html.erb and the redirects will be in place -- the actual template redesign in #904 can then follow.

First, we should make a new route, something like /questions/new - which also renders the question action in the editor controller. This would be done at /config/routes.rb -- nearby and above similar routes starting with "question".

Then we'll want to intercept and re-route any incoming requests to the current /post action in the editor controller: https://github.com/publiclab/plots2/blob/master/app/controllers/editor_controller.rb#L6

That is, if it has a tag starting with question: we should redirect it to a new method for the question form. Think about creating a line in the post method in the editor controller:

def post
  redirect_to '/questions/new' if params[:tags].include?("question:")
  # rest of method here
end

Then we'll want to adjust the test that checks the redirect currently in place:

https://github.com/publiclab/plots2/blob/master/test/functional/editor_controller_test.rb#L40-L47

currently it just checks that the title is correct. We'll want to add:

assert_response :redirect
assert_redirected_to '/questions/new'

And probably remove the assert_select line.

@jywarren jywarren added enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute Ruby labels Oct 20, 2016
@sandyvern
Copy link
Collaborator

Would it be ok if I give this one a go?

@ebarry
Copy link
Member

ebarry commented Oct 31, 2016

HI Sandy! Great to hear from you again :D
of course it would be! What do you need from us?

@sandyvern
Copy link
Collaborator

Not sure yet, as I haven't entirely checked things out...but will let you know if I run into trouble :-)

@sandyvern
Copy link
Collaborator

I opened a 2nd pull request as I set up a Cloud9 workspace rather than trying to work locally. Let me know if you want me to close the first one. Also it looks like the testing didn't pass....I think it is the test edit...I wasn't sure about the last part about "probably remove the assert_select line" cause there are 2 assert_select . So not sure if both of those lines are not needed or not?

@jywarren
Copy link
Member Author

I logged into the Cloud9 workspace, and ran "rake test" and got:


============================================================================================================================
Failure: Expected response to be a redirect to <"http://test.host/questions/new"> but was a redirect to <"http://test.host/questions/new?redirect=question&tags=question%3Aquestion%2Cone&template=question">.
test_should_show_question_template_in_post_form_for_questions(EditorControllerTest)
test/functional/editor_controller_test.rb:49:in `block in <class:EditorControllerTest>'

So maybe I'm not seeing the same state you were looking at 22 days ago... anyhow, happy to help now (or just after Thanksgiving, of course!)

@jywarren
Copy link
Member Author

jywarren commented Jan 3, 2017

Looks like this is now complete!! Closing.

@jywarren jywarren closed this as completed Jan 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute Ruby
Projects
None yet
Development

No branches or pull requests

3 participants