Sha256: e5fa7d3bff9dd1492fd2fca878c09e2eaa8c9c9e0055867bd76b67f32fc512b9

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

require 'rails_helper'

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

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

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

  it 'should be able to be marked as read' do
    notification = create :notification
    notification.mark_as_read
    expect(notification.is_read).to eq true
  end

  it 'should be able to be marked as sent' do
    notification = create :notification
    notification.mark_as_sent
    expect(notification.is_sent).to eq true
  end

  context "default values" do
    it { expect(create(:notification).is_read).to be false }
    it { expect(create(:notification).is_sent).to be false }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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