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.
def data_hash
return {} if data.blank?
@data_hash ||= begin
return {} if data.blank?
parsed = JSON.parse(data)
return {} if parsed.blank?
parsed = JSON.parse(data)
return {} if parsed.blank?
parsed.with_indifferent_access
parsed.with_indifferent_access
end
end
def url

View File

@ -334,12 +334,12 @@ describe PostMover do
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.post_number).to eq(1)
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.post_number).to eq(4)
end
@ -349,7 +349,7 @@ describe PostMover do
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.data_hash[:topic_title]).to eq(topic.title)
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)
n3.reload
n3 = Notification.find(n3.id)
expect(n3.topic_id).to eq(moved_to.id)
expect(n3.post_number).to eq(2)
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.post_number).to eq(4)
end