Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
modify to api return a places URL
Browse files Browse the repository at this point in the history
  • Loading branch information
y-yagi committed Jul 4, 2015
1 parent b592ff6 commit b0403a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/models/api/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ module Api::Place
property :latitude
property :longitude
property :station_info
property :url

def station_info
places_station.each.sum do |ns|
"#{ns.station.line} #{ns.station.name}#{ns.distance}\n"
end
end

def url
urls.try(:join, ",").to_s
end
end
end
1 change: 1 addition & 0 deletions test/controllers/api/v1/travels_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class Api::V1::TravelsControllerTest < ActionController::TestCase
actual_place = parsed_response_body['travel_dates'].first['schedules'].first['place']
assert_equal expected_place.name, actual_place['name']
assert_equal expected_place.address, actual_place['address']
assert_equal expected_place.urls.join(','), actual_place['url']
assert_match expected_place.places_station.first.station.name, actual_place['station_info']
end
end
4 changes: 4 additions & 0 deletions test/fixtures/places.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ kifune:
latitude: 35.07182
longitude: 135.45462
user: google
urls:
- http://kifunejinja.jp/

shimogamo:
name: 下鴨神社
address: 京都府京都市 左京区下鴨泉川町59
latitude: 35.07182
longitude: 135.45462
user: google
urls:
- http://www.shimogamo-jinja.or.jp/

<% 10.times.each do |i| %>
places_<%= i %>:
Expand Down

0 comments on commit b0403a4

Please sign in to comment.