Sha256: b464dd1eb4ede4bf053795f2e67abeb3e3641edd77e521eeb538fd159627138b

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'rails_helper'

RSpec.describe Wupee::NotificationType, type: :model do
  let!(:receiver) { create :user }
  let!(:notification_type_name) { 'notify_new_message' }
  let!(:notification_type) { create :notification_type, name: notification_type_name }
  let!(:notification) { create :notification, notification_type: notification_type, receiver: receiver }

  context "validations" do
    it "validates presence of name" do
      notification_type = Wupee::NotificationType.new
      notification_type.valid?
      expect(notification_type.errors).to have_key :name
    end

    it "validates presence of uniqueness of name" do
      notification_type = Wupee::NotificationType.new(name: notification_type_name)
      notification_type.valid?
      expect(notification_type.errors).to have_key :name
    end
  end

  context "methods" do
    it "responds to notifications" do
      expect(notification_type).to respond_to(:notifications)
    end
  end

  context "associations" do
    it "destroys notifications on destroy" do
      expect { notification_type.destroy! }.to change { Wupee::Notification.count }.by(-1)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wupee-2.0.0.beta2 spec/models/notification_type_spec.rb
wupee-2.0.0.beta1 spec/models/notification_type_spec.rb