Sha256: 55f9169393b445cc74ed05aa86fa4ea1ff512e6cad62f58db8349235442bab84

Contents?: true

Size: 1.82 KB

Versions: 45

Compression:

Stored size: 1.82 KB

Contents

require "rails_helper"

RSpec.describe ::Dorsale::CustomerVault::PeopleController, type: :controller do
  routes { Dorsale::Engine.routes }
  let(:user) { create(:user) }
  describe "#index" do
    it "should redirect to activity" do
      get :index
      expect(response).to redirect_to customer_vault_people_activity_path
    end
  end

  describe '#list' do
    describe 'sorting' do
      let!(:alice) {
        create(:customer_vault_individual, first_name: 'Alice', last_name: 'Zarston')
      }

      let!(:bob) {
        create(:customer_vault_individual, first_name: 'Bob', last_name: 'Tilan')
      }

      let!(:corporation) {
        create(:customer_vault_corporation, name: 'Zorg Corp')
      }


      it 'should sort people by name by default' do
        get :list
        expect(assigns(:people)).to eq([bob, alice, corporation])
      end
    end

    describe "search" do
      it "search should ignore filters" do
        corporation1 = create(:customer_vault_corporation, tag_list: "abc", name: "aaa")
        corporation2 = create(:customer_vault_corporation, tag_list: "xyz", name: "bbb")
        @request.cookies["filters"] = {tags: ["abc"]}.to_json
        get :list, q: "bbb"
        expect(assigns(:people)).to eq [corporation2]
      end
    end
  end

  describe "activity" do
    before do
      @person = create(:customer_vault_corporation)
      @comment1 = @person.comments.create!(text: "ABC", created_at: Time.now - 3.days, author: user)
      @comment2 = @person.comments.create!(text: "DEF", created_at: Time.now - 2.days, author: user)
      @comment3 = @person.comments.create!(text: "DEF", created_at: Time.now - 9.days, author: user)
    end

    it "should assigns all comments ordered by created_at DESC" do
      get :activity
      expect(assigns(:comments)).to eq [@comment2, @comment1, @comment3]
    end
  end

end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
dorsale-2.6.1 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.6.0 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.5.0 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.4.3 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.4.2 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.4.1 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.4.0 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.3.5 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.3.4 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.3.3 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.3.2 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.3.1 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.3.0 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.2.16 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.2.15 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.2.14 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.2.13 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.2.12 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.2.11 spec/controllers/dorsale/customer_vault/people_controller_spec.rb
dorsale-2.2.10 spec/controllers/dorsale/customer_vault/people_controller_spec.rb