diff --git a/lib/pact_broker/matrix/parse_query.rb b/lib/pact_broker/matrix/parse_query.rb index 39d4a0d77..a32988e10 100644 --- a/lib/pact_broker/matrix/parse_query.rb +++ b/lib/pact_broker/matrix/parse_query.rb @@ -27,6 +27,8 @@ def self.call query end if params.key?('limit') && params['limit'] != '' options[:limit] = params['limit'] + else + options[:limit] = "100" end if params.key?('latest') && params['latest'] != '' options[:latest] = params['latest'] == 'true' diff --git a/spec/lib/pact_broker/matrix/parse_query_spec.rb b/spec/lib/pact_broker/matrix/parse_query_spec.rb index ec08b8b8e..60cf1a0b2 100644 --- a/spec/lib/pact_broker/matrix/parse_query_spec.rb +++ b/spec/lib/pact_broker/matrix/parse_query_spec.rb @@ -39,22 +39,22 @@ module Matrix context "with no options specified" do let(:query) { "" } - it "does not set any options" do - expect(subject.last).to eq({}) + it "sets the defaults" do + expect(subject.last).to eq(limit: "100") end end context "with just one status specified" do let(:query) { "success=true" } it "extracts the one status" do - expect(subject.last).to eq success: [true] + expect(subject.last).to include success: [true] end end context "with an array of statuses" do let(:query) { "success[]=true&success[]=false&success[]=" } it "extracts the statuses" do - expect(subject.last).to eq success: [true, false, nil] + expect(subject.last).to include success: [true, false, nil] end end @@ -62,7 +62,7 @@ module Matrix let(:query) { "success[]=&foo=bar" } it "sets an array with a nil success" do - expect(subject.last).to eq(success: [nil]) + expect(subject.last).to include success: [nil] end end @@ -70,7 +70,7 @@ module Matrix let(:query) { "success=&foo=bar" } it "sets an array with a nil success" do - expect(subject.last).to eq(success: [nil]) + expect(subject.last).to include success: [nil] end end @@ -86,7 +86,7 @@ module Matrix let(:query) { "q[][pacticipant]=Foo&latest=true" } it "returns options with latest true" do - expect(subject.last).to eq latest: true + expect(subject.last).to include latest: true end end @@ -105,6 +105,14 @@ module Matrix expect(subject.first).to eq [{ pacticipant_name: 'Foo', tag: 'prod' }] end end + + context "when a limit is specified" do + let(:query) { "limit=200" } + + it "sets the limit" do + expect(subject.last[:limit]).to eq "200" + end + end end end end