Sha256: 039a8042ad1c7dae7c007e23dbf2672850b4b189d89b8e97e44b9bf399b779f6

Contents?: true

Size: 1.38 KB

Versions: 8

Compression:

Stored size: 1.38 KB

Contents

require 'rails_helper'

shared_examples_for "Wupee::Receiver" do
  let(:model) { described_class }

  it "has many notifications" do
    expect(model.new).to respond_to(:notifications)
  end

  it "has many notification_type_configurations" do
    expect(model.new).to respond_to(:notification_type_configurations)
  end

  it "destroys notification on destroy" do
    receiver = create model.name.underscore
    create :notification, receiver: receiver
    expect { receiver.destroy }.to change { Wupee::Notification.count }.by(-1)
  end

  it "destroys notification_type_configurations on destroy" do
    receiver = create model.name.underscore
    Wupee::NotificationTypeConfiguration.create(receiver: receiver, notification_type: Wupee::NotificationType.create(name: 'abc'))
    expect { receiver.destroy }.to change { Wupee::NotificationTypeConfiguration.count }.by(-1)
  end

  context "there are already notification type created" do
    it "has no notification_type_configurations associated to notification_type" do
      expect(Wupee::NotificationTypeConfiguration.count).to eq 0
    end

    it "creates notification_type_configurations after model is created" do
      create :notification_type
      expect { create model.name.underscore }.to change { Wupee::NotificationTypeConfiguration.count }.by(1)
      expect(Wupee::NotificationTypeConfiguration.last.receiver).to eq model.last
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wupee-1.1.4 spec/models/concerns/receiver_spec.rb
wupee-1.1.3 spec/models/concerns/receiver_spec.rb
wupee-1.1.2 spec/models/concerns/receiver_spec.rb
wupee-1.0.4 spec/models/concerns/receiver_spec.rb
wupee-1.0.3 spec/models/concerns/receiver_spec.rb
wupee-1.0.2 spec/models/concerns/receiver_spec.rb
wupee-1.0.1 spec/models/concerns/receiver_spec.rb
wupee-1.0.0 spec/models/concerns/receiver_spec.rb