Sha256: d373641a41ba17c71fdd20d5b46389451b7e82d9981e5b1b167aaf36a371d3b7

Contents?: true

Size: 1.64 KB

Versions: 9

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe BaseCRM::LineItemsService do
  before(:all) do
    @product = create(:product)
    @order = create_order
  end
  describe 'Responds to' do
    subject { client.line_items  }

    it { should respond_to :all }
    it { should respond_to :create }
    it { should respond_to :destroy }
    it { should respond_to :find }
    it { should respond_to :where }
  end

  describe :all do
    it "returns a PaginatedResource" do
      order_id = create_order.id
      expect(client.line_items.all(order_id)).to be_instance_of BaseCRM::PaginatedResource
    end
  end

  describe :where do
    it "returns an array" do
      order_id = create_order.id
      expect(client.line_items.where(order_id, page: 1)).to be_an Array
    end
  end

  describe :create do
    it "returns instance of LineItem class" do
      order_id = create_order.id
      @line_item = build(:line_item, product_id: @product.id, order_id: @order.id)
      expect(client.line_items.create(order_id, @line_item)).to be_instance_of BaseCRM::LineItem
    end
  end

  describe :find do
    before :each do
      @line_item = create(:line_item, product_id: @product.id, order_id: @order.id)
    end

    it "returns an instance of LineItem class" do
      expect(client.line_items.find(@order.id, @line_item.id)).to be_instance_of BaseCRM::LineItem
    end
  end

  describe :destroy do
    it "returns true on success" do
      @line_item = create(:line_item, product_id: @product.id, order_id: @order.id)
      expect(client.line_items.destroy(@order.id, @line_item.id)).to be_truthy
    end
  end

  def create_order
    deal = create(:deal)
    create(:order, deal_id: deal.id)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
basecrm-2.0.0 spec/services/line_items_service_spec.rb
basecrm-1.3.10 spec/services/line_items_service_spec.rb
basecrm-1.3.9 spec/services/line_items_service_spec.rb
basecrm-1.3.8 spec/services/line_items_service_spec.rb
basecrm-1.3.7 spec/services/line_items_service_spec.rb
basecrm-1.3.6 spec/services/line_items_service_spec.rb
basecrm-1.3.5 spec/services/line_items_service_spec.rb
basecrm-1.3.4 spec/services/line_items_service_spec.rb
basecrm-1.3.3 spec/services/line_items_service_spec.rb