Skip to content

Commit

Permalink
only create mentions after create
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperTux88 committed Aug 16, 2016
1 parent d022e51 commit 02dada6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/models/status_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def message

def mentioned_people
if self.persisted?
create_mentions if self.mentions.empty?
self.mentions.includes(:person => :profile).map{ |mention| mention.person }
else
Diaspora::Mentionable.people_from_string(text)
Expand Down
7 changes: 4 additions & 3 deletions spec/models/status_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,16 @@
end

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
expect(status_message).to receive(:create_mentions)
expect(status_message).not_to receive(:create_mentions)
status_message.mentioned_people
end

it "returns the mentioned people" do
status_message.mentions.delete_all
expect(status_message.mentioned_people.to_set).to eq(people.to_set)
end

it "does not call create_mentions if there are mentions in the db" do
expect(status_message).not_to receive(:create_mentions)
status_message.mentioned_people
Expand Down

0 comments on commit 02dada6

Please sign in to comment.