-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Replace all uses of wiki.slug in favor of wiki.path, fixes #736 #1101
Conversation
Aha - i see this is using some ERB templating code in the test:
For that we ought to use normal Ruby string substitution, like: https://github.com/publiclab/plots2/pull/1101/files#diff-6d0eec853a873b030e87f5a21aecdf63L150 and https://github.com/publiclab/plots2/blob/master/test/functional/admin_controller_test.rb#L324 It looks like that code was already wrong, actually! It was not running the ERB replacements, just spitting out the whole thing as a string, see? So it's great that we caught that in our revisions here. |
Yeah that is great! I shall make the changes now! |
Done! So the @node.slug_from_path function cannot be accessed from a Ruby string and needs to be added separately. That was the problem? |
Ah, looks like perhaps it should be |
I defined the function slug_from_path in drupal_node.rb. So shouldnt it be @DrupalNode.slug_from_path? |
DrupalNode is the classname -- so you can use it to make a new node like
DrupalNode.new. But once you make one, like:
node = DrupalNode.new
then you refer to it by the variable you've stored the instance in. In this
case, we didn't make a `node` or `@node` variable, but we can access the
node we want because `@revision` has a `.node` method which fetches it.
…On Wed, Dec 14, 2016 at 3:49 PM, 500swapnil ***@***.***> wrote:
I defined the function slug_from_path in drupal_node.rb. So shouldnt it be
@DrupalNode.slug_from_path?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1101 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABfJ4MME1_Sd-baONcKn3pfaoLXBOVIks5rIFZIgaJpZM4LNWvs>
.
|
Okay |
Ah - sorry, looks like we need |
No problem. I had that doubt |
Same error |
Checking now! Also, you can always ping |
@@ -321,7 +321,7 @@ def teardown | |||
assert_equal 0, revision.status | |||
assert_equal 0, revision.author.status | |||
assert_not_equal node(:spam_targeted_page).latest.vid, revision.vid | |||
assert_redirected_to "/wiki/revisions/<%= @node.slug %>" + '?_=' + Time.now.to_i.to_s | |||
assert_redirected_to "/wiki/revisions/" + @revision.drupal_node.slug_from_path + '?_=' + Time.now.to_i.to_s |
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.
OK -- while in the controller, we used an instance variable (starting with @
) in the test, we are just using a local variable, so no @
required. Check each changed line to ensure we're using what's available there -- either @node
or @revision
or node
or revision
-- and match the usage in that context.
@@ -77,7 +76,7 @@ | |||
<% if @node.power_tags('tabbed').include?("notes") %> | |||
<div class="tab-pane" id="tab-notes"> | |||
<%= render :partial => "notes/notes" %> | |||
<p><a href="/tag/<%= @node.slug %>"><%= raw t('wiki.show.more_research', :tag => @node.slug) %> »</a></p> | |||
<p><a href="/tag/<%= @revision.drupal_node.slug_from_path %>"><%= raw t('wiki.show.more_research', :tag => @revision.drupal_node.slug_from_path) %> »</a></p> |
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.
Yes -- see how here, we can indeed use @node
-- it was only in some contexts where @revision
was required, not all. Thanks!
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.
I went through the errors. @node is fine for all except admin_controller.rb and admin_controller_test.rb.
What should I use in admin_controller.rb and admin_controller_test.rb??
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.
Is there any way of testing a part of code and not the whole code locally? Some command instead of rake test:all .
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.
On this line in the admin controller test, revision.drupal_node
:
https://github.com/publiclab/plots2/blob/master/test/functional/admin_controller_test.rb#L324
And on this line, @revision.drupal_node
:
https://github.com/publiclab/plots2/blob/master/app/controllers/admin_controller.rb#L150
Yes, you can run just functional tests with rake test:functionals
, units with rake test:units
, integration with rake test:integration
, and you can even run just one test file with:
ruby -I test test/functional/notes_controller_test.rb
(for example)
I know it's time consuming to run them all!
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.
Okay I will work on it now!
Fine now? |
I'll take a look but I have to head out now -- later tonight I hope! Thanks! |
@@ -339,3 +339,9 @@ DEPENDENCIES | |||
uglifier (>= 1.0.3) | |||
will_paginate (>= 3.0.6) | |||
will_paginate-bootstrap (>= 1.0.1) | |||
|
|||
RUBY VERSION |
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.
I'd like to not include Gemfile or Gemfile.lock changes if not essential, but I'll leave these in this time. Thanks!
Looks great! merging now. Thanks for your careful work on this one! |
Thank you! Any idea on which issue I should try next? |
Yes -- there are some sub-issues to this one that'd be great to have some assistance on! #397 For example, the checks on the |
Make sure these boxes are checked before your pull request is ready to be reviewed and merged. Thanks!
rake test:all
schema.rb.example
has been updated if any database migrations were addedPlease be sure you've reviewed our contribution guidelines at https://publiclab.org/wiki/contributing-to-public-lab-software
We have a loose schedule of reviewing and pulling in changes every Tuesday and Friday, and publishing changes on Fridays. Please alert developers on plots-dev@googlegroups.com when your request is ready or if you need assistance.
Thanks!