Skip to content

Commit

Permalink
Remove unnecessary search method and agreement spec code
Browse files Browse the repository at this point in the history
  • Loading branch information
RobNicholsGDS committed Jan 7, 2025
1 parent ba8119f commit 8946b96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
4 changes: 0 additions & 4 deletions app/models/data_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ def data_from_source
air_table_data_source? ? data_from_air_table : data_from_rapid
end

def search(text)
search_via_air_table(text)
end

private

def is_draft?(record)
Expand Down
44 changes: 6 additions & 38 deletions spec/models/agreement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
describe ".populate" do # Note that most populate behavior is tested in the shared example 'is_data_table'
subject(:populate) { described_class.populate }

context "with rAPId source" do
let(:controller_name) { Faker::Name.name }
before do
allow(Rails.configuration).to receive(:data_source).and_return(:rapid)
expect(RapidApi).to receive(:output_for).with(described_class.rapid_table_name).and_return(data)
end

context "with duplicate ids" do
let(:id) { rand(0..1).to_s }
let(:data) do
{
Expand All @@ -24,11 +28,6 @@
}
end

before do
allow(Rails.configuration).to receive(:data_source).and_return(:rapid)
expect(RapidApi).to receive(:output_for).with(described_class.rapid_table_name).and_return(data)
end

it "assumes id is unique and does not create duplicates" do
expect { populate }.to change(described_class, :count).by(1)
end
Expand All @@ -40,37 +39,6 @@
end
end

# make sure a base exists to avoid callout for base
let!(:air_table_base) { create :air_table_base }
let(:base_id) { AirTableBase.base_id }

# There needs to be an air table table object to look up the table id
let!(:air_table_table) { create :air_table_table, name: described_class.air_table_name }
let(:table_id) { air_table_table.record_id }

describe ".search" do
let!(:agreement) { create :agreement, name: "it is all foo bar" }
let!(:other) { create :agreement, name: "something else" }
let(:data) do
{ records: [{ id: agreement.record_id }] }
end
let(:query) do
{ "filterByFormula" => "SEARCH(\"foo\",{Name})" }
end

before do
expect(AirTableApi).to receive(:data_for).with("#{base_id}/#{table_id}", query:).and_return(data)
end

it "returns records that match the query" do
expect(described_class.search("foo")).to include(agreement)
end

it "does not return records that do not match the query" do
expect(described_class.search("foo")).not_to include(other)
end
end

describe "#id_and_name" do
let(:agreement) { create :agreement, name: "Foo", fields: { id: "5" } }

Expand Down

0 comments on commit 8946b96

Please sign in to comment.