Sha256: 88adbe702a9d63f836b85ee4f12a661503a5c0c9af62f2349bceb83cbfdce158

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe Spree::Admin::PromotionsController, :type => :controller do
  stub_authorization!

  let!(:promotion1) { create(:promotion, name: "name1", code: "code1", path: "path1") }
  let!(:promotion2) { create(:promotion, name: "name2", code: "code2", path: "path2") }
  let!(:category) { create :promotion_category }

  context "#index" do
    it "succeeds" do
      spree_get :index
      expect(assigns[:promotions]).to match_array [promotion2, promotion1]
    end

    it "assigns promotion categories" do
      spree_get :index
      expect(assigns[:promotion_categories]).to match_array [category]
    end

    context "search" do
      it "pages results" do
        spree_get :index, per_page: '1'
        expect(assigns[:promotions]).to eq [promotion2]
      end

      it "filters by name" do
        spree_get :index, q: {name_cont: promotion1.name}
        expect(assigns[:promotions]).to eq [promotion1]
      end

      it "filters by code" do
        spree_get :index, q: {code_cont: promotion1.code}
        expect(assigns[:promotions]).to eq [promotion1]
      end

      it "filters by path" do
        spree_get :index, q: {path_cont: promotion1.path}
        expect(assigns[:promotions]).to eq [promotion1]
      end
    end
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spree_backend-3.1.5 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.1.4 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.1.3 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.1.2 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.0.10 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.1.1 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.1.0 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.1.0.rc4 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.0.9 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.1.0.rc3 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.1.0.rc2 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.1.0.rc1 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.0.8 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.0.7 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.0.6.1 spec/controllers/spree/admin/promotions_controller_spec.rb
spree_backend-3.0.6 spec/controllers/spree/admin/promotions_controller_spec.rb