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

Add test for questions count on methods page #2621

Merged
merged 6 commits into from Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/node.rb
Expand Up @@ -774,7 +774,7 @@ def body_preview(length = 100)
def questions
# override with a tag like `questions:h2s`
if self.has_power_tag('questions')
tagname = node.power_tag('questions')
tagname = self.power_tag('questions')
else
tagname = self.slug_from_path
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/notes/_notes.html.erb
Expand Up @@ -41,7 +41,7 @@
<p><small>
<a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#Activities"><i class="fa fa-flask" style="color:#3da56a;"></i> <%= node.activities.count %> activities</a> &nbsp;
<!-- <p><i class="fa fa-users" style="color:blue"></i> contributors</p> -->
<a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#Questions"><i class="fa fa-question-circle" style="color:#db3a1e;"></i> <%= node.questions.count %> questions</a>
<a <% if @widget %>target="_blank"<% end %> href="<%= node.path %>#Questions"><i class="fa fa-question-circle" style="color:#db3a1e;"></i> <span id="questions-count-<%= node.id %>"><%= node.questions.count %> questions</span></a>
</small></p>
<% else %>
<p><%= raw strip_tags(sanitize(RDiscount.new(node.body_preview).to_html)) if node.body %></p>
Expand Down
10 changes: 10 additions & 0 deletions test/functional/wiki_controller_test.rb
Expand Up @@ -558,6 +558,16 @@ def teardown
assert_not_nil :topics
end

test 'should get methods page and show questions count' do
nodes(:method).add_tag('questions:spectrometer', users(:bob))
Copy link
Contributor

Choose a reason for hiding this comment

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

@jywarren ...see this line :

tagname = node.power_tag('questions')

undefined local variable , right ?

nodes(:method).add_tag('method', users(:bob))
get :methods

assert_response :success
assert_not_nil :nodes
assert_select "#questions-count-#{nodes(:method).id}", "#{nodes(:method).questions.count} questions"
end

test 'should get methods page for given topic' do
get :methods, topic: 'mining'

Expand Down