summaryrefslogtreecommitdiff
path: root/spec/decorators/models/solidus_subscriptions/spree/user/have_many_subscriptions_spec.rb
blob: f15afbe622cbe7c9747887dde83fe871e0cfe475 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe SolidusSubscriptions::Spree::User::HaveManySubscriptions, type: :model do
  subject { Spree::User.new }

  it { is_expected.to have_many :subscriptions }
  it { is_expected.to accept_nested_attributes_for :subscriptions }

  describe '#subscriptions_attributes=' do
    it 'throws a deprecation warning' do
      allow(::Spree::Deprecation).to receive(:warn)

      subject.subscriptions_attributes = [{ interval_length: 2 }]

      expect(::Spree::Deprecation)
        .to have_received(:warn)
        .with(/Creating or updating subscriptions through Spree::User nested attributes is deprecated/)
    end
  end
end