Sha256: 4cdb09a6bbfd9347278859e01e57a6c4c48dd3973240d09c890f1947dbb2d9ca

Contents?: true

Size: 1.43 KB

Versions: 10

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Notifiable::LocalizedNotification do

  describe "#locale" do
    subject!(:l) { create(:localized_notification, :locale => 'en') }
    
    it { expect(Notifiable::LocalizedNotification.first.locale).to eq 'en' }
  end
  
  describe "#message" do
    context "valid" do
      subject!(:l) { create(:localized_notification, :message => "Test message") }
    
      it { expect(Notifiable::LocalizedNotification.first.message).to eq "Test message" }
    end
    
    context "empty" do
      subject!(:l) { build(:localized_notification, :message => nil) } 
           
      it { expect{ l.save! }.to raise_error ActiveRecord::RecordInvalid }      
    end
  end
  
  describe "#params" do
    subject!(:l) { create(:localized_notification, :params => {:custom_property => "A different message"}) }
    
    it { expect(Notifiable::LocalizedNotification.first.params).to eq({:custom_property => "A different message"}) }
  end
  
  describe "#notification" do
    let(:n) {create(:notification)}
    subject!(:l) { create(:localized_notification, :notification => n) }
    
    it { expect(Notifiable::LocalizedNotification.first.notification).to eq n }
  end
  
  describe "#destroy" do
    subject(:l) { create(:localized_notification) }
    let!(:s) { create(:notification_status, :localized_notification => l) }
    
    before(:each) { l.destroy }
    
    it { expect(Notifiable::NotificationStatus.count).to eq 0 }
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
notifiable-rails-0.24.3 spec/model/localized_notification_spec.rb
notifiable-rails-0.24.2 spec/model/localized_notification_spec.rb
notifiable-rails-0.24.1 spec/model/localized_notification_spec.rb
notifiable-rails-0.24.0 spec/model/localized_notification_spec.rb
notifiable-rails-0.23.0 spec/model/localized_notification_spec.rb
notifiable-rails-0.22.1 spec/model/localized_notification_spec.rb
notifiable-rails-0.22.0 spec/model/localized_notification_spec.rb
notifiable-rails-0.21.3 spec/model/localized_notification_spec.rb
notifiable-rails-0.21.2 spec/model/localized_notification_spec.rb
notifiable-rails-0.21.1 spec/model/localized_notification_spec.rb