File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
app/controllers/api_public/v1
spec/requests/api_public/v1 Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 77 locale = params [ :locale ] || I18n . default_locale
88 I18n . locale = locale
99 # Use listed_properties (materialized view) instead of deprecated props
10- property = Pwb::Current.website.listed_properties.find(params[:id])
10+ scope = Pwb ::Current . website . listed_properties
11+ property = scope . find_by ( slug : params [ :id ] ) || scope . find_by ( id : params [ :id ] )
12+ raise ActiveRecord ::RecordNotFound unless property
1113 render json : property . as_json
1214 rescue ActiveRecord ::RecordNotFound
1315 render json : { error : "Property not found" } , status : :not_found
Original file line number Diff line number Diff line change 2121 expect(json["id"]).to eq(realty_asset.id)
2222 end
2323
24+ it "returns the property by slug" do
25+ host! 'properties-test.example.com'
26+ get "/api_public/v1/properties/#{realty_asset.slug}"
27+ expect(response).to have_http_status(200)
28+ json = response.parsed_body
29+ expect(json["id"]).to eq(realty_asset.id)
30+ end
31+
2432 it "returns 404 for non-existent property" do
2533 host! 'properties-test.example.com'
2634 get "/api_public/v1/properties/00000000-0000-0000-0000-000000000000"
You can’t perform that action at this time.
0 commit comments