-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from robotmay/locale-fixes
Bugfixes for comment notifications in wrong locale
- Loading branch information
Showing
3 changed files
with
91 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,67 @@ | ||
require 'spec_helper' | ||
|
||
describe Comment do | ||
let(:user) { User.make! } | ||
let(:photograph) { Photograph.make!(user: User.make!) } | ||
let(:comment_thread) { CommentThread.make!(user: user, threadable: photograph) } | ||
|
||
it { should belong_to(:user) } | ||
it { should belong_to(:comment_thread) } | ||
it { should have_many(:notifications) } | ||
|
||
[:user_id, :comment_thread_id, :body].each do |attr| | ||
it { should validate_presence_of(attr) } | ||
end | ||
|
||
describe "scopes" do | ||
let(:published_comment) { | ||
Comment.make!(published: true, comment_thread: comment_thread, user: user) | ||
} | ||
|
||
it "returns published comments" do | ||
Comment.published.should include(published_comment) | ||
end | ||
end | ||
|
||
describe "notifications" do | ||
let(:comment) { Comment.make(comment_thread: comment_thread) } | ||
let(:notification) { Notification.make(notifiable: comment) } | ||
let(:photo_user) { User.make(locale: "en") } | ||
let(:comment_user) { User.make(locale: "fr") } | ||
|
||
|
||
describe "#notify" do | ||
it "creates a notification" do | ||
comment.notifications.should_receive(:create) | ||
comment.notify | ||
end | ||
|
||
describe "locales" do | ||
let(:comment) { Comment.make(user: comment_user) } | ||
|
||
it "uses the target's locale" do | ||
I18n.should_receive(:with_locale).with(photo_user.locale) | ||
comment.notify | ||
end | ||
end | ||
end | ||
|
||
describe "#toggle_visibility" do | ||
before { comment.stub(:save) { true } } | ||
|
||
it "creates a notification" do | ||
comment.notifications.should_receive(:create) | ||
comment.toggle_visibility | ||
end | ||
|
||
describe "locales" do | ||
let(:comment) { Comment.make(user: comment_user) } | ||
|
||
it "uses the target's locale" do | ||
I18n.should_receive(:with_locale).with(comment_user.locale) | ||
comment.toggle_visibility | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters