Sha256: 02acf4bfc43f757f8af3def20b3bda1867d8a6fbb0c2e019aa765b0f723713d6

Contents?: true

Size: 1.66 KB

Versions: 8

Compression:

Stored size: 1.66 KB

Contents

require 'rails_helper'

RSpec.describe Wupee::NotificationTypeConfiguration, type: :model do
  let!(:receiver) { create :user }
  let!(:notification_type) { create :notification_type }

  context "validations" do
    it "validates presence of receiver" do
      notification_type_conf = Wupee::NotificationTypeConfiguration.new
      notification_type_conf.valid?
      expect(notification_type_conf.errors).to have_key :receiver
    end

    it "validates presence of notification_type" do
      notification_type_conf = Wupee::NotificationTypeConfiguration.new
      notification_type_conf.valid?
      expect(notification_type_conf.errors).to have_key :notification_type
    end

    it "validates uniqueness of [receiver, notification_type]" do
      notification_type_conf_same = Wupee::NotificationTypeConfiguration.create(receiver: receiver, notification_type: notification_type)
      expect(notification_type_conf_same).to be_invalid
    end
  end

  context "methods" do
    it "has method wants_email?" do
      notification_type_conf = Wupee::NotificationTypeConfiguration.new(value: :both)
      expect(notification_type_conf.wants_email?).to eq true

      notification_type_conf = Wupee::NotificationTypeConfiguration.new(value: :email)
      expect(notification_type_conf.wants_email?).to eq true
    end

    it "has method wants_notification?" do
      notification_type_conf = Wupee::NotificationTypeConfiguration.new(value: :both)
      expect(notification_type_conf.wants_notification?).to eq true

      notification_type_conf = Wupee::NotificationTypeConfiguration.new(value: :notification)
      expect(notification_type_conf.wants_notification?).to eq true
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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