gitlab-org--gitlab-foss/spec/models/group_member_spec.rb

45 lines
1.4 KiB
Ruby
Raw Normal View History

2013-06-19 08:40:33 -04:00
# == Schema Information
#
# Table name: group_members
2013-06-19 08:40:33 -04:00
#
2013-08-21 05:34:02 -04:00
# id :integer not null, primary key
# group_access :integer not null
# group_id :integer not null
# user_id :integer not null
# created_at :datetime
# updated_at :datetime
2013-08-21 05:34:02 -04:00
# notification_level :integer default(3), not null
2013-06-19 08:40:33 -04:00
#
require 'spec_helper'
describe GroupMember do
2014-06-17 14:36:40 -04:00
context 'notification' do
describe "#after_create" do
it "should send email to user" do
membership = build(:users_group)
membership.stub(notification_service: double('NotificationService').as_null_object)
membership.should_receive(:notification_service)
membership.save
end
end
describe "#after_update" do
before do
@membership = create :users_group
@membership.stub(notification_service: double('NotificationService').as_null_object)
end
it "should send email to user" do
@membership.should_receive(:notification_service)
@membership.update_attribute(:group_access, GroupMember::MASTER)
2014-06-17 14:36:40 -04:00
end
it "does not send an email when the access level has not changed" do
@membership.should_not_receive(:notification_service)
@membership.update_attribute(:group_access, GroupMember::OWNER)
2014-06-17 14:36:40 -04:00
end
end
end
end