Skip to content

Commit e454b3e

Browse files
committed
Merge branch 'develop'
2 parents c280cdf + a227a9b commit e454b3e

29 files changed

+278
-67
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
.ruby-version
2626
.rspec
2727
Guardfile
28+
coverage

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ gem 'figaro'
3030
gem 'active_model_serializers'
3131
gem 'coveralls', require: false
3232

33+
# Async backgroun job handling
34+
gem 'sidekiq'
35+
3336
group :test do
3437
gem 'ffaker'
3538
gem 'database_cleaner'
3639
gem 'launchy'
3740
gem 'capybara'
38-
gem 'selenium-webdriver'
41+
gem 'selenium-webdriver', "~> 2.38.0"
3942
end
4043

4144
group :development,:test do

Gemfile.lock

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ GEM
5555
activemodel (>= 3.2.0)
5656
activesupport (>= 3.2.0)
5757
json (>= 1.7)
58-
childprocess (0.3.9)
58+
celluloid (0.15.2)
59+
timers (~> 1.1.0)
60+
childprocess (0.5.1)
5961
ffi (~> 1.0, >= 1.0.11)
6062
chunky_png (1.2.8)
6163
coderay (1.1.0)
@@ -73,6 +75,7 @@ GEM
7375
sass (~> 3.1)
7476
compass-rails (1.0.3)
7577
compass (>= 0.12.2, < 0.14)
78+
connection_pool (1.2.0)
7679
coveralls (0.7.0)
7780
multi_json (~> 1.3)
7881
rest-client
@@ -255,6 +258,9 @@ GEM
255258
ffi (>= 0.5.0)
256259
rdoc (3.12.2)
257260
json (~> 1.4)
261+
redis (3.0.7)
262+
redis-namespace (1.4.1)
263+
redis (~> 3.0.4)
258264
rest-client (1.6.7)
259265
mime-types (>= 1.16)
260266
rspec-core (2.14.5)
@@ -269,24 +275,30 @@ GEM
269275
rspec-expectations (~> 2.14.0)
270276
rspec-mocks (~> 2.14.0)
271277
ruby-hmac (0.4.0)
272-
rubyzip (0.9.9)
278+
rubyzip (1.1.0)
273279
sass (3.2.10)
274280
sass-rails (3.2.6)
275281
railties (~> 3.2.0)
276282
sass (>= 3.1.10)
277283
tilt (~> 1.3)
278284
sassy-math (1.5)
279285
compass (~> 0.11)
280-
selenium-webdriver (2.35.1)
286+
selenium-webdriver (2.38.0)
281287
childprocess (>= 0.2.5)
282288
multi_json (~> 1.0)
283-
rubyzip (< 1.0.0)
289+
rubyzip (~> 1.0)
284290
websocket (~> 1.0.4)
285291
sendgrid (1.2.0)
286292
json
287293
json
288294
shoulda-matchers (2.3.0)
289295
activesupport (>= 3.0.0)
296+
sidekiq (2.17.5)
297+
celluloid (>= 0.15.2)
298+
connection_pool (>= 1.0.0)
299+
json
300+
redis (>= 3.0.6)
301+
redis-namespace (>= 1.3.1)
290302
simple_oauth (0.2.0)
291303
simplecov (0.8.2)
292304
docile (~> 1.1.0)
@@ -311,6 +323,7 @@ GEM
311323
activerecord
312324
statistics2
313325
tilt (1.4.1)
326+
timers (1.1.0)
314327
tins (0.13.1)
315328
treetop (1.4.15)
316329
polyglot
@@ -381,9 +394,10 @@ DEPENDENCIES
381394
ransack
382395
rspec-rails
383396
sass-rails (~> 3.2.3)
384-
selenium-webdriver
397+
selenium-webdriver (~> 2.38.0)
385398
sendgrid
386399
shoulda-matchers
400+
sidekiq
387401
thin
388402
thumbs_up
389403
twitter

Procfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
2-

README.en.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ based on the [Open 311](http://open311.org) standard.
1818
- Rails 3.2
1919
- Bootstrap 3.0
2020
- Rspec 2.14
21+
- Redis 2.8.6
2122

2223
### Questions?
2324

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ de la comunicación con la ciudadanía y los reportes de cuestiones en sus servi
2121
- Rails 3.2
2222
- Bootstrap 3.0
2323
- Rspec 2.14
24+
- Redis 2.8.6
2425

2526
### ¿Dudas?
2627

app/assets/javascripts/geolocate_map/geolocateMap.js.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class window.GeolocateMap
2525
@jq_address_field.on 'change', =>
2626
@map.validates_address_text @jq_address_field.val(), (result, is_valid) =>
2727
if is_valid
28-
@map.marker.setPosition(result.geometry.location)
28+
@map.update_marker_position(result.geometry.location)
2929
@_update_lat_and_lng_from_marker()
3030
else
3131
@_rollback_to_last_valid_address()

app/assets/javascripts/geolocate_map/map.js.coffee

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class GeolocateMap.Map
3535
else
3636
cb(undefined, false)
3737

38+
update_marker_position: (position) ->
39+
@marker.setPosition(position)
40+
@_zoom_on_marker()
41+
42+
_zoom_on_marker: ->
43+
@g_map.setZoom(17);
44+
@g_map.panTo(@marker.getPosition());
45+
3846
_add_listener_for_map_drag_end: ->
3947
google.maps.event.addListener @g_map, 'dragend', =>
4048
@reset_to_center unless @validates_position(@g_map.getCenter())
@@ -48,6 +56,7 @@ class GeolocateMap.Map
4856
mapTypeId: google.maps.MapTypeId.ROADMAP
4957
scaleControl: true
5058
html5: false
59+
zoom: 15
5160
}, @_options)
5261

5362
_build_marker_on_center: ->
@@ -65,6 +74,7 @@ class GeolocateMap.Map
6574
if @validates_position(latLng)
6675
@marker.setPosition(latLng)
6776
@g_map.setCenter(latLng)
77+
@_zoom_on_marker()
6878
$(window).trigger('first_location')
6979
),
7080
((msg) ->

app/mailers/user_mailer.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class UserMailer < ActionMailer::Base
2+
default from: ENV['MAILER_FROM'] || 'Urbem <[email protected]>'
3+
4+
def notify_service_request_status_change(service_request_id, previous_status_id)
5+
@service_request = ServiceRequest.find(service_request_id)
6+
@user = @service_request.requester
7+
@previous_status = Status.find(previous_status_id)
8+
mail(subject: I18n.t('mailer.subject.status_change_notification'), to: @user.email)
9+
end
10+
11+
end
12+

app/models/service_request.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ServiceRequest < ActiveRecord::Base
1010
validate :service_extra_fields
1111

1212
before_validation :assign_default_status, on: :create
13+
after_update :send_notification_for_status_update
1314

1415
belongs_to :service
1516
belongs_to :requester, polymorphic: true
@@ -106,6 +107,11 @@ def service_fields_hash
106107
end
107108
end
108109

110+
def requested_by_user?
111+
self.requester_type == 'User'
112+
end
113+
114+
109115
ransacker :date do |parent|
110116
Arel::Nodes::InfixOperation.new('||',
111117
Arel::Nodes::InfixOperation.new('||', parent.table[:created_at], ' '), parent.table[:created_at])
@@ -123,4 +129,10 @@ def assign_default_status
123129
self.status = Status.where(is_default: true).first
124130
end
125131

132+
def send_notification_for_status_update
133+
if self.requested_by_user? && self.status_id_changed?
134+
UserMailer.delay.notify_service_request_status_change(self.id, self.status_id_was)
135+
end
136+
end
137+
126138
end

0 commit comments

Comments
 (0)