Skip to content

Commit

Permalink
fix: default matrix limit for /matrix/provider/PROVIDER/consumer/CONS…
Browse files Browse the repository at this point in the history
…UMER endpoint to 100
  • Loading branch information
bethesque committed May 20, 2019
1 parent a37ff49 commit 7ccc9b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions lib/pact_broker/matrix/parse_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
22 changes: 15 additions & 7 deletions spec/lib/pact_broker/matrix/parse_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,38 @@ 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

context "with success[]=" do
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

context "with success=" do
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

Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 7ccc9b6

Please sign in to comment.