Skip to content

Commit

Permalink
Conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolai-b committed Oct 7, 2015
2 parents 9b5259a + 138b6a6 commit dba0c8a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ gem 'email_reply_parser'
gem 'memoist'
gem 'excon'
gem 'paranoia', '~> 2.0'
gem 'grape'
gem 'grape', github: 'ruby-grape/grape'

gem 'sass-rails', '~> 4.0.3'
gem 'sass'
Expand Down
27 changes: 16 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ GIT
specs:
acts_as_indexed (0.8.3)

GIT
remote: git://github.com/ruby-grape/grape.git
revision: a7e4b2c5155cd9c1249036e87384c345f327a53b
specs:
grape (0.13.1)
activesupport
builder
hashie (>= 2.1.0)
multi_json (>= 1.3.2)
multi_xml (>= 0.5.2)
rack (>= 1.3.0)
rack-accept
rack-mount
virtus (>= 1.0.0)

GEM
remote: http://rubygems.org/
specs:
Expand Down Expand Up @@ -129,16 +144,6 @@ GEM
formtastic (2.3.1)
actionpack (>= 3.0)
fssm (0.2.10)
grape (0.13.0)
activesupport
builder
hashie (>= 2.1.0)
multi_json (>= 1.3.2)
multi_xml (>= 0.5.2)
rack (>= 1.3.0)
rack-accept
rack-mount
virtus (>= 1.0.0)
haml (4.0.6)
tilt
haml-rails (0.9.0)
Expand Down Expand Up @@ -387,7 +392,7 @@ DEPENDENCIES
factory_girl_rails
foreman
formtastic (~> 2.0)
grape
grape!
haml-rails
jquery-rails (~> 3.0.0)
jquery-turbolinks
Expand Down
10 changes: 5 additions & 5 deletions app/api/issue_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ def bbox_from_string(string, factory)
desc 'Returns issues as a GeoJSON collection'
params do
optional :bbox, type: String, desc: 'Four comma-separated coordinates making up the boundary of interest, e.g. "0.11905,52.20791,0.11907,52.20793"'
optional :tags, type: Array, desc: 'An array of tags all the issues must have, e.g. ["taga","tagb"]'
optional :tags, type: Array, desc: 'An array of tags all the issues must have, e.g. ["taga","tagb"]', coerce_with: JSON
optional :end_date, type: Date, desc: 'No issues after the end date are returned'
optional :start_date, type: Date, desc: 'No issues before the start date are returned'
optional :per_page, type: Integer, default: 200, desc: 'The number of issues per page, maximum of 500'
optional :page, type: Integer, desc: 'The page number'
end
get '/issues' do
scope = Issue.all.includes(:created_by, :tags)
scope.intersects_not_covered(bbox_from_string(params[:bbox], Issue.rgeo_factory).to_geometry) if params[:bbox].present?
scope.where_tag_names_in(params[:tags]) if params[:tags]
scope = scope.intersects_not_covered(bbox_from_string(params[:bbox], Issue.rgeo_factory).to_geometry) if params[:bbox].present?
scope = scope.where_tag_names_in(params[:tags]) if params[:tags]
scope = scope.before_date(params[:end_date]) if params[:end_date]
scope = scope.after_date(params[:start_date]) if params[:start_date]
per_page = [params[:per_page], 500].min
issues = scope.paginate(page: params[:page], per_page: per_page)
issues = issues.map { | issue | issue_feature(issue) }
scope = scope.paginate(page: params[:page], per_page: per_page)
issues = scope.map { | issue | issue_feature(issue) }
collection = RGeo::GeoJSON::EntityFactory.new.feature_collection(issues)
RGeo::GeoJSON.encode(collection)
end
Expand Down
5 changes: 3 additions & 2 deletions lib/taggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ def find_by_tag(tag)
end

def where_tag_names_in(tag_names)
if tag_names.present?
joins(:tags).where(tags: {name: tag_names}).group('issues.id').having('COUNT(tags.id)=?', tag_names.size)
if tag_names.present? &&
ids = joins(:tags).where(tags: {name: tag_names}).group('issues.id').having('COUNT(tags.id)=?', tag_names.size)
where(id: ids)
else
none
end
Expand Down
4 changes: 3 additions & 1 deletion spec/api/issue_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
before do
tag = create :tag, name: 'taga'
create :issue_within_quahog, tags: [tag] # location 0.11906 52.20792
get "#{host}/api/issues", bbox: '0.11905,52.20791,0.11907,52.20793', tags: ["taga"]
create :issue, tags: [tag]
create :issue
get "#{host}/api/issues", bbox: '0.11905,52.20791,0.11907,52.20793', tags: ["taga"].to_json
end

it 'returns issue' do
Expand Down
2 changes: 1 addition & 1 deletion spec/mailers/thread_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
describe 'new document messages' do
it 'has correct text in email' do
subject = described_class.send(:new_document_message, document.message, user)
expect(subject.body).to include(document.file.url)
expect(subject.body).to include("http://www.example.com#{document.file.url}")
expect(subject.body).to include(I18n.t('.thread_mailer.new_document_message.view_the_document'))
expect(subject.to).to include(user.email)
end
Expand Down

0 comments on commit dba0c8a

Please sign in to comment.