only create mentions after creating statusmessages

This commit is contained in:
Benjamin Neff 2016-08-17 00:25:50 +02:00
parent d022e51a0c
commit fb318373c7
2 changed files with 4 additions and 4 deletions

View file

@ -58,7 +58,6 @@ class StatusMessage < Post
def mentioned_people def mentioned_people
if self.persisted? if self.persisted?
create_mentions if self.mentions.empty?
self.mentions.includes(:person => :profile).map{ |mention| mention.person } self.mentions.includes(:person => :profile).map{ |mention| mention.person }
else else
Diaspora::Mentionable.people_from_string(text) Diaspora::Mentionable.people_from_string(text)

View file

@ -160,15 +160,16 @@ describe StatusMessage, type: :model do
end end
describe "#mentioned_people" do describe "#mentioned_people" do
it "calls create_mentions if there are no mentions in the db" do it "does not call create_mentions if there are no mentions in the db" do
status_message.mentions.delete_all status_message.mentions.delete_all
expect(status_message).to receive(:create_mentions) expect(status_message).not_to receive(:create_mentions)
status_message.mentioned_people status_message.mentioned_people
end end
it "returns the mentioned people" do it "returns the mentioned people" do
status_message.mentions.delete_all
expect(status_message.mentioned_people.to_set).to eq(people.to_set) expect(status_message.mentioned_people.to_set).to eq(people.to_set)
end end
it "does not call create_mentions if there are mentions in the db" do it "does not call create_mentions if there are mentions in the db" do
expect(status_message).not_to receive(:create_mentions) expect(status_message).not_to receive(:create_mentions)
status_message.mentioned_people status_message.mentioned_people