2013-06-19 12:40:33 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
2014-10-09 15:22:20 +00:00
|
|
|
# Table name: members
|
2013-06-19 12:40:33 +00:00
|
|
|
#
|
2013-08-21 09:34:02 +00:00
|
|
|
# id :integer not null, primary key
|
2014-09-15 08:36:50 +00:00
|
|
|
# access_level :integer not null
|
2014-10-09 15:22:20 +00:00
|
|
|
# source_id :integer not null
|
|
|
|
# source_type :string(255) not null
|
2013-08-21 09:34:02 +00:00
|
|
|
# user_id :integer not null
|
2014-10-09 15:22:20 +00:00
|
|
|
# notification_level :integer not null
|
|
|
|
# type :string(255)
|
2014-04-09 12:05:03 +00:00
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
2013-06-19 12:40:33 +00:00
|
|
|
#
|
|
|
|
|
2013-06-17 10:07:16 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-09-14 16:32:51 +00:00
|
|
|
describe GroupMember do
|
2014-06-17 18:36:40 +00:00
|
|
|
context 'notification' do
|
|
|
|
describe "#after_create" do
|
|
|
|
it "should send email to user" do
|
2014-09-15 08:36:50 +00:00
|
|
|
membership = build(:group_member)
|
2014-06-17 18:36:40 +00:00
|
|
|
membership.stub(notification_service: double('NotificationService').as_null_object)
|
|
|
|
membership.should_receive(:notification_service)
|
|
|
|
membership.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#after_update" do
|
|
|
|
before do
|
2014-09-15 08:36:50 +00:00
|
|
|
@membership = create :group_member
|
2014-06-17 18:36:40 +00:00
|
|
|
@membership.stub(notification_service: double('NotificationService').as_null_object)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should send email to user" do
|
|
|
|
@membership.should_receive(:notification_service)
|
2014-09-15 08:36:50 +00:00
|
|
|
@membership.update_attribute(:access_level, GroupMember::MASTER)
|
2014-06-17 18:36:40 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not send an email when the access level has not changed" do
|
|
|
|
@membership.should_not_receive(:notification_service)
|
2014-09-15 08:36:50 +00:00
|
|
|
@membership.update_attribute(:access_level, GroupMember::OWNER)
|
2014-06-17 18:36:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-06-17 10:07:16 +00:00
|
|
|
end
|