Commit f03ea737 by Toby Lawrence Committed by GitHub

Merge branch 'master' into bbeggs/revert-context-migration

parents 1f6978cc c309a7de
...@@ -90,7 +90,7 @@ GEM ...@@ -90,7 +90,7 @@ GEM
rake rake
multi_json (1.11.2) multi_json (1.11.2)
netrc (0.10.3) netrc (0.10.3)
newrelic_rpm (3.15.0.314) newrelic_rpm (3.16.0.318)
nokogiri (1.6.8) nokogiri (1.6.8)
mini_portile2 (~> 2.1.0) mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7) pkg-config (~> 1.1.7)
......
...@@ -141,7 +141,14 @@ class Comment < Content ...@@ -141,7 +141,14 @@ class Comment < Content
end end
def context def context
self.comment_thread_id ? self.comment_thread.context : nil if self.comment_thread_id
t = CommentThread.find self.comment_thread_id
if t
t.context
end
end
rescue Mongoid::Errors::DocumentNotFound
nil
end end
def course_context? def course_context?
......
require 'new_relic/agent/method_tracer'
module ThreadUtils module ThreadUtils
def self.get_endorsed(threads) def self.get_endorsed(threads)
...@@ -39,9 +41,10 @@ module ThreadUtils ...@@ -39,9 +41,10 @@ module ThreadUtils
read_states read_states
end end
extend self class << self
include ::NewRelic::Agent::MethodTracer include ::NewRelic::Agent::MethodTracer
add_method_tracer :get_read_states add_method_tracer :get_read_states
add_method_tracer :get_endorsed add_method_tracer :get_endorsed
end
end end
...@@ -36,6 +36,14 @@ describe Comment do ...@@ -36,6 +36,14 @@ describe Comment do
expect(comment.context).to eq("course") expect(comment.context).to eq("course")
end end
end end
context 'without valid parent thread' do
it 'returns nil' do
comment = make_comment(author, course_thread, "comment")
comment.comment_thread_id = 'not a thread'
expect(comment.context).to eq(nil)
end
end
end end
describe '#course_context?' do describe '#course_context?' do
...@@ -52,6 +60,14 @@ describe Comment do ...@@ -52,6 +60,14 @@ describe Comment do
expect(comment.course_context?).to be_true expect(comment.course_context?).to be_true
end end
end end
context 'without valid parent thread' do
it 'returns false' do
comment = make_comment(author, course_thread, "comment")
comment.comment_thread_id = 'not a thread'
expect(comment.course_context?).to be_false
end
end
end end
describe '#standalone_context?' do describe '#standalone_context?' do
...@@ -68,6 +84,15 @@ describe Comment do ...@@ -68,6 +84,15 @@ describe Comment do
expect(comment.standalone_context?).to be_false expect(comment.standalone_context?).to be_false
end end
end end
context 'without valid parent thread' do
it 'returns false' do
comment = make_comment(author, course_thread, "comment")
comment.comment_thread_id = 'not a thread'
expect(comment.standalone_context?).to be_false
end
end
end end
describe '#child_count' do describe '#child_count' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment