Sha256: e77c293448a322c839f40e6e47799af159ac90f2aad2938fac8e73426dc022df

Contents?: true

Size: 821 Bytes

Versions: 2

Compression:

Stored size: 821 Bytes

Contents

require "spec_helper"

RSpec.describe Spree::Admin::UsersController, type: :controller do
  let(:user) { mock_model(Spree::User) }
  let(:favorite_product) { mock_model(Spree::Product) }
  let(:favorite_products) { double(ActiveRecord::Relation) }

  describe 'favorite_products' do
    stub_authorization!

    def send_request
      get :favorite_products, params: { id: user.id }
    end


    before do
      allow(Spree::User).to receive(:find).and_return(user)
      allow(user).to receive(:favorite_products).and_return(favorite_products)
      allow(favorite_products).to receive_message_chain(:page, :per).and_return(favorite_products)
    end

    it 'is expected to set favorite_products' do
      expect(user).to receive(:favorite_products).and_return(favorite_products)
      send_request
    end

  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
spree_favorite_products-3.2.0 spec/controllers/spree/admin/users_controller_decorator_spec.rb
solidus_favorite_products-2.1.1 spec/controllers/spree/admin/users_controller_decorator_spec.rb