Sha256: 71df0adbddccdce127ccffdcd025591214331bc67e37e3f154feb29818c656c8

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

describe Commands::Groups::Group::List do
  is_required :application_id
  is_optional :account_id, :created_by, :is_account_group, :page, :page_size

  before do
    @groups = create_list(:group, 5)
  end

  context 'listing groups' do
    let(:response) { subject.class.run(params) }

    context ':application_id' do
      before { create_list(:group, 3, application_id: 123) }

      context 'valid' do
        let(:params) { { application_id: 123 } }
        it 'returns groups' do
          response.result[:meta][:groups][:count].should == 3
        end
      end

      context 'invalid' do
        let(:params) { { application_id: 999999 } }
        it 'returns no groups' do
          response.result[:meta][:groups][:count].should == 0
        end
      end

      pending ':application_id is required'
    end

    context ':account_id' do
      before do
        create_list(:group, 2, application_id: 123)
        create_list(:group, 2, application_id: 123, account_id: 345)
      end

      context 'valid' do
        let(:params) { { application_id: 123, account_id: 345 } }
        it 'returns groups' do
          response.result[:meta][:groups][:count].should == 2
        end
      end

      context 'invalid' do
        let(:params) { { application_id: 123, account_id: 999999 } }
        it 'returns no groups' do
          response.result[:meta][:groups][:count].should == 0
        end
      end

      context ':is_account_group' do
        let(:params) { { application_id: 123, is_account_group: true } }
        it 'returns groups that have an account' do
          response.result[:meta][:groups][:count].should == 2
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack_group_service-0.0.8 spec/commands/group/list_spec.rb