Fix the build - take 3.

754e1238b0
This commit is contained in:
Vinoth Kannan 2019-12-05 20:35:39 +05:30
parent 754e1238b0
commit 11c4d5eda7
2 changed files with 11 additions and 9 deletions

View File

@ -147,12 +147,14 @@ class Notification < ActiveRecord::Base
# Be wary of calling this frequently. O(n) JSON parsing can suck. # Be wary of calling this frequently. O(n) JSON parsing can suck.
def data_hash def data_hash
return {} if data.blank? @data_hash ||= begin
return {} if data.blank?
parsed = JSON.parse(data) parsed = JSON.parse(data)
return {} if parsed.blank? return {} if parsed.blank?
parsed.with_indifferent_access parsed.with_indifferent_access
end
end end
def url def url

View File

@ -334,12 +334,12 @@ describe PostMover do
new_topic = topic.move_posts(user, [p3.id], title: "new testing topic name") new_topic = topic.move_posts(user, [p3.id], title: "new testing topic name")
n3.reload n3 = Notification.find(n3.id)
expect(n3.topic_id).to eq(new_topic.id) expect(n3.topic_id).to eq(new_topic.id)
expect(n3.post_number).to eq(1) expect(n3.post_number).to eq(1)
expect(n3.data_hash[:topic_title]).to eq(new_topic.title) expect(n3.data_hash[:topic_title]).to eq(new_topic.title)
n4.reload n4 = Notification.find(n4.id)
expect(n4.topic_id).to eq(topic.id) expect(n4.topic_id).to eq(topic.id)
expect(n4.post_number).to eq(4) expect(n4.post_number).to eq(4)
end end
@ -349,7 +349,7 @@ describe PostMover do
topic.move_posts(user, [p1.id], title: "new testing topic name") topic.move_posts(user, [p1.id], title: "new testing topic name")
n1.reload n1 = Notification.find(n1.id)
expect(n1.topic_id).to eq(topic.id) expect(n1.topic_id).to eq(topic.id)
expect(n1.data_hash[:topic_title]).to eq(topic.title) expect(n1.data_hash[:topic_title]).to eq(topic.title)
expect(n1.post_number).to eq(1) expect(n1.post_number).to eq(1)
@ -575,12 +575,12 @@ describe PostMover do
moved_to = topic.move_posts(user, [p3.id], destination_topic_id: destination_topic.id) moved_to = topic.move_posts(user, [p3.id], destination_topic_id: destination_topic.id)
n3.reload n3 = Notification.find(n3.id)
expect(n3.topic_id).to eq(moved_to.id) expect(n3.topic_id).to eq(moved_to.id)
expect(n3.post_number).to eq(2) expect(n3.post_number).to eq(2)
expect(n3.data_hash[:topic_title]).to eq(moved_to.title) expect(n3.data_hash[:topic_title]).to eq(moved_to.title)
n4.reload n4 = Notification.find(n4.id)
expect(n4.topic_id).to eq(topic.id) expect(n4.topic_id).to eq(topic.id)
expect(n4.post_number).to eq(4) expect(n4.post_number).to eq(4)
end end