Sha256: 58871f8ea8b5029daea2e52e706bbaead3145cf334ec585e54bc2be9402a46e1

Contents?: true

Size: 1.76 KB

Versions: 8

Compression:

Stored size: 1.76 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

  # it '#deliver_now should send a mail' do
  #   notification = Wupee::Notification.new.send_notification(type: notification_type_name, attached_object: message)
  #                                  .to(receiver)
  #   expect(notification.deliver_now).to be_a(Mail::Message)
  # end
  #
  # it '#deliver_later should send later a mail' do
  #   notification = Wupee::Notification.new.send_notification(type: notification_type_name, attached_object: message)
  #                                  .to(receiver)
  #   expect(notification.deliver_later).to be_a(ActionMailer::DeliveryJob)
  # end
  #


end

Version data entries

8 entries across 8 versions & 1 rubygems

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