This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

group_member_spec.rb 1.35 KB
Newer Older
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
1
2
# == Schema Information
#
3
# Table name: group_members
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
4
#
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
5
6
7
8
#  id                 :integer          not null, primary key
#  group_access       :integer          not null
#  group_id           :integer          not null
#  user_id            :integer          not null
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
9
10
#  created_at         :datetime
#  updated_at         :datetime
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
11
#  notification_level :integer          default(3), not null
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
12
13
#

14
15
require 'spec_helper'

16
describe GroupMember do
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  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)
35
        @membership.update_attribute(:group_access, GroupMember::MASTER)
36
37
38
39
      end

      it "does not send an email when the access level has not changed" do
        @membership.should_not_receive(:notification_service)
40
        @membership.update_attribute(:group_access, GroupMember::OWNER)
41
42
43
      end
    end
  end
44
end