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

55 lines
1.6 KiB
Ruby
Raw Normal View History

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
# access_level :integer not null
2014-10-09 15:22:20 +00:00
# source_id :integer not null
# source_type :string(255) not null
2015-05-03 16:05:38 +00:00
# user_id :integer
2014-10-09 15:22:20 +00:00
# notification_level :integer not null
# type :string(255)
# created_at :datetime
# updated_at :datetime
2015-05-03 16:05:38 +00:00
# created_by_id :integer
# invite_email :string(255)
# invite_token :string(255)
# invite_accepted_at :datetime
2013-06-19 12:40:33 +00:00
#
require 'spec_helper'
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
membership = build(:group_member)
2015-05-21 21:49:06 +00:00
allow(membership).to receive(:notification_service).
and_return(double('NotificationService').as_null_object)
expect(membership).to receive(:notification_service)
2015-05-21 21:49:06 +00:00
2014-06-17 18:36:40 +00:00
membership.save
end
end
describe "#after_update" do
before do
@group_member = create :group_member
2015-05-21 21:49:06 +00:00
allow(@group_member).to receive(:notification_service).
and_return(double('NotificationService').as_null_object)
2014-06-17 18:36:40 +00:00
end
it "should send email to user" do
expect(@group_member).to receive(:notification_service)
@group_member.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
expect(@group_member).not_to receive(:notification_service)
@group_member.update_attribute(:access_level, GroupMember::OWNER)
2014-06-17 18:36:40 +00:00
end
end
end
end