Skip to content

Commit bf37cdf

Browse files
authored
fix: broken SQL in pacticipants_for_label resource (#944)
1 parent 360881c commit bf37cdf

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/pact_broker/pacticipants/repository.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def find(options = {}, pagination_options = {}, eager_load_associations = [])
4141
return [] if query.empty?
4242

4343
query = query.select_all_qualified
44-
query = query.filter(:name, options[:query_string]) if options[:query_string]
44+
query = query.filter(Sequel[:pacticipants][:name], options[:query_string]) if options[:query_string]
4545
query = query.label(options[:label_name]) if options[:label_name]
4646
query.order_ignore_case(Sequel[:pacticipants][:name]).eager(*eager_load_associations).all_with_pagination_options(pagination_options)
4747
end

spec/lib/pact_broker/pacticipants/repository_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ module Pacticipants
111111
end
112112
end
113113

114+
context "with label_name and search query" do
115+
subject { Repository.new.find label_name: "in", query_string: "oo" }
116+
117+
it "returns only the pacticipants matching both the label and the query string" do
118+
expect(subject.collect(&:name)).to eq ["Foo"]
119+
end
120+
end
121+
114122
context "when scope applied" do
115123
it "returns the pacticipants if scope allows" do
116124
allow_any_instance_of(Repository).to receive(:scope_for).and_return(PactBroker::Domain::Pacticipant) # default, with no scope applied

0 commit comments

Comments
 (0)