From 539774a3c33cb01fa9d2dd89490c4abf60f8d23a Mon Sep 17 00:00:00 2001 From: Juan Pablo Escobar Date: Sat, 28 Feb 2015 01:57:14 -0600 Subject: [PATCH 01/42] Gemfile updated to rails 4.2 --- Gemfile | 23 +- Gemfile.lock | 649 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 415 insertions(+), 257 deletions(-) diff --git a/Gemfile b/Gemfile index 4e4dd480..f9279a24 100644 --- a/Gemfile +++ b/Gemfile @@ -2,10 +2,10 @@ source 'https://rubygems.org' ruby '2.1.5' -gem 'rails', '3.2.16' +gem 'rails', '4.2.0' gem 'pg' -gem 'devise', '2.2.4' +gem 'devise' gem 'nested_form' gem 'geocoder' gem "highcharts-rails", "~> 3.0.0" @@ -63,14 +63,11 @@ group :production do gem 'unicorn' end -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' - gem 'haml-rails' - gem 'compass-rails' - gem "modular-scale", "~> 1.0.6" - gem 'bootstrap-sass', '~> 3.0.0.0.rc' - gem 'uglifier', '>= 1.0.3' -end +# Assets +gem 'sass-rails', '~> 5.0' +gem 'coffee-rails', '~> 4.1.0' +gem 'haml-rails' +gem 'compass-rails' +gem "modular-scale", "~> 1.0.6" +gem 'bootstrap-sass', '~> 3.0.0.0.rc' +gem 'uglifier', '>= 1.3.0' diff --git a/Gemfile.lock b/Gemfile.lock index dd26cc0e..aad32999 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,287 +1,436 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.16) - actionpack (= 3.2.16) - mail (~> 2.5.4) - actionpack (3.2.16) - activemodel (= 3.2.16) - activesupport (= 3.2.16) - builder (~> 3.0.0) + CFPropertyList (2.3.0) + actionmailer (4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.0) + actionview (= 4.2.0) + activesupport (= 4.2.0) + rack (~> 1.6.0) + rack-test (~> 0.6.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + actionview (4.2.0) + activesupport (= 4.2.0) + builder (~> 3.1) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - active_model_serializers (0.8.1) - activemodel (>= 3.0) - activemodel (3.2.16) - activesupport (= 3.2.16) - builder (~> 3.0.0) - activerecord (3.2.16) - activemodel (= 3.2.16) - activesupport (= 3.2.16) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.16) - activemodel (= 3.2.16) - activesupport (= 3.2.16) - activesupport (3.2.16) - i18n (~> 0.6, >= 0.6.4) - multi_json (~> 1.0) - addressable (2.3.5) - arel (3.0.3) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + active_model_serializers (0.9.3) + activemodel (>= 3.2) + activejob (4.2.0) + activesupport (= 4.2.0) + globalid (>= 0.3.0) + activemodel (4.2.0) + activesupport (= 4.2.0) + builder (~> 3.1) + activerecord (4.2.0) + activemodel (= 4.2.0) + activesupport (= 4.2.0) + arel (~> 6.0) + activesupport (4.2.0) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.3.7) + arel (6.0.0) aws-s3 (0.6.3) builder mime-types xml-simple - bcrypt-ruby (3.1.2) - better_errors (1.0.1) + bcrypt (3.1.10) + better_errors (2.1.1) coderay (>= 1.0.0) erubis (>= 2.6.6) + rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bootstrap-sass (3.0.0.0.rc2) + bootstrap-sass (3.0.0.0) sass (~> 3.2) - builder (3.0.4) + buftok (0.2.0) + builder (3.2.2) byebug (3.5.1) columnize (~> 0.8) debugger-linecache (~> 1.2) slop (~> 3.6) - capybara (2.1.0) + capybara (2.4.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) - carrierwave (0.9.0) + carrierwave (0.10.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) json (>= 1.7) - celluloid (0.15.2) - timers (~> 1.1.0) - childprocess (0.5.1) + mime-types (>= 1.16) + celluloid (0.16.0) + timers (~> 4.0.0) + childprocess (0.5.5) ffi (~> 1.0, >= 1.0.11) - chunky_png (1.2.8) + chunky_png (1.3.4) coderay (1.1.0) - coffee-rails (3.2.2) + coffee-rails (4.1.0) coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.6.3) + coffee-script-source (1.9.1) columnize (0.9.0) - compass (0.12.2) + compass (1.0.3) chunky_png (~> 1.2) - fssm (>= 0.2.7) - sass (~> 3.1) - compass-rails (1.0.3) - compass (>= 0.12.2, < 0.14) - connection_pool (1.2.0) - coveralls (0.7.0) - multi_json (~> 1.3) - rest-client - simplecov (>= 0.7) - term-ansicolor - thor + compass-core (~> 1.0.2) + compass-import-once (~> 1.0.5) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + sass (>= 3.3.13, < 3.5) + compass-core (1.0.3) + multi_json (~> 1.0) + sass (>= 3.3.0, < 3.5) + compass-import-once (1.0.5) + sass (>= 3.2, < 3.5) + compass-rails (2.0.4) + compass (~> 1.0.0) + sass-rails (<= 5.0.1) + sprockets (< 2.13) + connection_pool (2.1.1) + coveralls (0.7.11) + multi_json (~> 1.10) + rest-client (>= 1.6.8, < 2) + simplecov (~> 0.9.1) + term-ansicolor (~> 1.3) + thor (~> 0.19.1) daemons (1.1.9) - database_cleaner (1.1.1) + database_cleaner (1.4.0) debug_inspector (0.0.2) debugger-linecache (1.2.0) - devise (2.2.4) - bcrypt-ruby (~> 3.0) + devise (3.4.1) + bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (~> 3.1) - warden (~> 1.2.1) - diff-lcs (1.2.4) - docile (1.1.2) + railties (>= 3.2.6, < 5) + responders + thread_safe (~> 0.1) + warden (~> 1.2.3) + diff-lcs (1.2.5) + docile (1.1.5) + equalizer (0.0.9) erubis (2.7.0) - eventmachine (1.0.3) - excon (0.25.3) - execjs (2.0.1) - factory_girl (4.2.0) + eventmachine (1.0.7) + excon (0.44.3) + execjs (2.3.0) + factory_girl (4.5.0) activesupport (>= 3.0.0) - factory_girl_rails (4.2.1) - factory_girl (~> 4.2.0) + factory_girl_rails (4.5.0) + factory_girl (~> 4.5.0) railties (>= 3.0.0) - faraday (0.8.8) - multipart-post (~> 1.2.0) - ffaker (1.18.0) - ffi (1.9.0) - figaro (0.7.0) - bundler (~> 1.0) - rails (>= 3, < 5) - fog (1.15.0) + faraday (0.9.1) + multipart-post (>= 1.2, < 3) + ffaker (1.32.1) + ffi (1.9.6) + figaro (1.1.0) + thor (~> 0.14) + fission (0.5.0) + CFPropertyList (~> 2.2) + fog (1.28.0) + fog-atmos + fog-aws (~> 0.0) + fog-brightbox (~> 0.4) + fog-core (~> 1.27, >= 1.27.3) + fog-ecloud + fog-json + fog-profitbricks + fog-radosgw (>= 0.0.2) + fog-riakcs + fog-sakuracloud (>= 0.0.4) + fog-serverlove + fog-softlayer + fog-storm_on_demand + fog-terremark + fog-vmfusion + fog-voxel + fog-xml (~> 0.1.1) + ipaddress (~> 0.5) + nokogiri (~> 1.5, >= 1.5.11) + fog-atmos (0.1.0) + fog-core + fog-xml + fog-aws (0.1.1) + fog-core (~> 1.27) + fog-json (~> 1.0) + fog-xml (~> 0.1) + ipaddress (~> 0.8) + fog-brightbox (0.7.1) + fog-core (~> 1.22) + fog-json + inflecto (~> 0.0.2) + fog-core (1.29.0) builder - excon (~> 0.25.0) - formatador (~> 0.2.0) + excon (~> 0.38) + formatador (~> 0.2) mime-types - multi_json (~> 1.0) net-scp (~> 1.1) net-ssh (>= 2.1.3) - nokogiri (~> 1.5) - ruby-hmac - font-awesome-rails (3.2.1.3) + fog-ecloud (0.0.2) + fog-core + fog-xml + fog-json (1.0.0) + multi_json (~> 1.0) + fog-profitbricks (0.0.1) + fog-core + fog-xml + nokogiri + fog-radosgw (0.0.3) + fog-core (>= 1.21.0) + fog-json + fog-xml (>= 0.0.1) + fog-riakcs (0.1.0) + fog-core + fog-json + fog-xml + fog-sakuracloud (1.0.0) + fog-core + fog-json + fog-serverlove (0.1.1) + fog-core + fog-json + fog-softlayer (0.4.1) + fog-core + fog-json + fog-storm_on_demand (0.1.0) + fog-core + fog-json + fog-terremark (0.0.4) + fog-core + fog-xml + fog-vmfusion (0.0.1) + fission + fog-core + fog-voxel (0.0.2) + fog-core + fog-xml + fog-xml (0.1.1) + fog-core + nokogiri (~> 1.5, >= 1.5.11) + font-awesome-rails (4.3.0.0) railties (>= 3.2, < 5.0) - formatador (0.2.4) - fssm (0.2.10) - geocoder (1.1.8) - gravatar-ultimate (1.0.3) - guard (1.4.0) - listen (>= 0.4.2) - thor (>= 0.14.6) - guard-bundler (1.0.0) + formatador (0.2.5) + geocoder (1.2.7) + globalid (0.3.3) + activesupport (>= 4.1.0) + gravatar-ultimate (2.0.0) + activesupport (>= 2.3.14) + rack + guard (2.12.4) + formatador (>= 0.2.4) + listen (~> 2.7) + lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-bundler (2.1.0) bundler (~> 1.0) - guard (~> 1.1) - guard-pow (1.0.0) - guard (>= 1.1) - haml (4.0.3) + guard (~> 2.2) + guard-compat (~> 1.1) + guard-compat (1.2.1) + guard-pow (2.0.0) + guard (~> 2.0) + haml (4.0.6) tilt - haml-rails (0.4) - actionpack (>= 3.1, < 4.1) - activesupport (>= 3.1, < 4.1) - haml (>= 3.1, < 4.1) - railties (>= 3.1, < 4.1) - hashie (2.0.5) - highcharts-rails (3.0.5) + haml-rails (0.8.2) + actionpack (>= 4.0.1) + activesupport (>= 4.0.1) + haml (>= 3.1, < 5.0) + html2haml (>= 1.0.1) + railties (>= 4.0.1) + hashie (3.4.0) + highcharts-rails (3.0.10) railties (>= 3.1) hike (1.2.3) - httpauth (0.2.0) - i18n (0.6.9) - journey (1.0.4) - jquery-fileupload-rails (0.4.1) + hitimes (1.2.2) + html2haml (2.0.0) + erubis (~> 2.7.0) + haml (~> 4.0.0) + nokogiri (~> 1.6.0) + ruby_parser (~> 3.5) + http (0.6.3) + http_parser.rb (~> 0.6.0) + http_parser.rb (0.6.0) + i18n (0.7.0) + inflecto (0.0.2) + ipaddress (0.8.0) + jquery-fileupload-rails (0.4.4) actionpack (>= 3.1) railties (>= 3.1) - jquery-rails (3.0.4) - railties (>= 3.0, < 5.0) + sass (>= 3.2) + jquery-rails (4.0.3) + rails-dom-testing (~> 1.0) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (4.0.4) - jquery-rails - railties (>= 3.1.0) - json (1.8.1) - jwt (0.1.8) - multi_json (>= 1.5) - kaminari (0.14.1) + jquery-ui-rails (5.0.3) + railties (>= 3.2.16) + json (1.8.2) + jwt (1.3.0) + kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - kgio (2.8.1) - launchy (2.3.0) + kgio (2.9.3) + launchy (2.4.3) addressable (~> 2.3) - letter_opener (1.1.2) + letter_opener (1.3.0) launchy (~> 2.2) - listen (1.3.1) + listen (2.8.5) + celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) - rb-kqueue (>= 0.2) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.25.1) - mini_magick (3.6.0) - subexec (~> 0.2.1) - mini_portile (0.5.1) + loofah (2.0.1) + nokogiri (>= 1.5.9) + lumberjack (1.0.9) + mail (2.6.3) + mime-types (>= 1.16, < 3) + memoizable (0.4.2) + thread_safe (~> 0.3, >= 0.3.1) + method_source (0.8.2) + mime-types (2.4.3) + mini_magick (4.1.0) + mini_portile (0.6.2) + minitest (5.5.1) modular-scale (1.0.6) compass (>= 0.12.1) sass (>= 3.2.0) sassy-math (>= 1.5) - multi_json (1.8.4) - multipart-post (1.2.0) + multi_json (1.10.1) + multi_xml (0.5.5) + multipart-post (2.0.0) + naught (1.0.0) + nenv (0.2.0) nested_form (0.3.2) - net-scp (1.1.2) + net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (2.7.0) - nokogiri (1.6.0) - mini_portile (~> 0.5.0) + net-ssh (2.9.2) + netrc (0.10.3) + nokogiri (1.6.6.2) + mini_portile (~> 0.6.0) + notiffany (0.0.6) + nenv (~> 0.1) + shellany (~> 0.0) oauth (0.4.7) - oauth2 (0.8.1) - faraday (~> 0.8) - httpauth (~> 0.1) - jwt (~> 0.1.4) - multi_json (~> 1.0) + oauth2 (1.0.0) + faraday (>= 0.8, < 0.10) + jwt (~> 1.0) + multi_json (~> 1.3) + multi_xml (~> 0.5) rack (~> 1.2) - omniauth (1.1.4) - hashie (>= 1.2, < 3) - rack - omniauth-facebook (1.4.1) - omniauth-oauth2 (~> 1.1.0) + omniauth (1.2.2) + hashie (>= 1.2, < 4) + rack (~> 1.0) + omniauth-facebook (2.0.1) + omniauth-oauth2 (~> 1.2) omniauth-oauth (1.0.1) oauth omniauth (~> 1.0) - omniauth-oauth2 (1.1.1) - oauth2 (~> 0.8.0) - omniauth (~> 1.0) - omniauth-twitter (1.0.0) + omniauth-oauth2 (1.2.0) + faraday (>= 0.8, < 0.10) + multi_json (~> 1.3) + oauth2 (~> 1.0) + omniauth (~> 1.2) + omniauth-twitter (1.1.0) multi_json (~> 1.3) omniauth-oauth (~> 1.0) - orm_adapter (0.4.0) - pg (0.16.0) - polyamorous (0.6.4) + orm_adapter (0.5.0) + pg (0.18.1) + polyamorous (1.1.0) activerecord (>= 3.0) - polyglot (0.3.3) - quiet_assets (1.0.2) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.4.5) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.3) - rack - rack-test (0.6.2) + rack (1.6.0) + rack-test (0.6.3) rack (>= 1.0) - rails (3.2.16) - actionmailer (= 3.2.16) - actionpack (= 3.2.16) - activerecord (= 3.2.16) - activeresource (= 3.2.16) - activesupport (= 3.2.16) - bundler (~> 1.0) - railties (= 3.2.16) - railties (3.2.16) - actionpack (= 3.2.16) - activesupport (= 3.2.16) - rack-ssl (~> 1.3.2) + rails (4.2.0) + actionmailer (= 4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) + activemodel (= 4.2.0) + activerecord (= 4.2.0) + activesupport (= 4.2.0) + bundler (>= 1.3.0, < 2.0) + railties (= 4.2.0) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.5) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.1) + loofah (~> 2.0) + railties (4.2.0) + actionpack (= 4.2.0) + activesupport (= 4.2.0) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - raindrops (0.12.0) - rake (10.1.1) - ransack (1.0.0) + thor (>= 0.18.1, < 2.0) + raindrops (0.13.0) + rake (10.4.2) + ransack (1.6.3) actionpack (>= 3.0) activerecord (>= 3.0) - polyamorous (~> 0.6.0) - rb-fsevent (0.9.3) - rb-inotify (0.9.2) - ffi (>= 0.5.0) - rb-kqueue (0.2.0) - ffi (>= 0.5.0) - rdoc (3.12.2) - json (~> 1.4) - redis (3.0.7) - redis-namespace (1.4.1) - redis (~> 3.0.4) - rest-client (1.6.7) - mime-types (>= 1.16) - rspec-core (2.14.5) - rspec-expectations (2.14.2) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.3) - rspec-rails (2.14.0) - actionpack (>= 3.0) activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) - ruby-hmac (0.4.0) - rubyzip (1.1.0) - sass (3.2.10) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - sassy-math (1.5) - compass (~> 0.11) + i18n + polyamorous (~> 1.1) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) + ffi (>= 0.5.0) + redis (3.2.1) + redis-namespace (1.5.1) + redis (~> 3.0, >= 3.0.4) + responders (2.1.0) + railties (>= 4.2.0, < 5) + rest-client (1.7.3) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) + rspec-core (3.2.1) + rspec-support (~> 3.2.0) + rspec-expectations (3.2.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.2.0) + rspec-mocks (3.2.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.2.0) + rspec-rails (3.2.1) + actionpack (>= 3.0, < 4.3) + activesupport (>= 3.0, < 4.3) + railties (>= 3.0, < 4.3) + rspec-core (~> 3.2.0) + rspec-expectations (~> 3.2.0) + rspec-mocks (~> 3.2.0) + rspec-support (~> 3.2.0) + rspec-support (3.2.2) + ruby_parser (3.6.4) + sexp_processor (~> 4.1) + rubyzip (1.1.7) + sass (3.4.13) + sass-rails (5.0.1) + railties (>= 4.0.0, < 5.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (~> 1.1) + sassy-math (1.5.1) + compass (>= 0.11) selenium-webdriver (2.38.0) childprocess (>= 0.2.5) multi_json (~> 1.0) @@ -290,60 +439,72 @@ GEM sendgrid (1.2.0) json json - shoulda-matchers (2.3.0) + sexp_processor (4.4.5) + shellany (0.0.1) + shoulda-matchers (2.8.0) activesupport (>= 3.0.0) - sidekiq (2.17.5) - celluloid (>= 0.15.2) - connection_pool (>= 1.0.0) + sidekiq (3.3.2) + celluloid (>= 0.16.0) + connection_pool (>= 2.1.1) json redis (>= 3.0.6) redis-namespace (>= 1.3.1) - simple_oauth (0.2.0) - simplecov (0.8.2) + simple_oauth (0.3.1) + simplecov (0.9.2) docile (~> 1.1.0) - multi_json - simplecov-html (~> 0.8.0) - simplecov-html (0.8.0) + multi_json (~> 1.0) + simplecov-html (~> 0.9.0) + simplecov-html (0.9.0) slop (3.6.0) - sprockets (2.2.2) + sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.2.4) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (>= 2.8, < 4.0) statistics2 (0.54) - subexec (0.2.3) - term-ansicolor (1.2.2) - tins (~> 0.8) - thin (1.5.1) - daemons (>= 1.0.9) - eventmachine (>= 0.12.6) - rack (>= 1.0.0) - thor (0.18.1) + term-ansicolor (1.3.0) + tins (~> 1.0) + thin (1.6.3) + daemons (~> 1.0, >= 1.0.9) + eventmachine (~> 1.0) + rack (~> 1.0) + thor (0.19.1) + thread_safe (0.3.4) thumbs_up (0.6.7) activerecord statistics2 tilt (1.4.1) - timers (1.1.0) - tins (0.13.1) - treetop (1.4.15) - polyglot - polyglot (>= 0.3.1) - twitter (4.8.1) - faraday (~> 0.8, < 0.10) - multi_json (~> 1.0) - simple_oauth (~> 0.2) - tzinfo (0.3.38) - uglifier (2.2.1) + timers (4.0.1) + hitimes + tins (1.3.4) + twitter (5.14.0) + addressable (~> 2.3) + buftok (~> 0.2.0) + equalizer (~> 0.0.9) + faraday (~> 0.9.0) + http (~> 0.6.0) + http_parser.rb (~> 0.6.0) + json (~> 1.8) + memoizable (~> 0.4.0) + naught (~> 1.0) + simple_oauth (~> 0.3.0) + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (2.7.1) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - unicorn (4.6.3) + json (>= 1.8.0) + unicorn (4.8.3) kgio (~> 2.6) rack raindrops (~> 0.7) warden (1.2.3) rack (>= 1.0) websocket (1.0.7) - xml-simple (1.1.2) + xml-simple (1.1.4) xpath (2.0.0) nokogiri (~> 1.3) @@ -359,11 +520,11 @@ DEPENDENCIES byebug capybara carrierwave - coffee-rails (~> 3.2.1) + coffee-rails (~> 4.1.0) compass-rails coveralls database_cleaner - devise (= 2.2.4) + devise factory_girl_rails ffaker figaro @@ -390,10 +551,10 @@ DEPENDENCIES omniauth-twitter pg quiet_assets - rails (= 3.2.16) + rails (= 4.2.0) ransack rspec-rails - sass-rails (~> 3.2.3) + sass-rails (~> 5.0) selenium-webdriver (~> 2.38.0) sendgrid shoulda-matchers @@ -401,5 +562,5 @@ DEPENDENCIES thin thumbs_up twitter - uglifier (>= 1.0.3) + uglifier (>= 1.3.0) unicorn From 17881885719e975c3e66f22764002b9f9110ef9d Mon Sep 17 00:00:00 2001 From: Juan Pablo Escobar Date: Sun, 8 Mar 2015 18:15:33 -0600 Subject: [PATCH 02/42] [WIP] updated with rails4.2 boilerplate config files --- .gitignore | 3 +- Gemfile | 12 ++++++- Gemfile.lock | 17 +++++++++ Rakefile | 2 +- app/assets/javascripts/application.js | 1 + app/controllers/application_controller.rb | 5 ++- app/views/layouts/application.html.haml | 4 +-- config.ru | 2 +- config/application.rb | 12 +++---- config/boot.rb | 5 +-- config/database.yml.example | 25 +++++++------ config/environment.rb | 4 +-- config/environments/development.rb | 32 +++++++++-------- config/environments/production.rb | 36 +++++++++++++------ config/environments/test.rb | 19 ++++++---- config/initializers/assets.rb | 11 ++++++ config/initializers/cookies_serializer.rb | 3 ++ .../initializers/filter_parameter_logging.rb | 4 +++ config/initializers/inflections.rb | 7 ++-- config/initializers/mime_types.rb | 1 - config/initializers/secret_token.rb | 11 ------ config/initializers/session_store.rb | 6 +--- config/initializers/wrap_parameters.rb | 11 +++--- config/routes.rb | 2 +- config/secrets.yml | 22 ++++++++++++ 25 files changed, 167 insertions(+), 90 deletions(-) create mode 100644 config/initializers/assets.rb create mode 100644 config/initializers/cookies_serializer.rb create mode 100644 config/initializers/filter_parameter_logging.rb delete mode 100644 config/initializers/secret_token.rb create mode 100644 config/secrets.yml diff --git a/.gitignore b/.gitignore index 0b05244d..141b5ea4 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,8 @@ /db/*.sqlite3 # Ignore all logfiles and tempfiles. -/log/*.log +/log/* +!/log/.keep /tmp .DS_Store .sass-cache/ diff --git a/Gemfile b/Gemfile index f9279a24..e6095386 100644 --- a/Gemfile +++ b/Gemfile @@ -45,13 +45,17 @@ group :development,:test do gem 'factory_girl_rails' gem 'rspec-rails' gem 'shoulda-matchers' + gem 'byebug' + # Access an IRB console on exception pages or by using <%= console %> in views + gem 'web-console', '~> 2.0' + # Spring speeds up development by keeping your application running in the background + gem 'spring' end group :development do gem 'better_errors' gem 'binding_of_caller' gem 'thin' - gem 'byebug' gem 'letter_opener' gem 'quiet_assets' gem 'guard' @@ -71,3 +75,9 @@ gem 'compass-rails' gem "modular-scale", "~> 1.0.6" gem 'bootstrap-sass', '~> 3.0.0.0.rc' gem 'uglifier', '>= 1.3.0' + +# See https://github.com/sstephenson/execjs#readme for more supported runtimes +gem 'therubyracer', platforms: :ruby + +# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks +gem 'turbolinks' diff --git a/Gemfile.lock b/Gemfile.lock index aad32999..6dd94d4f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -288,6 +288,7 @@ GEM addressable (~> 2.3) letter_opener (1.3.0) launchy (~> 2.2) + libv8 (3.16.14.7) listen (2.8.5) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) @@ -397,6 +398,7 @@ GEM redis (3.2.1) redis-namespace (1.5.1) redis (~> 3.0, >= 3.0.4) + ref (1.0.5) responders (2.1.0) railties (>= 4.2.0, < 5) rest-client (1.7.3) @@ -456,6 +458,7 @@ GEM simplecov-html (~> 0.9.0) simplecov-html (0.9.0) slop (3.6.0) + spring (1.3.3) sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) @@ -468,6 +471,9 @@ GEM statistics2 (0.54) term-ansicolor (1.3.0) tins (~> 1.0) + therubyracer (0.12.1) + libv8 (~> 3.16.14.0) + ref thin (1.6.3) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0) @@ -481,6 +487,8 @@ GEM timers (4.0.1) hitimes tins (1.3.4) + turbolinks (2.5.3) + coffee-rails twitter (5.14.0) addressable (~> 2.3) buftok (~> 0.2.0) @@ -503,6 +511,11 @@ GEM raindrops (~> 0.7) warden (1.2.3) rack (>= 1.0) + web-console (2.1.1) + activemodel (>= 4.0) + binding_of_caller (>= 0.7.2) + railties (>= 4.0) + sprockets-rails (>= 2.0, < 4.0) websocket (1.0.7) xml-simple (1.1.4) xpath (2.0.0) @@ -559,8 +572,12 @@ DEPENDENCIES sendgrid shoulda-matchers sidekiq + spring + therubyracer thin thumbs_up + turbolinks twitter uglifier (>= 1.3.0) unicorn + web-console (~> 2.0) diff --git a/Rakefile b/Rakefile index 9d2f6ffe..98b5e81b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ -#!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) ReporteCiudadano::Application.load_tasks +Rails.application.load_tasks diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4c4b267f..173f7cfd 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,4 +12,5 @@ //= require highcharts //= require highcharts/modules/exporting //= require jquery.tablesorter +//= require turbolinks //= require_tree . diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1efafebf..f45b59bf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,8 @@ class ApplicationController < ActionController::Base - protect_from_forgery + + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception include SessionsHelper end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 48f9f974..ec8bfe84 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,8 +2,8 @@ %html %head %title Reporte Ciudadano - = stylesheet_link_tag current_theme, :media => "all" - = javascript_include_tag "application" + = stylesheet_link_tag current_theme, :media => "all", 'data-turbolinks-track' => true + = javascript_include_tag "application", 'data-turbolinks-track' => true %script(type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=#{ENV['GOOGLE_KEY']}&sensor=false") %meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"} = csrf_meta_tags diff --git a/config.ru b/config.ru index 67edd168..5bc2a619 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) -run ReporteCiudadano::Application +run Rails.application diff --git a/config/application.rb b/config/application.rb index 031f7dc7..2b5f0b71 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,12 +2,9 @@ require 'rails/all' -if defined?(Bundler) - # If you precompile assets before deploying to production, use this line - # Bundler.require(*Rails.groups(:assets => %w(development test))) - # If you want your assets lazily compiled in production, use this line - Bundler.require(:default, :assets, Rails.env) -end +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) module ReporteCiudadano class Application < Rails::Application @@ -71,5 +68,8 @@ class Application < Rails::Application routing_specs:false,controller_specs:true,request_specs:false g.fixture_replacement :factory_girl, dir: "spec/factories" end + + # Do not swallow errors in after_commit/after_rollback callbacks. + config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/boot.rb b/config/boot.rb index 4489e586..6b750f00 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,6 +1,3 @@ -require 'rubygems' - -# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/database.yml.example b/config/database.yml.example index 6c574f1d..26909086 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -1,21 +1,20 @@ -development: +default: &default adapter: postgresql - encoding: unicode - host: localhost - database: reporte_ciudadano_development + encoding: utf-8 pool: 5 - password: + timeout: 5000 + +development: + <<: *default + database: reporte_ciudadano_development +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. test: - adapter: postgresql - encoding: unicode + <<: *default database: reporte_ciudadano_test - pool: 5 - password: production: - adapter: postgresql - encoding: unicode + <<: *default database: reporte_ciudadano_production - pool: 5 - password: diff --git a/config/environment.rb b/config/environment.rb index c95d2380..3814138e 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,5 @@ -# Load the rails application +# Load the Rails application. require File.expand_path('../application', __FILE__) # Initialize the rails application -ReporteCiudadano::Application.initialize! +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index c4bb603d..438deb66 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,4 +1,4 @@ -ReporteCiudadano::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on @@ -6,8 +6,8 @@ # since you don't have to restart the web server when you make code changes. config.cache_classes = false - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + # Do not eager load code on boot. + config.eager_load = false # Show full error reports and disable caching config.consider_all_requests_local = true @@ -19,21 +19,25 @@ # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true - # Do not compress assets - config.assets.compress = false + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true - # Expands the lines which load the assets - config.assets.debug = true + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true # Action Mailer config.action_mailer.default_url_options = { :host => 'localhost:3000' } diff --git a/config/environments/production.rb b/config/environments/production.rb index 01e376b1..2d11ee25 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,18 +1,32 @@ -ReporteCiudadano::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like + # NGINX, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? - # Compress JavaScripts and CSS - config.assets.compress = true + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = true @@ -20,7 +34,6 @@ # Generate digests for assets URLs config.assets.digest = true - # Defaults to nil and saved in location specified by config.assets.prefix # config.assets.manifest = YOUR_PATH @@ -32,7 +45,7 @@ # config.force_ssl = true # See everything in the log (default is :info) - # config.log_level = :debug + config.log_level = :debug # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] @@ -62,10 +75,11 @@ # Send deprecation notices to registered listeners config.active_support.deprecation = :notify - # Log the query plan for queries taking more than this (works - # with SQLite, MySQL, and PostgreSQL) - # config.active_record.auto_explain_threshold_in_seconds = 0.5 - # + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false # Action mailer config.action_mailer.raise_delivery_errors = false diff --git a/config/environments/test.rb b/config/environments/test.rb index ebba7b56..8687d853 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,4 +1,4 @@ -ReporteCiudadano::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's @@ -7,13 +7,15 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = true + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + # Configure static asset server for tests with Cache-Control for performance config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false @@ -22,7 +24,7 @@ config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the @@ -30,12 +32,15 @@ config.action_mailer.delivery_method = :test config.action_mailer.default_url_options = { :host => 'localhost:3000' } - # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + # Randomize the order test cases are executed. + config.active_support.test_order = :random # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + # Enable testing mode for omniauth requests OmniAuth.config.test_mode = true end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 00000000..01ef3e66 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..7f70458d --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 5d8d9be2..8a39994b 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,7 +1,8 @@ # Be sure to restart your server when you modify this file. -# Add new inflection rules using the following format -# (all these examples are active by default): +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' @@ -10,6 +11,6 @@ # end # # These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections do |inflect| +# ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb index 72aca7e4..dc189968 100644 --- a/config/initializers/mime_types.rb +++ b/config/initializers/mime_types.rb @@ -2,4 +2,3 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb deleted file mode 100644 index f01b420a..00000000 --- a/config/initializers/secret_token.rb +++ /dev/null @@ -1,11 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -ReporteCiudadano::Application.config.secret_token = if Rails.env.production? - ENV['SECRET_TOKEN'] -else - ('x' * 30) # requirimiento minimo de 30 caracteres -end diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index c3cbfe9f..505d0e60 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,8 +1,4 @@ # Be sure to restart your server when you modify this file. -ReporteCiudadano::Application.config.session_store :cookie_store, key: '_reporte-ciudadano_session' +Rails.application.config.session_store :cookie_store, key: '_reporte-ciudadano_session' -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rails generate session_migration") -# ReporteCiudadano::Application.config.session_store :active_record_store diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 999df201..3fef73d6 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,10 +5,11 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) end -# Disable root element in JSON by default. -ActiveSupport.on_load(:active_record) do - self.include_root_in_json = false -end +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end + diff --git a/config/routes.rb b/config/routes.rb index 063ec011..e15e2f09 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ require 'api_constraints' -ReporteCiudadano::Application.routes.draw do +Rails.application.routes.draw do devise_for :admins, controllers: { sessions: 'admins/sessions' } devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks", registrations: 'users/registrations' } diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 00000000..52d3c759 --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: a06009069f069a8dd704308e0f49355916340e850cb62b788249246494970dc6e7d7480e6e6bc3def35313baed938de95ed0831349805fd2a6b2906bea2123ed + +test: + secret_key_base: 7814d511f4c327ab6a5a08d4043a5d5b42f6f681506fb0e45d182c2a7966799f9b945171d53027843b1fad27aaa58d633d8ac767025123284525f1f85544c227 + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> From a954491017848b32d2909c6714110eb33bb31e02 Mon Sep 17 00:00:00 2001 From: Juan Pablo Escobar Date: Sun, 8 Mar 2015 18:55:33 -0600 Subject: [PATCH 03/42] updates aws-s3 gem --- Gemfile | 2 +- Gemfile.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index e6095386..3f80911f 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem 'omniauth-twitter' gem 'carrierwave' gem 'mini_magick' gem 'fog' -gem 'aws-s3' +gem 'aws-sdk', '< 2.0' gem 'kaminari' gem 'thumbs_up' gem 'gravatar-ultimate' diff --git a/Gemfile.lock b/Gemfile.lock index 6dd94d4f..7e637d59 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,10 +41,11 @@ GEM tzinfo (~> 1.1) addressable (2.3.7) arel (6.0.0) - aws-s3 (0.6.3) - builder - mime-types - xml-simple + aws-sdk (1.63.0) + aws-sdk-v1 (= 1.63.0) + aws-sdk-v1 (1.63.0) + json (~> 1.4) + nokogiri (>= 1.4.4) bcrypt (3.1.10) better_errors (2.1.1) coderay (>= 1.0.0) @@ -517,7 +518,6 @@ GEM railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) websocket (1.0.7) - xml-simple (1.1.4) xpath (2.0.0) nokogiri (~> 1.3) @@ -526,7 +526,7 @@ PLATFORMS DEPENDENCIES active_model_serializers - aws-s3 + aws-sdk (< 2.0) better_errors binding_of_caller bootstrap-sass (~> 3.0.0.0.rc) From 43d7221eda5dcf63bf4e3f9abc057dda87d1f0e5 Mon Sep 17 00:00:00 2001 From: Juan Pablo Escobar Date: Sun, 8 Mar 2015 22:54:57 -0600 Subject: [PATCH 04/42] [WIP] starting to migrate attr_accessible to strong params --- app/controllers/admins/service_requests_controller.rb | 11 +++++++++-- app/controllers/service_requests_controller.rb | 10 +++++++++- app/models/admin.rb | 2 -- app/models/application_setting.rb | 1 - app/models/service.rb | 1 - 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/controllers/admins/service_requests_controller.rb b/app/controllers/admins/service_requests_controller.rb index 86d04e66..30b9a702 100644 --- a/app/controllers/admins/service_requests_controller.rb +++ b/app/controllers/admins/service_requests_controller.rb @@ -11,7 +11,7 @@ def new end def create - @service_request = current_admin.service_requests.build(params[:service_request]) + @service_request = current_admin.service_requests.build(service_request_params) if @service_request.save redirect_to edit_admins_service_request_path(@service_request), flash: { success: I18n.t('flash.service_requests.created') } else @@ -28,7 +28,7 @@ def edit def update @service_request = ServiceRequest.find params[:id] - if @service_request.update_attributes params[:service_request] + if @service_request.update_attributes(service_request_params) @service_request.comments.create content: params[:message], commentable: current_admin if params[:message].present? redirect_to edit_admins_service_request_path(@service_request), flash: { success: I18n.t('flash.service_requests.updated') } else @@ -42,5 +42,12 @@ def destroy redirect_to :back, flash: { success: I18n.t('flash.service_requests.destroyed') } end + private + + # Never trust parameters from the scary internet, only allow the white list through. + def service_request_params + params.require(:service_request).permit(:name, :service_fields_attributes, :messages_attributes) + end + end diff --git a/app/controllers/service_requests_controller.rb b/app/controllers/service_requests_controller.rb index a5c9b0e6..c060a49d 100644 --- a/app/controllers/service_requests_controller.rb +++ b/app/controllers/service_requests_controller.rb @@ -16,7 +16,7 @@ def new end def create - @service_request = current_user.service_requests.build(params[:service_request]) + @service_request = current_user.service_requests.build(service_request_params) if @service_request.save redirect_to root_path, flash: { success: 'La solicitud fue creada satisfactoriamente' } else @@ -45,4 +45,12 @@ def markers_for_gmap format.json { render :json => service_requests } end end + + private + + # Never trust parameters from the scary internet, only allow the white list through. + def service_request_params + params.require(:service_request).permit(:name, :service_fields_attributes, :messages_attributes) + end + end diff --git a/app/models/admin.rb b/app/models/admin.rb index 737c9e08..78c3a859 100644 --- a/app/models/admin.rb +++ b/app/models/admin.rb @@ -8,8 +8,6 @@ class Admin < ActiveRecord::Base before_save :ensure_authentication_token - # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me, :avatar, :name # attr_accessible :title, :body has_many :comments, as: :commentable diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index e83d2f85..bafed3b1 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -1,3 +1,2 @@ class ApplicationSetting < ActiveRecord::Base - attr_accessible :type, :value end diff --git a/app/models/service.rb b/app/models/service.rb index 7004342d..a6350018 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -1,5 +1,4 @@ class Service < ActiveRecord::Base - attr_accessible :name, :service_fields_attributes, :messages_attributes has_many :service_requests validates :name, presence: true From cbcd84a6dd298ba0293d44d05e7d0f223582238e Mon Sep 17 00:00:00 2001 From: abigail sosa Date: Mon, 9 Mar 2015 14:56:50 -0600 Subject: [PATCH 05/42] Removed attr_accessible from models --- app/models/admin.rb | 6 +- app/models/application_settings/css_theme.rb | 2 +- .../application_settings/map_constraints.rb | 2 +- app/models/authentication.rb | 2 +- app/models/comment.rb | 2 +- app/models/logo.rb | 2 +- app/models/message.rb | 2 +- app/models/service_field.rb | 2 +- app/models/service_request.rb | 4 +- app/models/status.rb | 2 +- app/models/user.rb | 2 +- app/models/vote.rb | 2 +- config/application.rb | 1 - config/initializers/devise.rb | 3 +- db/schema.rb | 219 +++++++++--------- 15 files changed, 126 insertions(+), 127 deletions(-) diff --git a/app/models/admin.rb b/app/models/admin.rb index 78c3a859..c468cab4 100644 --- a/app/models/admin.rb +++ b/app/models/admin.rb @@ -3,10 +3,8 @@ class Admin < ActiveRecord::Base # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, - :recoverable, :rememberable, :trackable, :validatable, - :token_authenticatable - - before_save :ensure_authentication_token + :recoverable, :rememberable, :trackable, :validatable + #before_save :ensure_authentication_token # attr_accessible :title, :body diff --git a/app/models/application_settings/css_theme.rb b/app/models/application_settings/css_theme.rb index 3d25fd76..6af1a4ef 100644 --- a/app/models/application_settings/css_theme.rb +++ b/app/models/application_settings/css_theme.rb @@ -2,7 +2,7 @@ class ApplicationSettings::CssTheme < ApplicationSetting DEFAULT_THEME_NAME = "theme_one" THEMES = %w{theme_one theme_two theme_three theme_four} - attr_accessible :name + #attr_accessible :name validates :name, presence: true, inclusion: { in: THEMES } def self.get diff --git a/app/models/application_settings/map_constraints.rb b/app/models/application_settings/map_constraints.rb index 59ad4ea5..45c7cab8 100644 --- a/app/models/application_settings/map_constraints.rb +++ b/app/models/application_settings/map_constraints.rb @@ -8,7 +8,7 @@ class ApplicationSettings::MapConstraints < ApplicationSetting ] } - attr_accessible :map_constraints + #attr_accessible :map_constraints validates :map_constraints, presence: true def self.get diff --git a/app/models/authentication.rb b/app/models/authentication.rb index 4c737997..00d0bcf2 100644 --- a/app/models/authentication.rb +++ b/app/models/authentication.rb @@ -1,5 +1,5 @@ class Authentication < ActiveRecord::Base - attr_accessible :provider, :uid + #attr_accessible :provider, :uid belongs_to :user diff --git a/app/models/comment.rb b/app/models/comment.rb index 65955689..846d691f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,5 +1,5 @@ class Comment < ActiveRecord::Base - attr_accessible :content, :service_request_id, :image, :commentable + #attr_accessible :content, :service_request_id, :image, :commentable belongs_to :commentable, polymorphic: true belongs_to :service_request diff --git a/app/models/logo.rb b/app/models/logo.rb index be618de5..7c9f0872 100644 --- a/app/models/logo.rb +++ b/app/models/logo.rb @@ -1,7 +1,7 @@ class Logo < ActiveRecord::Base include ActAsSortable - attr_accessible :image, :position, :title, :image_cache + #attr_accessible :image, :position, :title, :image_cache validates :image, :title, presence: true diff --git a/app/models/message.rb b/app/models/message.rb index ae79ad35..a6f78ea9 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,5 +1,5 @@ class Message < ActiveRecord::Base - attr_accessible :content, :status_id + #attr_accessible :content, :status_id belongs_to :service belongs_to :status diff --git a/app/models/service_field.rb b/app/models/service_field.rb index 7dba282e..34e4de17 100644 --- a/app/models/service_field.rb +++ b/app/models/service_field.rb @@ -1,5 +1,5 @@ class ServiceField < ActiveRecord::Base - attr_accessible :service_id, :name + #attr_accessible :service_id, :name belongs_to :service validates :name, presence: true diff --git a/app/models/service_request.rb b/app/models/service_request.rb index 9ad5ab6a..f1aaff55 100644 --- a/app/models/service_request.rb +++ b/app/models/service_request.rb @@ -1,7 +1,7 @@ #encoding: utf-8 class ServiceRequest < ActiveRecord::Base - attr_accessible :anonymous, :service_id, :description, :lat, :lng, - :service_fields, :media, :status_id, :address, :title + #attr_accessible :anonymous, :service_id, :description, :lat, :lng, + # :service_fields, :media, :status_id, :address, :title attr_accessor :message diff --git a/app/models/status.rb b/app/models/status.rb index a5ae4445..a5f18267 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -1,5 +1,5 @@ class Status < ActiveRecord::Base - attr_accessible :name, :is_default + #attr_accessible :name, :is_default has_many :service_requests has_many :messages diff --git a/app/models/user.rb b/app/models/user.rb index 421a456d..4af99fa5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,7 @@ class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :name + #attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :name devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :registerable diff --git a/app/models/vote.rb b/app/models/vote.rb index dda0bf06..31963cef 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -8,7 +8,7 @@ class Vote < ActiveRecord::Base belongs_to :voteable, :polymorphic => true belongs_to :voter, :polymorphic => true - attr_accessible :vote, :voter, :voteable + #attr_accessible :vote, :voter, :voteable # Comment out the line below to allow multiple votes per user. diff --git a/config/application.rb b/config/application.rb index 2b5f0b71..f7eca464 100644 --- a/config/application.rb +++ b/config/application.rb @@ -53,7 +53,6 @@ class Application < Rails::Application # This will create an empty whitelist of attributes available for mass-assignment for all models # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. - config.active_record.whitelist_attributes = true # Enable the asset pipeline config.assets.enabled = true diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 586beb54..182deebb 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -180,7 +180,7 @@ # ==> Configuration for :token_authenticatable # Defines name of the authentication token params key - config.token_authentication_key = :auth_token + # config.token_authentication_key = :auth_token # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for @@ -209,7 +209,6 @@ # The default HTTP method used to sign out a resource. Default is :delete. config.sign_out_via = :delete - # ==> OmniAuth # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. diff --git a/db/schema.rb b/db/schema.rb index d936bac4..f6b229b2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,168 +9,171 @@ # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # -# It's strongly recommended to check this file into your version control system. +# It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140211002335) do +ActiveRecord::Schema.define(version: 20140211002335) do - create_table "admins", :force => true do |t| - t.string "email", :default => "", :null => false - t.string "encrypted_password", :default => "", :null => false - t.string "name", :default => "", :null => false - t.string "avatar" - t.string "reset_password_token" + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "admins", force: :cascade do |t| + t.string "email", limit: 255, default: "", null: false + t.string "encrypted_password", limit: 255, default: "", null: false + t.string "name", limit: 255, default: "", null: false + t.string "avatar", limit: 255 + t.string "reset_password_token", limit: 255 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "authentication_token" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 + t.string "authentication_token", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "admins", ["authentication_token"], :name => "index_admins_on_authentication_token", :unique => true - add_index "admins", ["email"], :name => "index_admins_on_email", :unique => true - add_index "admins", ["reset_password_token"], :name => "index_admins_on_reset_password_token", :unique => true + add_index "admins", ["authentication_token"], name: "index_admins_on_authentication_token", unique: true, using: :btree + add_index "admins", ["email"], name: "index_admins_on_email", unique: true, using: :btree + add_index "admins", ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true, using: :btree - create_table "api_keys", :force => true do |t| - t.string "access_token" + create_table "api_keys", force: :cascade do |t| + t.string "access_token", limit: 255 t.integer "admin_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" - add_index "api_keys", ["admin_id"], :name => "index_api_keys_on_admin_id" + add_index "api_keys", ["access_token"], name: "index_api_keys_on_access_token", using: :btree + add_index "api_keys", ["admin_id"], name: "index_api_keys_on_admin_id", using: :btree - create_table "application_settings", :force => true do |t| - t.string "type" - t.string "value" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "application_settings", force: :cascade do |t| + t.string "type", limit: 255 + t.string "value", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "application_settings", ["type"], :name => "index_application_settings_on_type", :unique => true + add_index "application_settings", ["type"], name: "index_application_settings_on_type", unique: true, using: :btree - create_table "authentications", :force => true do |t| + create_table "authentications", force: :cascade do |t| t.integer "user_id" - t.string "provider" - t.string "uid" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.string "provider", limit: 255 + t.string "uid", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "authentications", ["user_id"], :name => "index_authentications_on_user_id" + add_index "authentications", ["user_id"], name: "index_authentications_on_user_id", using: :btree - create_table "comments", :force => true do |t| - t.text "content", :default => "" + create_table "comments", force: :cascade do |t| + t.text "content", default: "" t.integer "service_request_id" - t.integer "commentable_id", :null => false - t.string "commentable_type", :null => false - t.string "ancestry" - t.string "image" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "commentable_id", null: false + t.string "commentable_type", limit: 255, null: false + t.string "ancestry", limit: 255 + t.string "image", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "comments", ["ancestry"], :name => "index_comments_on_ancestry" - add_index "comments", ["commentable_id", "commentable_type"], :name => "index_comments_on_commentable_id_and_commentable_type" - add_index "comments", ["service_request_id"], :name => "index_comments_on_service_request_id" + add_index "comments", ["ancestry"], name: "index_comments_on_ancestry", using: :btree + add_index "comments", ["commentable_id", "commentable_type"], name: "index_comments_on_commentable_id_and_commentable_type", using: :btree + add_index "comments", ["service_request_id"], name: "index_comments_on_service_request_id", using: :btree - create_table "logos", :force => true do |t| - t.string "title" - t.string "image" + create_table "logos", force: :cascade do |t| + t.string "title", limit: 255 + t.string "image", limit: 255 t.integer "position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "messages", :force => true do |t| + create_table "messages", force: :cascade do |t| t.text "content" t.integer "service_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "status_id" end - add_index "messages", ["service_id"], :name => "index_messages_on_service_id" - add_index "messages", ["status_id"], :name => "index_messages_on_status_id" + add_index "messages", ["service_id"], name: "index_messages_on_service_id", using: :btree + add_index "messages", ["status_id"], name: "index_messages_on_status_id", using: :btree - create_table "service_fields", :force => true do |t| - t.string "name" + create_table "service_fields", force: :cascade do |t| + t.string "name", limit: 255 t.integer "service_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "service_requests", :force => true do |t| - t.text "description", :default => "" - t.string "lat", :default => "" - t.string "lng", :default => "" - t.boolean "anonymous", :default => false - t.text "service_fields", :default => "{}" - t.text "address", :default => "" - t.string "media" + create_table "service_requests", force: :cascade do |t| + t.text "description", default: "" + t.string "lat", limit: 255, default: "" + t.string "lng", limit: 255, default: "" + t.boolean "anonymous", default: false + t.text "service_fields", default: "{}" + t.text "address", default: "" + t.string "media", limit: 255 t.integer "service_id" - t.integer "requester_id", :null => false - t.string "requester_type", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "requester_id", null: false + t.string "requester_type", limit: 255, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "status_id" end - add_index "service_requests", ["requester_id", "requester_type"], :name => "index_service_requests_on_requester_id_and_requester_type" - add_index "service_requests", ["service_id"], :name => "index_service_requests_on_service_id" - add_index "service_requests", ["status_id"], :name => "index_service_requests_on_status_id" + add_index "service_requests", ["requester_id", "requester_type"], name: "index_service_requests_on_requester_id_and_requester_type", using: :btree + add_index "service_requests", ["service_id"], name: "index_service_requests_on_service_id", using: :btree + add_index "service_requests", ["status_id"], name: "index_service_requests_on_status_id", using: :btree - create_table "services", :force => true do |t| - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + create_table "services", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - create_table "statuses", :force => true do |t| - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "is_default", :default => false + create_table "statuses", force: :cascade do |t| + t.string "name", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "is_default", default: false end - create_table "users", :force => true do |t| - t.string "name" - t.string "username" - t.string "avatar" - t.string "email", :default => "" - t.string "encrypted_password", :default => "", :null => false - t.string "reset_password_token" + create_table "users", force: :cascade do |t| + t.string "name", limit: 255 + t.string "username", limit: 255 + t.string "avatar", limit: 255 + t.string "email", limit: 255, default: "" + t.string "encrypted_password", limit: 255, default: "", null: false + t.string "reset_password_token", limit: 255 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", :default => 0 + t.integer "sign_in_count", default: 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "users", ["email"], :name => "index_users_on_email", :unique => true - add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true + add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree - create_table "votes", :force => true do |t| - t.boolean "vote", :default => false, :null => false - t.integer "voteable_id", :null => false - t.string "voteable_type", :null => false + create_table "votes", force: :cascade do |t| + t.boolean "vote", default: false, null: false + t.integer "voteable_id", null: false + t.string "voteable_type", limit: 255, null: false t.integer "voter_id" - t.string "voter_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.string "voter_type", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "votes", ["voteable_id", "voteable_type"], :name => "index_votes_on_voteable_id_and_voteable_type" - add_index "votes", ["voter_id", "voter_type", "voteable_id", "voteable_type"], :name => "fk_one_vote_per_user_per_entity", :unique => true - add_index "votes", ["voter_id", "voter_type"], :name => "index_votes_on_voter_id_and_voter_type" + add_index "votes", ["voteable_id", "voteable_type"], name: "index_votes_on_voteable_id_and_voteable_type", using: :btree + add_index "votes", ["voter_id", "voter_type", "voteable_id", "voteable_type"], name: "fk_one_vote_per_user_per_entity", unique: true, using: :btree + add_index "votes", ["voter_id", "voter_type"], name: "index_votes_on_voter_id_and_voter_type", using: :btree end From 0d4065fe62b26d2b915728ad034763b636fda10f Mon Sep 17 00:00:00 2001 From: abisosa Date: Mon, 9 Mar 2015 18:04:09 -0600 Subject: [PATCH 06/42] Updated old model scopes definition --- app/models/message.rb | 2 +- app/models/service_request.rb | 20 ++++++++++---------- app/models/status.rb | 2 +- app/models/vote.rb | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/models/message.rb b/app/models/message.rb index a6f78ea9..357db448 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -4,7 +4,7 @@ class Message < ActiveRecord::Base belongs_to :service belongs_to :status - scope :with_status, lambda { |status_id| + scope :with_status,-> (status_id) { where(status_id: status_id) } end diff --git a/app/models/service_request.rb b/app/models/service_request.rb index f1aaff55..e09e4bf5 100644 --- a/app/models/service_request.rb +++ b/app/models/service_request.rb @@ -21,41 +21,41 @@ class ServiceRequest < ActiveRecord::Base mount_uploader :media, ImageUploader acts_as_voteable - default_scope order: 'created_at DESC' + default_scope { order('created_at DESC') } - scope :on_start_date, lambda {|from| + scope :on_start_date, -> (from) { where("service_requests.created_at >= ?", from) unless from.blank? } - scope :on_finish_date, lambda { |to| + scope :on_finish_date, -> (to) { where("service_requests.created_at <= ?", to) unless to.blank? } - scope :with_status, lambda { |status_id| + scope :with_status, -> (status_id) { where(status_id: status_id) unless status_id.blank? } - scope :on_status_name, lambda { |status_name| + scope :on_status_name, -> (status_name) { joins(:status).where('statuses.name = ?', status_name) unless status_name.blank? } - scope :on_service, lambda { |service_ids| + scope :on_service, -> (service_ids) { where(service_id: service_ids.split(',')) unless service_ids.blank? } - scope :find_by_ids, lambda { |ids| + scope :find_by_ids, -> (ids) { where("service_requests.id IN (?)", ids.split(',')) unless ids.blank? } - scope :closed, lambda { + scope :closed, -> { where(status_id: 4) } - scope :not_closed, lambda { + scope :not_closed, -> { where('status_id != ?', 4) } - scope :open, lambda { + scope :open, -> { where(status: 1) } diff --git a/app/models/status.rb b/app/models/status.rb index a5f18267..f1ee78e0 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -7,7 +7,7 @@ class Status < ActiveRecord::Base before_create :set_default_if_is_the_first - default_scope order('created_at') + default_scope { order('created_at') } def to_s name diff --git a/app/models/vote.rb b/app/models/vote.rb index 31963cef..df683abb 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -1,9 +1,9 @@ class Vote < ActiveRecord::Base - scope :for_voter, lambda { |*args| where(["voter_id = ? AND voter_type = ?", args.first.id, args.first.class.base_class.name]) } - scope :for_voteable, lambda { |*args| where(["voteable_id = ? AND voteable_type = ?", args.first.id, args.first.class.base_class.name]) } - scope :recent, lambda { |*args| where(["created_at > ?", (args.first || 2.weeks.ago)]) } - scope :descending, order("created_at DESC") + scope :for_voter, -> (*args) { where(["voter_id = ? AND voter_type = ?", args.first.id, args.first.class.base_class.name]) } + scope :for_voteable, -> (*args) { where(["voteable_id = ? AND voteable_type = ?", args.first.id, args.first.class.base_class.name]) } + scope :recent, -> (*args) { where(["created_at > ?", (args.first || 2.weeks.ago)]) } + scope :descending, -> { order("created_at DESC") } belongs_to :voteable, :polymorphic => true belongs_to :voter, :polymorphic => true From a1d38d19462a7809453405832139ad6de395f336 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 10:56:46 -0600 Subject: [PATCH 07/42] Fix service request model and spec --- app/mailers/user_mailer.rb | 1 - app/models/service_request.rb | 4 ++-- spec/models/css_theme_spec.rb | 2 +- spec/models/service_request_spec.rb | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 24c95bab..561a1807 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -7,6 +7,5 @@ def notify_service_request_status_change(service_request_id, previous_status_id) @previous_status = Status.find(previous_status_id) mail(subject: I18n.t('mailer.subject.status_change_notification'), to: @user.email) end - end diff --git a/app/models/service_request.rb b/app/models/service_request.rb index e09e4bf5..1a85835c 100644 --- a/app/models/service_request.rb +++ b/app/models/service_request.rb @@ -60,7 +60,7 @@ class ServiceRequest < ActiveRecord::Base } def service? - self.service.present? + service.present? end def self.filter_by_search(params) @@ -130,7 +130,7 @@ def assign_default_status def send_notification_for_status_update if self.requested_by_user? && self.status_id_changed? - UserMailer.delay.notify_service_request_status_change(self.id, self.status_id_was) + UserMailer.notify_service_request_status_change(self.id, self.status_id_was).deliver_later end end diff --git a/spec/models/css_theme_spec.rb b/spec/models/css_theme_spec.rb index 1fad322f..bcdee42b 100644 --- a/spec/models/css_theme_spec.rb +++ b/spec/models/css_theme_spec.rb @@ -8,7 +8,7 @@ context 'validations' do it { should validate_presence_of :name } - it { should ensure_inclusion_of(:name).in_array(%w{theme_one theme_two theme_three theme_four})} + it { should validate_inclusion_of(:name).in_array(%w{theme_one theme_two theme_three theme_four})} end end diff --git a/spec/models/service_request_spec.rb b/spec/models/service_request_spec.rb index 9764f6a8..79e428ce 100644 --- a/spec/models/service_request_spec.rb +++ b/spec/models/service_request_spec.rb @@ -49,13 +49,13 @@ admin_request = create(:service_request, requester: admin) expect do admin_request.update_attributes(status_id: FactoryGirl.create(:status).id) - end.to_not change{ ActionMailer::Base.deliveries.size }.by(1) + end.to_not change{ ActionMailer::Base.deliveries.size } end it 'does not send an email when any other attribute was updated' do expect do service_request.update_attributes(address: 'Nueva direccion') - end.to_not change{ ActionMailer::Base.deliveries.size }.by(1) + end.to_not change{ ActionMailer::Base.deliveries.size } end end @@ -95,7 +95,7 @@ let(:service_request) { create(:service_request) } it '#service? tells me if my service_request has a service' do - expect(service_request.service?).to be_true + expect(service_request.service?).to be end it '#service_requester returns a hash with the avatar_url and name from the service_requester' do From a9a9f4801688d72d994e266f54a3bf1e1096b190 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 11:16:33 -0600 Subject: [PATCH 08/42] Fix admin model spec --- spec/models/admin_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/admin_spec.rb b/spec/models/admin_spec.rb index a72bca5e..a434c27a 100644 --- a/spec/models/admin_spec.rb +++ b/spec/models/admin_spec.rb @@ -27,7 +27,7 @@ end it '#api_key?' do create(:api_key, admin: admin) - expect(admin.api_key?).to be_true + expect(admin.api_key?).to be end end end From d3a80f2664bab9f00c3393e0bc9f018ea7403b11 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 11:37:09 -0600 Subject: [PATCH 09/42] Fix controllers specs --- spec/controllers/api/v1/service_requests_controllers_spec.rb | 2 +- spec/controllers/service_requests_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/api/v1/service_requests_controllers_spec.rb b/spec/controllers/api/v1/service_requests_controllers_spec.rb index 96e93da2..03fe48c0 100644 --- a/spec/controllers/api/v1/service_requests_controllers_spec.rb +++ b/spec/controllers/api/v1/service_requests_controllers_spec.rb @@ -2,7 +2,7 @@ module Api module V1 - describe ServiceRequestsController do + describe ServiceRequestsController, type: :controller do describe 'GET show' do let(:service_request) { create(:service_request)} diff --git a/spec/controllers/service_requests_controller_spec.rb b/spec/controllers/service_requests_controller_spec.rb index 487a37a9..37a8c5aa 100644 --- a/spec/controllers/service_requests_controller_spec.rb +++ b/spec/controllers/service_requests_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ServiceRequestsController do +describe ServiceRequestsController, type: :controller do describe 'GET markers_for_gmap' do it 'returns a group of service_requests' do From 7655aa1901dceeb2d8940dd2503cdc6502d50798 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 13:32:42 -0600 Subject: [PATCH 10/42] Fix assets inclusion (jquery plugins) --- Gemfile | 2 +- Gemfile.lock | 38 +++++++++++----------- app/assets/javascripts/application.js | 4 +-- app/assets/stylesheets/common.scss | 2 +- app/assets/stylesheets/shared/modules.scss | 3 +- config/initializers/assets.rb | 1 + 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Gemfile b/Gemfile index 3f80911f..14b7cb39 100644 --- a/Gemfile +++ b/Gemfile @@ -38,7 +38,7 @@ group :test do gem 'database_cleaner' gem 'launchy' gem 'capybara' - gem 'selenium-webdriver', "~> 2.38.0" + gem 'selenium-webdriver' end group :development,:test do diff --git a/Gemfile.lock b/Gemfile.lock index 7e637d59..84883944 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,15 +102,15 @@ GEM compass (~> 1.0.0) sass-rails (<= 5.0.1) sprockets (< 2.13) - connection_pool (2.1.1) + connection_pool (2.1.2) coveralls (0.7.11) multi_json (~> 1.10) rest-client (>= 1.6.8, < 2) simplecov (~> 0.9.1) term-ansicolor (~> 1.3) thor (~> 0.19.1) - daemons (1.1.9) - database_cleaner (1.4.0) + daemons (1.2.1) + database_cleaner (1.4.1) debug_inspector (0.0.2) debugger-linecache (1.2.0) devise (3.4.1) @@ -125,8 +125,8 @@ GEM equalizer (0.0.9) erubis (2.7.0) eventmachine (1.0.7) - excon (0.44.3) - execjs (2.3.0) + excon (0.44.4) + execjs (2.4.0) factory_girl (4.5.0) activesupport (>= 3.0.0) factory_girl_rails (4.5.0) @@ -247,10 +247,10 @@ GEM guard (~> 2.0) haml (4.0.6) tilt - haml-rails (0.8.2) + haml-rails (0.9.0) actionpack (>= 4.0.1) activesupport (>= 4.0.1) - haml (>= 3.1, < 5.0) + haml (>= 4.0.6, < 5.0) html2haml (>= 1.0.1) railties (>= 4.0.1) hashie (3.4.0) @@ -280,7 +280,7 @@ GEM jquery-ui-rails (5.0.3) railties (>= 3.2.16) json (1.8.2) - jwt (1.3.0) + jwt (1.4.0) kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -290,7 +290,7 @@ GEM letter_opener (1.3.0) launchy (~> 2.2) libv8 (3.16.14.7) - listen (2.8.5) + listen (2.9.0) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) @@ -310,7 +310,7 @@ GEM compass (>= 0.12.1) sass (>= 3.2.0) sassy-math (>= 1.5) - multi_json (1.10.1) + multi_json (1.11.0) multi_xml (0.5.5) multipart-post (2.0.0) naught (1.0.0) @@ -378,7 +378,7 @@ GEM activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.1) + rails-html-sanitizer (1.0.2) loofah (~> 2.0) railties (4.2.0) actionpack (= 4.2.0) @@ -434,15 +434,15 @@ GEM tilt (~> 1.1) sassy-math (1.5.1) compass (>= 0.11) - selenium-webdriver (2.38.0) - childprocess (>= 0.2.5) + selenium-webdriver (2.45.0) + childprocess (~> 0.5) multi_json (~> 1.0) rubyzip (~> 1.0) - websocket (~> 1.0.4) + websocket (~> 1.0) sendgrid (1.2.0) json json - sexp_processor (4.4.5) + sexp_processor (4.5.0) shellany (0.0.1) shoulda-matchers (2.8.0) activesupport (>= 3.0.0) @@ -480,14 +480,14 @@ GEM eventmachine (~> 1.0) rack (~> 1.0) thor (0.19.1) - thread_safe (0.3.4) + thread_safe (0.3.5) thumbs_up (0.6.7) activerecord statistics2 tilt (1.4.1) timers (4.0.1) hitimes - tins (1.3.4) + tins (1.3.5) turbolinks (2.5.3) coffee-rails twitter (5.14.0) @@ -517,7 +517,7 @@ GEM binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) - websocket (1.0.7) + websocket (1.2.1) xpath (2.0.0) nokogiri (~> 1.3) @@ -568,7 +568,7 @@ DEPENDENCIES ransack rspec-rails sass-rails (~> 5.0) - selenium-webdriver (~> 2.38.0) + selenium-webdriver sendgrid shoulda-matchers sidekiq diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 173f7cfd..6561bf64 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -1,8 +1,8 @@ //= require jquery //= require jquery_ujs //= require jquery_nested_form -//= require jquery.ui.datepicker -//= require jquery.ui.sortable +//= require jquery-ui/datepicker +//= require jquery-ui/sortable //= require jquery.timeago //= require jquery-timeago/locales/jquery.timeago.es //= require jquery-fileupload/basic diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 3641e5f1..8ba2ad2e 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -1,7 +1,7 @@ @import "bootstrap"; @import "compass/css3"; @import "compass/utilities/general"; -@import "jquery.ui.datepicker"; +@import "jquery-ui/datepicker"; @import "jquery.fileupload-ui"; @import "shared/base"; @import "shared/layout"; diff --git a/app/assets/stylesheets/shared/modules.scss b/app/assets/stylesheets/shared/modules.scss index 8325e905..33f92a03 100644 --- a/app/assets/stylesheets/shared/modules.scss +++ b/app/assets/stylesheets/shared/modules.scss @@ -9,8 +9,7 @@ .field_with_errors { @extend .has-error; - @extend .control-group; - @extend .error; + @extend .form-group; } #error_explanation { diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e66..6f26ea05 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -2,6 +2,7 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.precompile += %w( theme_one.css ) # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path From ce0d1ea9c2628b0e772edd03c003f3164a29f39d Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 13:33:06 -0600 Subject: [PATCH 11/42] Added rails_helper for rspec --- spec/rails_helper.rb | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 spec/rails_helper.rb diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 00000000..ad9077dd --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,51 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV['RAILS_ENV'] ||= 'test' +require 'spec_helper' +require File.expand_path('../../config/environment', __FILE__) +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } + +# Checks for pending migrations before tests are run. +# If you are not using ActiveRecord, you can remove this line. +ActiveRecord::Migration.maintain_test_schema! + +RSpec.configure do |config| + config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.use_transactional_fixtures = false + config.include FactoryGirl::Syntax::Methods + config.infer_spec_type_from_file_location! + include Warden::Test::Helpers + Warden.test_mode! + + config.before(:suite) do + DatabaseCleaner.clean_with(:truncation) + end + + config.before(:each) do + ActionMailer::Base.deliveries.clear + DatabaseCleaner.strategy = :transaction + end + + config.before(:each) do + DatabaseCleaner.start + end + + config.after(:each) do + DatabaseCleaner.clean + end +end From 3e990ab1ea0ddd514fa79ec386dfa283d8b96e5e Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 14:05:39 -0600 Subject: [PATCH 12/42] Fix strong params for service creation and update --- app/controllers/admins/services_controller.rb | 10 ++++++++-- app/models/service.rb | 2 -- spec/features/admin/manage_services_spec.rb | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/admins/services_controller.rb b/app/controllers/admins/services_controller.rb index baf2db3a..f0c47452 100644 --- a/app/controllers/admins/services_controller.rb +++ b/app/controllers/admins/services_controller.rb @@ -14,7 +14,7 @@ def edit end def create - @service = Service.new(params[:service]) + @service = Service.new(service_params) if @service.save redirect_to admins_services_path, notice: I18n.t('flash.service.created') @@ -26,7 +26,7 @@ def create def update @service = Service.find(params[:id]) - if @service.update_attributes(params[:service]) + if @service.update_attributes(service_params) redirect_to admins_services_path, notice: I18n.t('flash.service.updated') else render action: "edit" @@ -38,4 +38,10 @@ def destroy @service.destroy redirect_to admins_services_url, notice: I18n.t('flash.service.destroyed') end + + private + + def service_params + params.require(:service).permit(:name, messages: [:content, :status_id], service_fields: [:name]) + end end diff --git a/app/models/service.rb b/app/models/service.rb index a6350018..95538823 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -24,6 +24,4 @@ def self.chart_data query = query.group('services.id') query = query.order('services.id') end - - end diff --git a/spec/features/admin/manage_services_spec.rb b/spec/features/admin/manage_services_spec.rb index cac1fe1b..e19bf482 100644 --- a/spec/features/admin/manage_services_spec.rb +++ b/spec/features/admin/manage_services_spec.rb @@ -46,7 +46,7 @@ fill_in 'service[name]', with: 'Servicio nuevo' click_link 'Agregar mensaje' - within '#new_service' do + within first('.add-message .fields') do fill_in 'Mensaje', with: 'Mensaje para status abierto' select 'Abierto', from: 'Estatus' end From c5450c8e89d576ada77afcc694a0f57afd86dd42 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 15:18:00 -0600 Subject: [PATCH 13/42] Changed rspec expectations syntax --- spec/features/admin/manage_services_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/features/admin/manage_services_spec.rb b/spec/features/admin/manage_services_spec.rb index e19bf482..05a1badd 100644 --- a/spec/features/admin/manage_services_spec.rb +++ b/spec/features/admin/manage_services_spec.rb @@ -11,7 +11,7 @@ scenario 'I can see a list of services' do service = create(:service, name: 'service') visit admins_services_path - page.should have_content service.name + expect(page).to have_content service.name end scenario 'I can create a new service' do @@ -19,7 +19,7 @@ click_link 'Nuevo servicio' fill_in 'service[name]', with: 'Servicio nuevo' click_button 'Guardar' - page.should have_content t('flash.service.created') + expect(page).to have_content t('flash.service.created') end scenario 'I can edit a service' do @@ -27,15 +27,15 @@ visit edit_admins_service_path(service) fill_in 'service[name]', with: 'Servicio editado' click_button 'Guardar' - page.should have_content t('flash.service.updated') + expect(page).to have_content t('flash.service.updated') end scenario 'I can delete a service' do service = create(:service, name: 'service') visit admins_services_path click_link 'destroy-btn' - page.should_not have_content service.name - page.should have_content t('flash.service.destroyed') + expect(page).not_to have_content service.name + expect(page).to have_content t('flash.service.destroyed') end scenario 'I can create a new service with status message', js: true do @@ -53,7 +53,7 @@ click_button 'Guardar' - page.should have_content t('flash.service.created') + expect(page).to have_content t('flash.service.created') end end From 8253949234347eaf8c8e48ba933ca3f26393c31f Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 15:22:24 -0600 Subject: [PATCH 14/42] Changed rspec expectations syntax on manage_services_requests --- .../admin/manage_service_requests_spec.rb | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/spec/features/admin/manage_service_requests_spec.rb b/spec/features/admin/manage_service_requests_spec.rb index f3f582c8..70f5f78e 100644 --- a/spec/features/admin/manage_service_requests_spec.rb +++ b/spec/features/admin/manage_service_requests_spec.rb @@ -15,9 +15,9 @@ click_link t('admins.shared.sidebar.requests') end current_path == admins_service_requests_path - page.should have_content service_requests.first.service.name - page.should have_content service_requests[1].service.name - page.should have_content service_requests.last.service.name + expect(page).to have_content service_requests.first.service.name + expect(page).to have_content service_requests[1].service.name + expect(page).to have_content service_requests.last.service.name end scenario 'I can go to admin view for a service request' do @@ -25,8 +25,8 @@ click_link service_request.service.name current_path == edit_admins_service_request_path(service_request) - page.should have_content service_request.service.name - page.should have_content service_request.status + expect(page).to have_content service_request.service.name + expect(page).to have_content service_request.status end scenario 'I can see the requester full name and email' do @@ -34,9 +34,9 @@ click_link service_request.service.name current_path == edit_admins_service_request_path(service_request) - page.should have_content service_request.requester.name - page.should have_content service_request.requester.email - page.should have_content service_request.requester.id + expect(page).to have_content service_request.requester.name + expect(page).to have_content service_request.requester.email + expect(page).to have_content service_request.requester.id end scenario 'I can update the status of a service request' do @@ -46,7 +46,7 @@ select statuses.first.name, from: 'service_request[status_id]' end click_button t('update') - page.should have_content t('admins.service_requests.edit.status', status: statuses.first.name) + expect(page).to have_content t('admins.service_requests.edit.status', status: statuses.first.name) end scenario 'I can update the service of a service request' do @@ -57,7 +57,7 @@ end click_button t('update') current_path.should == edit_admins_service_request_path(service_request) - page.should have_content services.last.name + expect(page).to have_content services.last.name end scenario 'I can update the message of a service request', js: true do @@ -71,14 +71,14 @@ within '.stream' do # Message content should be posted as a comment on the service request - page.should have_content message.content + expect(page).to have_content message.content end end scenario 'I can delete a service request' do visit admins_service_requests_path page.find("a[href='#{admins_service_request_path(service_request)}']").click - page.should have_content t('flash.service_requests.destroyed') + expect(page).to have_content t('flash.service_requests.destroyed') end scenario 'I can post a comment on a service request' do @@ -89,15 +89,15 @@ click_button 'Comentar' end - page.should have_content 'Reporte ciudadano es lo mejor' - page.should have_content 'Tu comentario ha sido publicado' + expect(page).to have_content 'Reporte ciudadano es lo mejor' + expect(page).to have_content 'Tu comentario ha sido publicado' end scenario 'I can delete a comment on a service request' do comment = create(:comment, service_request: service_request) visit edit_admins_service_request_path(service_request) page.find("a[href='#{comment_path(comment)}']").click - page.should_not have_content comment.content + expect(page).not_to have_content comment.content end end From 29ce48bf9bfdf0f1f5f70feb4f33e40aa158093c Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 16:15:22 -0600 Subject: [PATCH 15/42] Fix strong params for admin service requests controller --- app/controllers/admins/service_requests_controller.rb | 5 +---- app/controllers/comments_controller.rb | 6 +++++- app/controllers/service_requests_controller.rb | 2 -- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/admins/service_requests_controller.rb b/app/controllers/admins/service_requests_controller.rb index 30b9a702..5584c83e 100644 --- a/app/controllers/admins/service_requests_controller.rb +++ b/app/controllers/admins/service_requests_controller.rb @@ -44,10 +44,7 @@ def destroy private - # Never trust parameters from the scary internet, only allow the white list through. def service_request_params - params.require(:service_request).permit(:name, :service_fields_attributes, :messages_attributes) + params.require(:service_request).permit(:name, :status_id, :service_fields_attributes, :messages_attributes) end - - end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index f923e187..1ef06a5f 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -4,7 +4,7 @@ class CommentsController < ApplicationController def create @current_session = current_user || current_admin - @comment = @current_session.comments.build(params[:comment]) + @comment = @current_session.comments.build(comment_params) if @comment.save flash[:success] = "Tu comentario ha sido publicado" redirect_to after_comment_path @@ -22,6 +22,10 @@ def destroy private + def comment_params + params.require(:comment).permit(:content, :service_request_id, :image) + end + def can_comment! deny_access unless user_signed_in? or admin_signed_in? end diff --git a/app/controllers/service_requests_controller.rb b/app/controllers/service_requests_controller.rb index c060a49d..95240192 100644 --- a/app/controllers/service_requests_controller.rb +++ b/app/controllers/service_requests_controller.rb @@ -48,9 +48,7 @@ def markers_for_gmap private - # Never trust parameters from the scary internet, only allow the white list through. def service_request_params params.require(:service_request).permit(:name, :service_fields_attributes, :messages_attributes) end - end From 52a8b11cba00707ac7fea54cef69caf1be58c860 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 16:19:33 -0600 Subject: [PATCH 16/42] Changed rspec expectations syntax on manage_status --- spec/features/admin/manage_status_spec.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/spec/features/admin/manage_status_spec.rb b/spec/features/admin/manage_status_spec.rb index 9f98f103..e277e2af 100644 --- a/spec/features/admin/manage_status_spec.rb +++ b/spec/features/admin/manage_status_spec.rb @@ -16,8 +16,7 @@ click_button t('save') end - page.should have_content t('flash.status.created') - + expect(page).to have_content t('flash.status.created') end scenario 'As an admin I can edit a status' do @@ -26,17 +25,14 @@ fill_in 'status[name]', with: 'Open' click_button t('save') - page.should have_content t('flash.status.updated') - + expect(page).to have_content t('flash.status.updated') end scenario 'As an admin I can see a list of statuses' do first, second, third = create_list(:status, 3) visit admins_services_path - page.should have_content(first.name) - page.should have_content(second.name) - page.should have_content(third.name) + expect(page).to have_content(first.name) + expect(page).to have_content(second.name) + expect(page).to have_content(third.name) end - - end From a571ffd00ae44579b07c84e8c86b8d013c22ee13 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 16:30:31 -0600 Subject: [PATCH 17/42] Fix strong params on statuses_controller --- app/controllers/admins/statuses_controller.rb | 10 ++++++++-- app/models/status.rb | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/admins/statuses_controller.rb b/app/controllers/admins/statuses_controller.rb index 2b1ddc92..b552e911 100644 --- a/app/controllers/admins/statuses_controller.rb +++ b/app/controllers/admins/statuses_controller.rb @@ -9,7 +9,7 @@ def new end def create - @status = Status.new(params[:status]) + @status = Status.new(status_params) if @status.save redirect_to admins_services_path, flash: { success: I18n.t('flash.status.created') } else @@ -23,10 +23,16 @@ def edit def update @status = Status.find(params[:id]) - if @status.update_attributes(params[:status]) + if @status.update_attributes(status_params) redirect_to admins_services_path, flash: { success: I18n.t('flash.status.updated') } else render :new end end + + private + + def status_params + params.require(:status).permit(:name, :is_default) + end end diff --git a/app/models/status.rb b/app/models/status.rb index f1ee78e0..9a365a6d 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -1,5 +1,5 @@ class Status < ActiveRecord::Base - #attr_accessible :name, :is_default + has_many :service_requests has_many :messages From 2dd7b2cc146dca2f8542151849830f53cb3e7437 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 16:34:31 -0600 Subject: [PATCH 18/42] Changed rspec expectations syntax on registration_spec --- spec/features/admin/registration_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/registration_spec.rb b/spec/features/admin/registration_spec.rb index 3b63a7e1..6b44b797 100644 --- a/spec/features/admin/registration_spec.rb +++ b/spec/features/admin/registration_spec.rb @@ -10,7 +10,7 @@ scenario 'As an admin I can see an edit link' do visit admins_services_path - page.should have_content 'Editar perfil' + expect(page).to have_content 'Editar perfil' end scenario 'As an admin I can update my profile' do @@ -21,7 +21,7 @@ fill_in 'admin[email]', with: 'nuevo@correo.com' end click_button 'Actualizar' - page.should have_content t('flash.admin.updated') + expect(page).to have_content t('flash.admin.updated') end end From 235a157c38f1051eb022b0da8c658a69ace07829 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 16:39:08 -0600 Subject: [PATCH 19/42] Fix strong params for registrations_controller --- app/controllers/admins/registrations_controller.rb | 8 +++++++- spec/features/admin/registration_spec.rb | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/admins/registrations_controller.rb b/app/controllers/admins/registrations_controller.rb index 2354d270..c30ffb7b 100644 --- a/app/controllers/admins/registrations_controller.rb +++ b/app/controllers/admins/registrations_controller.rb @@ -6,10 +6,16 @@ def edit def update @admin = current_admin - if @admin.update_attributes(params[:admin]) + if @admin.update_attributes(admin_params) redirect_to admins_services_path, notice: I18n.t('flash.admin.updated') else render :edit end end + + private + + def admin_params + params.require(:admin).permit(:name, :avatar, :email) + end end diff --git a/spec/features/admin/registration_spec.rb b/spec/features/admin/registration_spec.rb index 6b44b797..fc00139b 100644 --- a/spec/features/admin/registration_spec.rb +++ b/spec/features/admin/registration_spec.rb @@ -23,5 +23,4 @@ click_button 'Actualizar' expect(page).to have_content t('flash.admin.updated') end - end From 82a7a1fce9edaefe5f346de9d6753c05fd4fd646 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 17:20:18 -0600 Subject: [PATCH 20/42] Update twitter gem configuration --- config/initializers/twitter.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/initializers/twitter.rb b/config/initializers/twitter.rb index 70ea3a23..34406d95 100644 --- a/config/initializers/twitter.rb +++ b/config/initializers/twitter.rb @@ -1,6 +1,6 @@ -Twitter.configure do |config| - config.consumer_key = ENV['TWITTER_KEY'] - config.consumer_secret = ENV['TWITTER_SECRET'] - config.oauth_token = ENV['TWITTER_OAUTH_TOKEN'] - config.oauth_token_secret = ENV['TWITTER_OAUTH_TOKEN_SECRET'] -end +client = Twitter::REST::Client.new do |config| + config.consumer_key = ENV['TWITTER_KEY'] + config.consumer_secret = ENV['TWITTER_SECRET'] + config.access_token = ENV['TWITTER_OAUTH_TOKEN'] + config.access_token_secret = ENV['TWITTER_OAUTH_TOKEN_SECRET'] +end \ No newline at end of file From decd6e143022acfdc338a90e5be0708182a459d3 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 18:01:17 -0600 Subject: [PATCH 21/42] Changed rspec expectations syntax on feature specs --- spec/features/admin/manage_org_logos_spec.rb | 2 +- spec/features/admin/session_handling_spec.rb | 11 ++--- spec/features/user_account_flow.rb | 30 ++++++------ spec/features/user_dashboard.rb | 9 ++-- .../features/user_service_request_managing.rb | 46 +++++++++---------- 5 files changed, 44 insertions(+), 54 deletions(-) diff --git a/spec/features/admin/manage_org_logos_spec.rb b/spec/features/admin/manage_org_logos_spec.rb index ce61fab5..f9778e05 100644 --- a/spec/features/admin/manage_org_logos_spec.rb +++ b/spec/features/admin/manage_org_logos_spec.rb @@ -11,7 +11,7 @@ scenario 'I can visit the upload logos view' do page.find("a[href='#{new_admins_logo_path}']").click - page.should have_content "Agregar nuevo logo" + expect(page).to have_content "Agregar nuevo logo" end end diff --git a/spec/features/admin/session_handling_spec.rb b/spec/features/admin/session_handling_spec.rb index 49c34c06..def7fbbc 100644 --- a/spec/features/admin/session_handling_spec.rb +++ b/spec/features/admin/session_handling_spec.rb @@ -7,21 +7,20 @@ scenario 'signs in with valid email and password' do sign_in_admin admin - current_path.should == admins_dashboards_path + expect(current_path).to eq admins_dashboards_path end scenario 'cannot sign in with invalid email and password' do sign_in_admin admin, password: 'invalid' - current_path.should == new_admin_session_path - page.should have_content "Correo o contraseña inválidos" + expect(current_path).to eq new_admin_session_path + expect(page).to have_content "Correo o contraseña inválidos" end scenario 'signs out and is redirected to the root page' do sign_in_admin admin page.find('a[href="/admins/sign_out"]').click - page.should have_content 'Iniciar sesión' - current_url.should eq root_url + expect(page).to have_content 'Iniciar sesión' + expect(current_url).to eq root_url end - end diff --git a/spec/features/user_account_flow.rb b/spec/features/user_account_flow.rb index cac60245..e5f18bbb 100644 --- a/spec/features/user_account_flow.rb +++ b/spec/features/user_account_flow.rb @@ -6,16 +6,16 @@ OmniAuth.config.mock_auth[:facebook] = omniauth_facebook_valid_hash visit new_user_registration_path click_link 'Facebook' - page.should have_content 'Joe Bloggs' - current_url.should == root_url + expect(page).to have_content 'Joe Bloggs' + expect(current_url).to eq root_url end scenario 'through twitter button' do OmniAuth.config.mock_auth[:twitter] = omniauth_twitter_valid_hash visit new_user_registration_path click_link 'Twitter' - page.should have_content 'John Q Public' - current_url.should == root_url + expect(page).to have_content 'John Q Public' + expect(current_url).to eq root_url end scenario 'through registration form' do @@ -26,18 +26,17 @@ fill_in 'user[password_confirmation]', with: 'superinsecurepassword' end click_button 'Registrarme' - page.should have_content 'eddie@myemail.com' - current_url.should == root_url + expect(page).to have_content 'eddie@myemail.com' + expect(current_url).to eq root_url end scenario 'with invalid credentials redirects' do OmniAuth.config.mock_auth[:facebook] = :invalid visit new_user_registration_path click_link 'Facebook' - page.should have_content t('devise.omniauth_callbacks.failure', kind: 'Facebook', reason: 'Invalid') - current_url.should == new_user_session_url + expect(page).to have_content t('devise.omniauth_callbacks.failure', kind: 'Facebook', reason: 'Invalid') + expect(current_url).to eq new_user_session_url end - end feature 'As a user I can login' do @@ -48,16 +47,16 @@ OmniAuth.config.mock_auth[:facebook] = omniauth_facebook_valid_hash visit new_user_session_path click_link 'Facebook' - page.should have_content 'Joe Bloggs' - current_url.should == root_url + expect(page).to have_content 'Joe Bloggs' + expect(current_url).to eq root_url end scenario 'through twitter button' do OmniAuth.config.mock_auth[:twitter] = omniauth_twitter_valid_hash visit new_user_session_path click_link 'Twitter' - page.should have_content 'John Q Public' - current_url.should == root_url + expect(page).to have_content 'John Q Public' + expect(current_url).to eq root_url end scenario 'through registration form' do @@ -67,8 +66,7 @@ fill_in 'user[password]', with: 'superinsecurepassword' end click_button 'Entrar' - page.should have_content user.name - current_url.should eq root_url + expect(page).to have_content user.name + expect(current_url).to eq root_url end - end diff --git a/spec/features/user_dashboard.rb b/spec/features/user_dashboard.rb index 8a562b28..89190316 100644 --- a/spec/features/user_dashboard.rb +++ b/spec/features/user_dashboard.rb @@ -3,8 +3,8 @@ feature 'When I am in the dashboard' do context 'as a logged in user' do - let(:user) { create(:user)} - let!(:service_requests) {create_list(:service_request, 3)} + let(:user) { create(:user) } + let!(:service_requests) { create_list(:service_request, 3) } background do sign_in_user user @@ -12,11 +12,8 @@ scenario 'I can vote on an service_request', js: true do visit root_path - save_and_open_page page.find("a[href='/service_requests/#{service_requests.first.id}/vote']").click - page.should have_content('Votaste') + expect(page).to have_content('Votaste') end - end - end diff --git a/spec/features/user_service_request_managing.rb b/spec/features/user_service_request_managing.rb index 0f6740e7..5120ced5 100644 --- a/spec/features/user_service_request_managing.rb +++ b/spec/features/user_service_request_managing.rb @@ -9,14 +9,14 @@ context 'when not logged in user' do scenario 'get redirected to sign in page after trying to go to create a new service request' do visit new_service_request_path - current_url.should eq new_user_session_url + expect(current_url).to eq new_user_session_url end scenario 'can see a list of service requests' do service_requests = create_list(:service_request, 2) visit service_requests_path - page.should have_content service_requests.first.description.truncate(30) - page.should have_content service_requests.last.description.truncate(30) + expect(page).to have_content service_requests.first.description.truncate(30) + expect(page).to have_content service_requests.last.description.truncate(30) end scenario 'can search for service requests by min creation date' do @@ -29,9 +29,9 @@ fill_in 'q[date_gteq]', with: 3.days.ago.strftime("%Y-%m-%d").to_s click_button 'Buscar' end - page.should have_content service_requests.last.description.truncate(30) - page.should_not have_content service_requests.first.description.truncate(30) - page.should_not have_content service_requests[1].description.truncate(30) + expect(page).to have_content service_requests.last.description.truncate(30) + expect(page).not_to have_content service_requests.first.description.truncate(30) + expect(page).not_to have_content service_requests[1].description.truncate(30) end scenario 'can search for service requests by max creation date' do @@ -44,9 +44,9 @@ fill_in 'q[date_lteq]', with: 4.days.ago.strftime("%Y-%m-%d").to_s click_button 'Buscar' end - page.should_not have_content service_requests.last.description.truncate(30) - page.should have_content service_requests.first.description.truncate(30) - page.should have_content service_requests[1].description.truncate(30) + expect(page).not_to have_content service_requests.last.description.truncate(30) + expect(page).to have_content service_requests.first.description.truncate(30) + expect(page).to have_content service_requests[1].description.truncate(30) end scenario 'can search for service requests by service' do @@ -56,9 +56,9 @@ select service_requests.first.service.name, from: 'q[service_id_eq]' click_button 'Buscar' end - page.should have_content service_requests.first.description.truncate(30) - page.should_not have_content service_requests[1].description.truncate(30) - page.should_not have_content service_requests.last.description.truncate(30) + expect(page).to have_content service_requests.first.description.truncate(30) + expect(page).to have_content service_requests[1].description.truncate(30) + expect(page).to have_content service_requests.last.description.truncate(30) end scenario 'can search for service requests by status' do @@ -68,17 +68,15 @@ select service_requests.first.status.name, from: 'q[status_id_eq]' click_button 'Buscar' end - page.should have_content service_requests.first.description.truncate(30) - page.should_not have_content service_requests[1].description.truncate(30) - page.should_not have_content service_requests.last.description.truncate(30) + expect(page).to have_content service_requests.first.description.truncate(30) + expect(page).not_to have_content service_requests[1].description.truncate(30) + expect(page).not_to have_content service_requests.last.description.truncate(30) end scenario 'can go see a service request' do visit service_request_path(service_request) - page.should have_content(service_request.service.name) + expect(page).to have_content(service_request.service.name) end - - end context 'when logged in user' do @@ -98,13 +96,13 @@ fill_in "service_request[service_fields][#{service.service_fields.first.name}]", with: 'more fields' click_button 'Guardar' end - page.should have_content '123 Governor Dr, San Diego, CA 92122' + expect(page).to have_content '123 Governor Dr, San Diego, CA 92122' end scenario 'can vote on an service request', js: true do visit service_request_path(service_request) page.find("a[href='/requests/#{service_request.id}/vote']").click - page.should have_content('Votaste') + expect(page).to have_content('Votaste') end scenario 'can comment on a service request' do @@ -115,11 +113,9 @@ fill_in 'comment[content]', with: comment_content click_button 'Comentar' end - current_url.should eq service_request_url(service_request) - page.should have_content(comment_content) - page.should have_xpath("//img[@src=\"/uploads/comment/image/1/comment_avatar.png\"]") + expect(current_url).to eq service_request_url(service_request) + expect(page).to have_content(comment_content) + expect(page).to have_xpath("//img[@src=\"/uploads/comment/image/1/comment_avatar.png\"]") end - end - end From 8dd5a1b87dc821599a7661c5a4aad002f2769024 Mon Sep 17 00:00:00 2001 From: abisosa Date: Wed, 11 Mar 2015 18:37:43 -0600 Subject: [PATCH 22/42] Exclude fog credentials from test environment --- config/initializers/carrierwave.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 63e4f3e3..7f6681ca 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -1,16 +1,16 @@ CarrierWave.configure do |config| - config.fog_credentials = { - :provider => 'AWS', - :aws_access_key_id => ENV['AWS_KEY'], - :aws_secret_access_key => ENV['AWS_SECRET'] - } - config.fog_directory = ENV['S3_BUCKET'] + unless Rails.env.test? + config.fog_credentials = { + :provider => 'AWS', + :aws_access_key_id => ENV['AWS_KEY'], + :aws_secret_access_key => ENV['AWS_SECRET'] + } + config.fog_directory = ENV['S3_BUCKET'] + end config.fog_public = true # config.root = Rails.root.join('tmp') # config.cache_dir = 'files' - config.permissions = 0600 - config.storage(Rails.env.test? || Rails.env.development? ? :file : :fog) config.enable_processing = false if Rails.env.test? end From dcb4231fd2a1d89ce870a14c8f32018dc4041960 Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 12 Mar 2015 12:52:41 -0600 Subject: [PATCH 23/42] Added spec for service request creation --- Gemfile.lock | 6 +++--- .../admins/service_requests_controller.rb | 2 +- config/initializers/assets.rb | 2 +- .../admin/manage_service_requests_spec.rb | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 84883944..66f61c21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -280,7 +280,7 @@ GEM jquery-ui-rails (5.0.3) railties (>= 3.2.16) json (1.8.2) - jwt (1.4.0) + jwt (1.4.1) kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -405,7 +405,7 @@ GEM rest-client (1.7.3) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) - rspec-core (3.2.1) + rspec-core (3.2.2) rspec-support (~> 3.2.0) rspec-expectations (3.2.0) diff-lcs (>= 1.2.0, < 2.0) @@ -512,7 +512,7 @@ GEM raindrops (~> 0.7) warden (1.2.3) rack (>= 1.0) - web-console (2.1.1) + web-console (2.1.2) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) railties (>= 4.0) diff --git a/app/controllers/admins/service_requests_controller.rb b/app/controllers/admins/service_requests_controller.rb index 5584c83e..15eb0e4d 100644 --- a/app/controllers/admins/service_requests_controller.rb +++ b/app/controllers/admins/service_requests_controller.rb @@ -45,6 +45,6 @@ def destroy private def service_request_params - params.require(:service_request).permit(:name, :status_id, :service_fields_attributes, :messages_attributes) + params.require(:service_request).permit(:address, :status_id, :service_id, :description, :media, :anonymous, :lat, :lng) end end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 6f26ea05..3b9f7c97 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -2,7 +2,7 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' -Rails.application.config.assets.precompile += %w( theme_one.css ) +Rails.application.config.assets.precompile += %w( theme_one.css admin.css ) # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path diff --git a/spec/features/admin/manage_service_requests_spec.rb b/spec/features/admin/manage_service_requests_spec.rb index 70f5f78e..e2677977 100644 --- a/spec/features/admin/manage_service_requests_spec.rb +++ b/spec/features/admin/manage_service_requests_spec.rb @@ -29,6 +29,19 @@ expect(page).to have_content service_request.status end + scenario 'I can create a service request' do + services = create_list(:service, 2) + visit new_admins_service_request_path + + select services.first.name, from: 'service_request[service_id]' + fill_in 'service_request[address]', with: 'An address #111' + set_location_as(lat: "12.12", lng: "12.13") + fill_in 'service_request[description]', with: 'Request description' + click_button t('save') + + expect(page).to have_content t('flash.service_requests.created') + end + scenario 'I can see the requester full name and email' do visit admins_service_requests_path click_link service_request.service.name @@ -100,4 +113,8 @@ expect(page).not_to have_content comment.content end + def set_location_as(lat:, lng:) + find("#lat").set(lat) + find("#lng").set(lng) + end end From aeec00079f724a25c49b24e45d2d2f963a2872db Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 12 Mar 2015 13:19:08 -0600 Subject: [PATCH 24/42] Changed current path expectations on service_requests_spec --- spec/features/admin/manage_service_requests_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/admin/manage_service_requests_spec.rb b/spec/features/admin/manage_service_requests_spec.rb index e2677977..36e8f6a2 100644 --- a/spec/features/admin/manage_service_requests_spec.rb +++ b/spec/features/admin/manage_service_requests_spec.rb @@ -14,7 +14,7 @@ within '.sidebar-nav' do click_link t('admins.shared.sidebar.requests') end - current_path == admins_service_requests_path + expect(current_path).to eq admins_service_requests_path expect(page).to have_content service_requests.first.service.name expect(page).to have_content service_requests[1].service.name expect(page).to have_content service_requests.last.service.name @@ -24,7 +24,7 @@ visit admins_service_requests_path click_link service_request.service.name - current_path == edit_admins_service_request_path(service_request) + expect(current_path).to eq edit_admins_service_request_path(service_request) expect(page).to have_content service_request.service.name expect(page).to have_content service_request.status end @@ -46,7 +46,7 @@ visit admins_service_requests_path click_link service_request.service.name - current_path == edit_admins_service_request_path(service_request) + expect(current_path).to eq edit_admins_service_request_path(service_request) expect(page).to have_content service_request.requester.name expect(page).to have_content service_request.requester.email expect(page).to have_content service_request.requester.id @@ -69,7 +69,7 @@ select services.last.name, from: 'service_request[service_id]' end click_button t('update') - current_path.should == edit_admins_service_request_path(service_request) + expect(current_path).to eq edit_admins_service_request_path(service_request) expect(page).to have_content services.last.name end From ec71bcf2943c92b9a80530d0bdeb5b1f4310164a Mon Sep 17 00:00:00 2001 From: abisosa Date: Tue, 17 Mar 2015 14:36:21 -0600 Subject: [PATCH 25/42] Fix: theme selection by admin --- app/controllers/admins/application_settings_controller.rb | 5 ++++- app/views/admins/dashboards/design.html.haml | 2 +- config/initializers/assets.rb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/admins/application_settings_controller.rb b/app/controllers/admins/application_settings_controller.rb index 047f01ec..68b3e0ee 100644 --- a/app/controllers/admins/application_settings_controller.rb +++ b/app/controllers/admins/application_settings_controller.rb @@ -15,7 +15,10 @@ def map_constraints def update_setting(klass) @setting = klass.get - @setting.update_attributes(params[:setting]) + @setting.update_attributes(setting_params) end + def setting_params + params.require(:setting).permit(:name) + end end diff --git a/app/views/admins/dashboards/design.html.haml b/app/views/admins/dashboards/design.html.haml index f16d8035..664b85e3 100644 --- a/app/views/admins/dashboards/design.html.haml +++ b/app/views/admins/dashboards/design.html.haml @@ -27,7 +27,7 @@ %p= t('.no_logos') %h2= t('.color_scheme') -= form_for ApplicationSettings::CssTheme.get, url: css_theme_admins_application_settings_path(@default_css_theme, format: :json), remote: true, as: :setting do |f| += form_for ApplicationSettings::CssTheme.get, url: css_theme_admins_application_settings_path(@default_css_theme, format: :json), remote: true, as: :setting, method: :put do |f| .row - ApplicationSettings::CssTheme::THEMES.each do |theme| .col-md-3 diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 3b9f7c97..e426c72d 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -2,7 +2,7 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' -Rails.application.config.assets.precompile += %w( theme_one.css admin.css ) +Rails.application.config.assets.precompile += %w( theme_one.css theme_two.css theme_three.css theme_four.css admin.css ) # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path From 1cb58169c610d9da54d7b6df3eaaca600e5036df Mon Sep 17 00:00:00 2001 From: abisosa Date: Tue, 17 Mar 2015 15:15:14 -0600 Subject: [PATCH 26/42] Changed application.js to coffeescript --- app/assets/javascripts/application.js | 16 ---------------- app/assets/javascripts/application.js.coffee | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/javascripts/application.js.coffee diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js deleted file mode 100644 index 6561bf64..00000000 --- a/app/assets/javascripts/application.js +++ /dev/null @@ -1,16 +0,0 @@ -//= require jquery -//= require jquery_ujs -//= require jquery_nested_form -//= require jquery-ui/datepicker -//= require jquery-ui/sortable -//= require jquery.timeago -//= require jquery-timeago/locales/jquery.timeago.es -//= require jquery-fileupload/basic -//= require bootstrap/dropdown -//= require bootstrap/collapse -//= require bootstrap/modal -//= require highcharts -//= require highcharts/modules/exporting -//= require jquery.tablesorter -//= require turbolinks -//= require_tree . diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee new file mode 100644 index 00000000..cfa4fafe --- /dev/null +++ b/app/assets/javascripts/application.js.coffee @@ -0,0 +1,15 @@ +#= require jquery +#= require jquery_ujs +#= require jquery_nested_form +#= require jquery-ui/datepicker +#= require jquery-ui/sortable +#= require jquery.timeago +#= require jquery-timeago/locales/jquery.timeago.es +#= require jquery-fileupload/basic +#= require bootstrap/dropdown +#= require bootstrap/collapse +#= require bootstrap/modal +#= require highcharts +#= require highcharts/modules/exporting +#= require jquery.tablesorter +#= require turbolinks From 5499bf90ea2ed66b3683aeaef7a4afb0b196e5ee Mon Sep 17 00:00:00 2001 From: abisosa Date: Tue, 17 Mar 2015 16:06:56 -0600 Subject: [PATCH 27/42] Fix failing test and seeds with right constraints --- app/models/message.rb | 2 +- db/seeds.rb | 12 +++++++++++- spec/features/admin/manage_service_requests_spec.rb | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/models/message.rb b/app/models/message.rb index 357db448..58f232e3 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -4,7 +4,7 @@ class Message < ActiveRecord::Base belongs_to :service belongs_to :status - scope :with_status,-> (status_id) { + scope :with_status, -> (status_id) { where(status_id: status_id) } end diff --git a/db/seeds.rb b/db/seeds.rb index 298522a4..7ea8d011 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,5 +1,6 @@ # Destroy'em all Admin.destroy_all +User.destroy_all Service.destroy_all ServiceRequest.destroy_all Status.destroy_all @@ -18,16 +19,18 @@ r = { service_id: c.id, description: "Parece que la toma esta tapada.", + address: "Calle Benito Juarez", lat: "17.07610765289478", lng: "-96.71955585479736", status_id: status.id } -user.service_requests.build(r).save +user.service_requests.build(r) c = Service.create(name: "Ruptura de tuberia") r = { service_id: c.id, description: "Se necesita atender una tuberia que se acaba de romper.", + address: "Calle Benito Juarez", lat: "17.05811444402115", lng: "-96.72695453226964", status_id: status.id @@ -38,6 +41,7 @@ r = { service_id: c.id, description: "Acabo de ver una fuga en el Parque.", + address: "Calle Benito Juarez", lat: "17.065020737526442", lng: "-96.72539234161377", status_id: status.id @@ -49,6 +53,7 @@ anonymous: true, service_id: c.id, description: "Mi vecino dejo abierta una manguera.", + address: "Calle Benito Juarez", lat: "17.065593", lng: "-96.724253", status_id: status.id @@ -59,6 +64,7 @@ r = { service_id: c.id, description: "Parece ser que se robaron una alcantarilla.", + address: "Calle Benito Juarez", lat: "17.068128422248872", lng: "-96.7195987701416", status_id: status.id @@ -69,6 +75,7 @@ r = { service_id: c.id, description: "La alcantarilla tiene mal olor y fugas de agua.", + address: "Calle Benito Juarez", lat: "17.07714402", lng: "-96.71353313", status_id: status.id @@ -79,6 +86,7 @@ r = { service_id: c.id, description: "El drenaje tiene fallas desde hace dos dias.", + address: "Calle Benito Juarez", lat: "17.060477065746248", lng: "-96.72543525695801", status_id: status.id @@ -94,6 +102,7 @@ end r = { service_id: special_services[0].id, + address: "Calle Benito Juarez", description: "El dia de hoy no paso mi servicio!.", lat: "17.046243761147192", lng: "-96.76591701931939", @@ -105,6 +114,7 @@ r = { service_id: special_services[1].id, description: "Hoy en la manana note que mi medidor habia sido robado.", + address: "Calle Benito Juarez", lat: "17.06185146120198", lng: "-96.72612190246582", service_fields: ["Jose del Bosque", "9981427729"], diff --git a/spec/features/admin/manage_service_requests_spec.rb b/spec/features/admin/manage_service_requests_spec.rb index 36e8f6a2..d9495afc 100644 --- a/spec/features/admin/manage_service_requests_spec.rb +++ b/spec/features/admin/manage_service_requests_spec.rb @@ -74,7 +74,7 @@ end scenario 'I can update the message of a service request', js: true do - message = create(:message, service: service_request.service) + message = create(:message, service: service_request.service, status: service_request.status) visit edit_admins_service_request_path(service_request) within '.edit_service_request' do select message.status.name, from: 'service_request[status_id]' From c0b14743e9577b85540d651c2751d3b63ca4fdfe Mon Sep 17 00:00:00 2001 From: abisosa Date: Tue, 17 Mar 2015 16:36:23 -0600 Subject: [PATCH 28/42] Change expectations syntax on user_mailer_spec --- spec/mailers/user_mailer_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index bfec5a58..624bd2c2 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -12,7 +12,7 @@ it "sends the email" do reset_email mail.deliver! - ActionMailer::Base.deliveries.size.should be 1 + expect(ActionMailer::Base.deliveries.size).to eq 1 end it "sends an email to the requester" do From 8736a0aa7f31d0cf50babebb5e17a74de56d2384 Mon Sep 17 00:00:00 2001 From: abisosa Date: Tue, 17 Mar 2015 17:15:06 -0600 Subject: [PATCH 29/42] Can't delete service when it has associated requests --- app/models/service.rb | 4 ++++ app/views/admins/services/index.html.haml | 2 +- spec/features/admin/manage_services_spec.rb | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/models/service.rb b/app/models/service.rb index 95538823..a09ed8aa 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -24,4 +24,8 @@ def self.chart_data query = query.group('services.id') query = query.order('services.id') end + + def cant_be_deleted? + service_requests.any? + end end diff --git a/app/views/admins/services/index.html.haml b/app/views/admins/services/index.html.haml index 2688f7ae..762811c0 100644 --- a/app/views/admins/services/index.html.haml +++ b/app/views/admins/services/index.html.haml @@ -27,7 +27,7 @@ .btn-group = link_to edit_admins_service_path(service), class: 'btn btn-default' do %span.glyphicon.glyphicon-wrench - = link_to admins_service_path(service), method: :delete, data: { confirm: t('alerts.destroy_confirmation') }, id: 'destroy-btn', class: 'btn btn-danger' do + = link_to admins_service_path(service), method: :delete, data: { confirm: t('alerts.destroy_confirmation') }, id: 'destroy-btn', class: 'btn btn-danger', disabled: service.cant_be_deleted? do %span.glyphicon.glyphicon-trash %h2= t('.statuses') diff --git a/spec/features/admin/manage_services_spec.rb b/spec/features/admin/manage_services_spec.rb index 05a1badd..332bcfcf 100644 --- a/spec/features/admin/manage_services_spec.rb +++ b/spec/features/admin/manage_services_spec.rb @@ -38,6 +38,14 @@ expect(page).to have_content t('flash.service.destroyed') end + scenario 'I can delete a service unless it has associated requests' do + service = create(:service, name: 'service') + create :service_request, service: service + visit admins_services_path + expect(destroy_link).to be_disabled + expect(page).to have_content service.name + end + scenario 'I can create a new service with status message', js: true do create(:status, name: 'Abierto') @@ -56,4 +64,7 @@ expect(page).to have_content t('flash.service.created') end + def destroy_link + find("#destroy-btn") + end end From 0acf9c459e7a965886e665ac3f7622ff6b4c0d20 Mon Sep 17 00:00:00 2001 From: abisosa Date: Tue, 17 Mar 2015 18:05:36 -0600 Subject: [PATCH 30/42] WIP: Fix for highcharts loading error --- Gemfile.lock | 2 +- app/assets/javascripts/dashboards.js.coffee | 49 +++--- app/assets/javascripts/graph.js.coffee | 3 +- app/assets/javascripts/main.js.coffee | 148 +++++++++--------- .../javascripts/service_requets.js.coffee | 72 ++++----- app/assets/javascripts/services.js.coffee | 6 +- 6 files changed, 139 insertions(+), 141 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 66f61c21..b519003e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -374,7 +374,7 @@ GEM sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.5) + rails-dom-testing (1.0.6) activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) diff --git a/app/assets/javascripts/dashboards.js.coffee b/app/assets/javascripts/dashboards.js.coffee index e33b3d7a..b94a9c30 100644 --- a/app/assets/javascripts/dashboards.js.coffee +++ b/app/assets/javascripts/dashboards.js.coffee @@ -1,32 +1,31 @@ -jQuery -> - $('.js-sortable').sortable( - revert: 100 - cursor: "move" - opacity: 0.8 - update: (e, ui) -> - container = ui.item.parents('.js-sortable') - ids = $(container).sortable('serialize') - post_url = $(container).data('url') +$('.js-sortable').sortable( + revert: 100 + cursor: "move" + opacity: 0.8 + update: (e, ui) -> + container = ui.item.parents('.js-sortable') + ids = $(container).sortable('serialize') + post_url = $(container).data('url') - $.post post_url, ids, (data, status) -> - console.log ids - ).disableSelection() + $.post post_url, ids, (data, status) -> + console.log ids +).disableSelection() - $('body').on 'click', '.js-form-submitter', -> - $(@).closest('form').submit() - $(@).next('.js-save-box').removeClass('hide') +$('body').on 'click', '.js-form-submitter', -> + $(@).closest('form').submit() + $(@).next('.js-save-box').removeClass('hide') - $('body').on 'click', '.js-ajax-button', -> - $(@).next('.js-save-box').removeClass('hide') +$('body').on 'click', '.js-ajax-button', -> + $(@).next('.js-save-box').removeClass('hide') - $('body').on 'click', '.js-ajax-sender', -> - $(@).val($(@).data('processing-label')) +$('body').on 'click', '.js-ajax-sender', -> + $(@).val($(@).data('processing-label')) - $('.edit_setting').bind('ajax:success', (e, data, status, xhr) -> - setTimeout (-> - $('.js-save-box','.edit_setting' ).addClass('hide') - ), 500 - ).bind 'ajax:error', (e, xhr, status, error) -> - $('.js-save-box', @).addClass('hide') +$('.edit_setting').bind('ajax:success', (e, data, status, xhr) -> + setTimeout (-> + $('.js-save-box','.edit_setting' ).addClass('hide') + ), 500 +).bind 'ajax:error', (e, xhr, status, error) -> + $('.js-save-box', @).addClass('hide') diff --git a/app/assets/javascripts/graph.js.coffee b/app/assets/javascripts/graph.js.coffee index 5896fab3..265e0a1b 100644 --- a/app/assets/javascripts/graph.js.coffee +++ b/app/assets/javascripts/graph.js.coffee @@ -1,5 +1,4 @@ -jQuery -> - +$(document).on 'ready page:load', -> if $('#reports-chart').length > 0 chart_data = $('#reports-chart').data('chart-data') status_names = $('#reports-chart').data('status-names') diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 01ebbae0..10de524c 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -1,88 +1,88 @@ -$ -> - # The body element has the controller and action name as class attribute - current_controller_and_action = $("body").attr('class') - $tabs = $('.menu a') - # Activate the tab for the current controller and action - $tabs.filter("[class='#{current_controller_and_action}']").addClass('active') - # On click change active tab - $tabs.click -> - $tabs.removeClass 'active' - $(@).addClass 'active' +# The body element has the controller and action name as class attribute +current_controller_and_action = $("body").attr('class') - $('#service_request_status_id').change -> - status_id = $(@).val() - service_id = $(@).data('service-id') - $.ajax( - url: "/admins/services/#{service_id}/messages" - data: - status_id: status_id - type: 'GET' - ) +$tabs = $('.menu a') +# Activate the tab for the current controller and action +$tabs.filter("[class='#{current_controller_and_action}']").addClass('active') +# On click change active tab +$tabs.click -> + $tabs.removeClass 'active' + $(@).addClass 'active' + +$('#service_request_status_id').change -> + status_id = $(@).val() + service_id = $(@).data('service-id') + $.ajax( + url: "/admins/services/#{service_id}/messages" + data: + status_id: status_id + type: 'GET' + ) - $(window).resize -> - $("#main_width").html $(window).width() +$(window).resize -> + $("#main_width").html $(window).width() - setTimeout -> - hideFlashMessages() - ,4000 +setTimeout -> + hideFlashMessages() +,4000 - hideFlashMessages = -> - $(".alert").fadeOut('slow') +hideFlashMessages = -> + $(".alert").fadeOut('slow') - if $("#new-report-map").length > 0 - newReportMap = $('#new-report-map') - mapConstraints = newReportMap.data('map-constraints') - newReportMap.geolocateMap({ - html5: true - zoom: parseInt(mapConstraints.zoom) - sync_input: - longitude: '#lng' - latitude: '#lat' - address: '#address' - bounds: - sw: - latitude: mapConstraints.bounds[0][0] - longitude: mapConstraints.bounds[0][1] - ne: - latitude: mapConstraints.bounds[1][0] - longitude: mapConstraints.bounds[1][1] - }) +if $("#new-report-map").length > 0 + newReportMap = $('#new-report-map') + mapConstraints = newReportMap.data('map-constraints') + newReportMap.geolocateMap({ + html5: true + zoom: parseInt(mapConstraints.zoom) + sync_input: + longitude: '#lng' + latitude: '#lat' + address: '#address' + bounds: + sw: + latitude: mapConstraints.bounds[0][0] + longitude: mapConstraints.bounds[0][1] + ne: + latitude: mapConstraints.bounds[1][0] + longitude: mapConstraints.bounds[1][1] + }) - if $("#reports-map").length > 0 - reports_markers = $(".recent-report-sum").map -> - return { lat: $(this).data("lat"), lng: $(this).data("lng"), description: $(this).data("description") } +if $("#reports-map").length > 0 + reports_markers = $(".recent-report-sum").map -> + return { lat: $(this).data("lat"), lng: $(this).data("lng"), description: $(this).data("description") } - $map = $(".map") - lat = $map.attr("data-latitude") - lng = $map.attr("data-longitude") + $map = $(".map") + lat = $map.attr("data-latitude") + lng = $map.attr("data-longitude") - report_map = new PinDropper('#reports-map', reports_markers, {center: new google.maps.LatLng(lat, lng)}) + report_map = new PinDropper('#reports-map', reports_markers, {center: new google.maps.LatLng(lat, lng)}) - $(".filters").on("ajax:success", (e, data, status, xhr) -> - report_map.updateMarkers( - $.map data['service_requests'], (val, index)-> - return { lat: val.lat, lng: val.long, description: val.description } - ) - submit_button = $(this).find('.js-ajax-sender') - submit_button.val(submit_button.data('stealth-label')) - ).bind "ajax:error", (e, xhr, status, error) -> - console.log 'ERROR!' + $(".filters").on("ajax:success", (e, data, status, xhr) -> + report_map.updateMarkers( + $.map data['service_requests'], (val, index)-> + return { lat: val.lat, lng: val.long, description: val.description } + ) + submit_button = $(this).find('.js-ajax-sender') + submit_button.val(submit_button.data('stealth-label')) + ).bind "ajax:error", (e, xhr, status, error) -> + console.log 'ERROR!' - if $("#show-report-map").length > 0 - $map = $("#show-report-map") - lat = $map.attr("data-latitude") - lng = $map.attr("data-longitude") +if $("#show-report-map").length > 0 + $map = $("#show-report-map") + lat = $map.attr("data-latitude") + lng = $map.attr("data-longitude") - reports_markers = [ - { - lat: $map.data("latitude") - lng: $map.data("longitude") - description: $map.data("description") - } - ] + reports_markers = [ + { + lat: $map.data("latitude") + lng: $map.data("longitude") + description: $map.data("description") + } + ] - $map.pinDropper(reports_markers, { - center: new google.maps.LatLng(lat, lng) - }) + $map.pinDropper(reports_markers, { + center: new google.maps.LatLng(lat, lng) + }) diff --git a/app/assets/javascripts/service_requets.js.coffee b/app/assets/javascripts/service_requets.js.coffee index 82927eb8..de015e5f 100644 --- a/app/assets/javascripts/service_requets.js.coffee +++ b/app/assets/javascripts/service_requets.js.coffee @@ -1,42 +1,42 @@ -$ -> - $("abbr.timeago").timeago() - $('.datepicker').datepicker({ - dateFormat: 'yy-mm-dd' - }) +$("abbr.timeago").timeago() - $('.js-load_service_fields').change -> - $.ajax( - url: '/services/load_service_fields' - data: { - id: $(@).val() - } - ) +$('.datepicker').datepicker({ + dateFormat: 'yy-mm-dd' +}) - $('.blocked').click (e) -> - e.preventDefault() - receivedMessage = $(@).data('message') - if receivedMessage? - alert receivedMessage - else - alert 'Es necesario que te registres en el sistema para realizar esta operación.' +$('.js-load_service_fields').change -> + $.ajax( + url: '/services/load_service_fields' + data: { + id: $(@).val() + } + ) - if window.FileReader - $('.js-image-preview').change (event) -> - files = event.target.files[0] - reader = new FileReader() - reader.onload = ((theFile) -> - return (e) -> - $('.image_preview').html(""))(files) - reader.readAsDataURL(files) +$('.blocked').click (e) -> + e.preventDefault() + receivedMessage = $(@).data('message') + if receivedMessage? + alert receivedMessage + else + alert 'Es necesario que te registres en el sistema para realizar esta operación.' - $(".sortable_table").tablesorter( - cssHeader: 'table-header' - sortList: [[0,0]] - ) +if window.FileReader + $('.js-image-preview').change (event) -> + files = event.target.files[0] + reader = new FileReader() + reader.onload = ((theFile) -> + return (e) -> + $('.image_preview').html(""))(files) + reader.readAsDataURL(files) + +$(".sortable_table").tablesorter( + cssHeader: 'table-header' + sortList: [[0,0]] +) - $('.sortable_table .table-header').click -> - $('.table-header').find('i').removeClass('icon-chevron-up').addClass('icon-chevron-down') - $(@).find('.icon-chevron-down').removeClass('icon-chevron-down').addClass('icon-chevron-up') - if $(@).hasClass('headerSortUp') - $(@).find('.icon-chevron-up').removeClass('icon-chevron-up').addClass('icon-chevron-down') +$('.sortable_table .table-header').click -> + $('.table-header').find('i').removeClass('icon-chevron-up').addClass('icon-chevron-down') + $(@).find('.icon-chevron-down').removeClass('icon-chevron-down').addClass('icon-chevron-up') + if $(@).hasClass('headerSortUp') + $(@).find('.icon-chevron-up').removeClass('icon-chevron-up').addClass('icon-chevron-down') diff --git a/app/assets/javascripts/services.js.coffee b/app/assets/javascripts/services.js.coffee index 2fec7871..bc0fbbf7 100644 --- a/app/assets/javascripts/services.js.coffee +++ b/app/assets/javascripts/services.js.coffee @@ -1,3 +1,3 @@ -$ -> - if $('#bounding-box-map').length - $('#bounding-box-map').mapBounder($('.js-save-map')) + +if $('#bounding-box-map').length + $('#bounding-box-map').mapBounder($('.js-save-map')) From ad0015e910b3fb98550922f9885a44bcec67ede3 Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 19 Mar 2015 11:37:28 -0600 Subject: [PATCH 31/42] Fix failing google maps render --- app/assets/javascripts/application.js.coffee | 1 + app/assets/javascripts/comments.js.coffee | 3 +- app/assets/javascripts/dashboards.js.coffee | 49 +++--- app/assets/javascripts/main.js.coffee | 150 +++++++++--------- .../javascripts/service_requets.js.coffee | 72 ++++----- app/assets/javascripts/services.js.coffee | 6 +- app/views/layouts/admins.html.haml | 5 +- 7 files changed, 143 insertions(+), 143 deletions(-) diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index cfa4fafe..d280e509 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -13,3 +13,4 @@ #= require highcharts/modules/exporting #= require jquery.tablesorter #= require turbolinks +#= require_tree . \ No newline at end of file diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee index 0325a427..d610913f 100644 --- a/app/assets/javascripts/comments.js.coffee +++ b/app/assets/javascripts/comments.js.coffee @@ -1,5 +1,4 @@ -jQuery -> - +$ -> $('.image_container').click (e) -> $('#comment_image').click() diff --git a/app/assets/javascripts/dashboards.js.coffee b/app/assets/javascripts/dashboards.js.coffee index b94a9c30..142e186a 100644 --- a/app/assets/javascripts/dashboards.js.coffee +++ b/app/assets/javascripts/dashboards.js.coffee @@ -1,31 +1,32 @@ -$('.js-sortable').sortable( - revert: 100 - cursor: "move" - opacity: 0.8 - update: (e, ui) -> - container = ui.item.parents('.js-sortable') - ids = $(container).sortable('serialize') - post_url = $(container).data('url') +$ -> + $('.js-sortable').sortable( + revert: 100 + cursor: "move" + opacity: 0.8 + update: (e, ui) -> + container = ui.item.parents('.js-sortable') + ids = $(container).sortable('serialize') + post_url = $(container).data('url') - $.post post_url, ids, (data, status) -> - console.log ids -).disableSelection() + $.post post_url, ids, (data, status) -> + console.log ids + ).disableSelection() -$('body').on 'click', '.js-form-submitter', -> - $(@).closest('form').submit() - $(@).next('.js-save-box').removeClass('hide') + $('body').on 'click', '.js-form-submitter', -> + $(@).closest('form').submit() + $(@).next('.js-save-box').removeClass('hide') -$('body').on 'click', '.js-ajax-button', -> - $(@).next('.js-save-box').removeClass('hide') + $('body').on 'click', '.js-ajax-button', -> + $(@).next('.js-save-box').removeClass('hide') -$('body').on 'click', '.js-ajax-sender', -> - $(@).val($(@).data('processing-label')) + $('body').on 'click', '.js-ajax-sender', -> + $(@).val($(@).data('processing-label')) -$('.edit_setting').bind('ajax:success', (e, data, status, xhr) -> - setTimeout (-> - $('.js-save-box','.edit_setting' ).addClass('hide') - ), 500 -).bind 'ajax:error', (e, xhr, status, error) -> - $('.js-save-box', @).addClass('hide') + $('.edit_setting').bind('ajax:success', (e, data, status, xhr) -> + setTimeout (-> + $('.js-save-box','.edit_setting' ).addClass('hide') + ), 500 + ).bind 'ajax:error', (e, xhr, status, error) -> + $('.js-save-box', @).addClass('hide') diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 10de524c..703dd79d 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -1,88 +1,88 @@ +$ -> + # The body element has the controller and action name as class attribute + current_controller_and_action = $("body").attr('class') + $tabs = $('.menu a') + # Activate the tab for the current controller and action + $tabs.filter("[class='#{current_controller_and_action}']").addClass('active') + # On click change active tab + $tabs.click -> + $tabs.removeClass 'active' + $(@).addClass 'active' -# The body element has the controller and action name as class attribute -current_controller_and_action = $("body").attr('class') - -$tabs = $('.menu a') -# Activate the tab for the current controller and action -$tabs.filter("[class='#{current_controller_and_action}']").addClass('active') -# On click change active tab -$tabs.click -> - $tabs.removeClass 'active' - $(@).addClass 'active' - -$('#service_request_status_id').change -> - status_id = $(@).val() - service_id = $(@).data('service-id') - $.ajax( - url: "/admins/services/#{service_id}/messages" - data: - status_id: status_id - type: 'GET' - ) + $('#service_request_status_id').change -> + status_id = $(@).val() + service_id = $(@).data('service-id') + $.ajax( + url: "/admins/services/#{service_id}/messages" + data: + status_id: status_id + type: 'GET' + ) -$(window).resize -> - $("#main_width").html $(window).width() + $(window).resize -> + $("#main_width").html $(window).width() -setTimeout -> - hideFlashMessages() -,4000 + setTimeout -> + hideFlashMessages() + ,4000 -hideFlashMessages = -> - $(".alert").fadeOut('slow') + hideFlashMessages = -> + $(".alert").fadeOut('slow') -if $("#new-report-map").length > 0 - newReportMap = $('#new-report-map') - mapConstraints = newReportMap.data('map-constraints') - newReportMap.geolocateMap({ - html5: true - zoom: parseInt(mapConstraints.zoom) - sync_input: - longitude: '#lng' - latitude: '#lat' - address: '#address' - bounds: - sw: - latitude: mapConstraints.bounds[0][0] - longitude: mapConstraints.bounds[0][1] - ne: - latitude: mapConstraints.bounds[1][0] - longitude: mapConstraints.bounds[1][1] - }) + $("#new-report-map").each -> + newReportMap = $('#new-report-map') + console.log "entra" + mapConstraints = newReportMap.data('map-constraints') + newReportMap.geolocateMap({ + html5: true + zoom: parseInt(mapConstraints.zoom) + sync_input: + longitude: '#lng' + latitude: '#lat' + address: '#address' + bounds: + sw: + latitude: mapConstraints.bounds[0][0] + longitude: mapConstraints.bounds[0][1] + ne: + latitude: mapConstraints.bounds[1][0] + longitude: mapConstraints.bounds[1][1] + }) -if $("#reports-map").length > 0 - reports_markers = $(".recent-report-sum").map -> - return { lat: $(this).data("lat"), lng: $(this).data("lng"), description: $(this).data("description") } + if $("#reports-map").length > 0 + reports_markers = $(".recent-report-sum").map -> + return { lat: $(this).data("lat"), lng: $(this).data("lng"), description: $(this).data("description") } - $map = $(".map") - lat = $map.attr("data-latitude") - lng = $map.attr("data-longitude") + $map = $(".map") + lat = $map.attr("data-latitude") + lng = $map.attr("data-longitude") - report_map = new PinDropper('#reports-map', reports_markers, {center: new google.maps.LatLng(lat, lng)}) + report_map = new PinDropper('#reports-map', reports_markers, {center: new google.maps.LatLng(lat, lng)}) - $(".filters").on("ajax:success", (e, data, status, xhr) -> - report_map.updateMarkers( - $.map data['service_requests'], (val, index)-> - return { lat: val.lat, lng: val.long, description: val.description } - ) - submit_button = $(this).find('.js-ajax-sender') - submit_button.val(submit_button.data('stealth-label')) - ).bind "ajax:error", (e, xhr, status, error) -> - console.log 'ERROR!' + $(".filters").on("ajax:success", (e, data, status, xhr) -> + report_map.updateMarkers( + $.map data['service_requests'], (val, index)-> + return { lat: val.lat, lng: val.long, description: val.description } + ) + submit_button = $(this).find('.js-ajax-sender') + submit_button.val(submit_button.data('stealth-label')) + ).bind "ajax:error", (e, xhr, status, error) -> + console.log 'ERROR!' -if $("#show-report-map").length > 0 - $map = $("#show-report-map") - lat = $map.attr("data-latitude") - lng = $map.attr("data-longitude") + if $("#show-report-map").length > 0 + $map = $("#show-report-map") + lat = $map.attr("data-latitude") + lng = $map.attr("data-longitude") - reports_markers = [ - { - lat: $map.data("latitude") - lng: $map.data("longitude") - description: $map.data("description") - } - ] + reports_markers = [ + { + lat: $map.data("latitude") + lng: $map.data("longitude") + description: $map.data("description") + } + ] - $map.pinDropper(reports_markers, { - center: new google.maps.LatLng(lat, lng) - }) + $map.pinDropper(reports_markers, { + center: new google.maps.LatLng(lat, lng) + }) diff --git a/app/assets/javascripts/service_requets.js.coffee b/app/assets/javascripts/service_requets.js.coffee index de015e5f..82927eb8 100644 --- a/app/assets/javascripts/service_requets.js.coffee +++ b/app/assets/javascripts/service_requets.js.coffee @@ -1,42 +1,42 @@ +$ -> + $("abbr.timeago").timeago() -$("abbr.timeago").timeago() + $('.datepicker').datepicker({ + dateFormat: 'yy-mm-dd' + }) -$('.datepicker').datepicker({ - dateFormat: 'yy-mm-dd' -}) + $('.js-load_service_fields').change -> + $.ajax( + url: '/services/load_service_fields' + data: { + id: $(@).val() + } + ) -$('.js-load_service_fields').change -> - $.ajax( - url: '/services/load_service_fields' - data: { - id: $(@).val() - } - ) - -$('.blocked').click (e) -> - e.preventDefault() - receivedMessage = $(@).data('message') - if receivedMessage? - alert receivedMessage - else - alert 'Es necesario que te registres en el sistema para realizar esta operación.' + $('.blocked').click (e) -> + e.preventDefault() + receivedMessage = $(@).data('message') + if receivedMessage? + alert receivedMessage + else + alert 'Es necesario que te registres en el sistema para realizar esta operación.' -if window.FileReader - $('.js-image-preview').change (event) -> - files = event.target.files[0] - reader = new FileReader() - reader.onload = ((theFile) -> - return (e) -> - $('.image_preview').html(""))(files) - reader.readAsDataURL(files) + if window.FileReader + $('.js-image-preview').change (event) -> + files = event.target.files[0] + reader = new FileReader() + reader.onload = ((theFile) -> + return (e) -> + $('.image_preview').html(""))(files) + reader.readAsDataURL(files) -$(".sortable_table").tablesorter( - cssHeader: 'table-header' - sortList: [[0,0]] -) + $(".sortable_table").tablesorter( + cssHeader: 'table-header' + sortList: [[0,0]] + ) -$('.sortable_table .table-header').click -> - $('.table-header').find('i').removeClass('icon-chevron-up').addClass('icon-chevron-down') - $(@).find('.icon-chevron-down').removeClass('icon-chevron-down').addClass('icon-chevron-up') - if $(@).hasClass('headerSortUp') - $(@).find('.icon-chevron-up').removeClass('icon-chevron-up').addClass('icon-chevron-down') + $('.sortable_table .table-header').click -> + $('.table-header').find('i').removeClass('icon-chevron-up').addClass('icon-chevron-down') + $(@).find('.icon-chevron-down').removeClass('icon-chevron-down').addClass('icon-chevron-up') + if $(@).hasClass('headerSortUp') + $(@).find('.icon-chevron-up').removeClass('icon-chevron-up').addClass('icon-chevron-down') diff --git a/app/assets/javascripts/services.js.coffee b/app/assets/javascripts/services.js.coffee index bc0fbbf7..2fec7871 100644 --- a/app/assets/javascripts/services.js.coffee +++ b/app/assets/javascripts/services.js.coffee @@ -1,3 +1,3 @@ - -if $('#bounding-box-map').length - $('#bounding-box-map').mapBounder($('.js-save-map')) +$ -> + if $('#bounding-box-map').length + $('#bounding-box-map').mapBounder($('.js-save-map')) diff --git a/app/views/layouts/admins.html.haml b/app/views/layouts/admins.html.haml index b8740ddc..d017946a 100644 --- a/app/views/layouts/admins.html.haml +++ b/app/views/layouts/admins.html.haml @@ -5,6 +5,8 @@ = stylesheet_link_tag "admin", :media => "all" %meta{:content => "width=device-width, initial-scale=1.0", :name => "viewport"} = csrf_meta_tags + = javascript_include_tag "application" + %script(type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=#{ENV['GOOGLE_KEY']}") %body #wrapper{class: ("is-logged-in" if admin_signed_in?) } - if admin_signed_in? @@ -16,6 +18,3 @@ = content_tag :div, :class => "alert #{flash_class(name)}" do = msg = yield - - = javascript_include_tag "application" - %script(type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=#{ENV['GOOGLE_KEY']}&sensor=false") From 0a69202b113c541d45a70f1441f1f369e9b4619f Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 19 Mar 2015 11:49:37 -0600 Subject: [PATCH 32/42] Changed ifs to each on selectors that may appear in the dom --- app/assets/javascripts/graph.js.coffee | 2 +- app/assets/javascripts/main.js.coffee | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/graph.js.coffee b/app/assets/javascripts/graph.js.coffee index 265e0a1b..edcfe797 100644 --- a/app/assets/javascripts/graph.js.coffee +++ b/app/assets/javascripts/graph.js.coffee @@ -1,5 +1,5 @@ $(document).on 'ready page:load', -> - if $('#reports-chart').length > 0 + $('#reports-chart').each -> chart_data = $('#reports-chart').data('chart-data') status_names = $('#reports-chart').data('status-names') series = [] diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index 703dd79d..a0674129 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -50,7 +50,7 @@ $ -> longitude: mapConstraints.bounds[1][1] }) - if $("#reports-map").length > 0 + $("#reports-map").each -> reports_markers = $(".recent-report-sum").map -> return { lat: $(this).data("lat"), lng: $(this).data("lng"), description: $(this).data("description") } @@ -70,7 +70,7 @@ $ -> ).bind "ajax:error", (e, xhr, status, error) -> console.log 'ERROR!' - if $("#show-report-map").length > 0 + $("#show-report-map").each -> $map = $("#show-report-map") lat = $map.attr("data-latitude") lng = $map.attr("data-longitude") From 9c5218a30b7a9e548aa003fe4aa2b0256942af94 Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 19 Mar 2015 12:12:09 -0600 Subject: [PATCH 33/42] Fix loading report map when container is not loaded --- app/assets/javascripts/main.js.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index a0674129..7b4ef8df 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -1,4 +1,4 @@ -$ -> +$(document).on 'ready page:load', -> # The body element has the controller and action name as class attribute current_controller_and_action = $("body").attr('class') @@ -32,7 +32,6 @@ $ -> $("#new-report-map").each -> newReportMap = $('#new-report-map') - console.log "entra" mapConstraints = newReportMap.data('map-constraints') newReportMap.geolocateMap({ html5: true From 60a2112b0d0ff997babc01249c57c8468e405ce8 Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 19 Mar 2015 14:25:45 -0600 Subject: [PATCH 34/42] Fix strong params to accept service_fields hash with unknown keys --- .../javascripts/service_requets.js.coffee | 7 +++--- .../admins/service_requests_controller.rb | 5 ++++- app/models/service_field.rb | 1 - .../admin/manage_service_requests_spec.rb | 22 ++++++++++++++++++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/service_requets.js.coffee b/app/assets/javascripts/service_requets.js.coffee index 82927eb8..7a7c1a3a 100644 --- a/app/assets/javascripts/service_requets.js.coffee +++ b/app/assets/javascripts/service_requets.js.coffee @@ -1,17 +1,16 @@ -$ -> +$(document).on 'ready page:load', -> $("abbr.timeago").timeago() $('.datepicker').datepicker({ dateFormat: 'yy-mm-dd' }) - $('.js-load_service_fields').change -> - $.ajax( + $('.js-load_service_fields').on "change", -> + $.ajax url: '/services/load_service_fields' data: { id: $(@).val() } - ) $('.blocked').click (e) -> e.preventDefault() diff --git a/app/controllers/admins/service_requests_controller.rb b/app/controllers/admins/service_requests_controller.rb index 15eb0e4d..3f99b038 100644 --- a/app/controllers/admins/service_requests_controller.rb +++ b/app/controllers/admins/service_requests_controller.rb @@ -45,6 +45,9 @@ def destroy private def service_request_params - params.require(:service_request).permit(:address, :status_id, :service_id, :description, :media, :anonymous, :lat, :lng) + service_fields = params[:service_request].delete(:service_fields) + params.require(:service_request).permit(:address, :status_id, :service_id, :description, :media, :anonymous, :lat, :lng).tap do |whitelisted| + whitelisted[:service_fields] = service_fields + end end end diff --git a/app/models/service_field.rb b/app/models/service_field.rb index 34e4de17..46317922 100644 --- a/app/models/service_field.rb +++ b/app/models/service_field.rb @@ -7,5 +7,4 @@ class ServiceField < ActiveRecord::Base def to_s self.name end - end diff --git a/spec/features/admin/manage_service_requests_spec.rb b/spec/features/admin/manage_service_requests_spec.rb index d9495afc..f18d4a3b 100644 --- a/spec/features/admin/manage_service_requests_spec.rb +++ b/spec/features/admin/manage_service_requests_spec.rb @@ -31,9 +31,11 @@ scenario 'I can create a service request' do services = create_list(:service, 2) + first_service = services.first + visit new_admins_service_request_path + select first_service.name, from: 'service_request[service_id]' - select services.first.name, from: 'service_request[service_id]' fill_in 'service_request[address]', with: 'An address #111' set_location_as(lat: "12.12", lng: "12.13") fill_in 'service_request[description]', with: 'Request description' @@ -42,6 +44,19 @@ expect(page).to have_content t('flash.service_requests.created') end + scenario 'I can see the service extra fields when creating a request', js: true do + services = create_list(:service, 2) + first_service = services.first + + given_service_with_extra_fields(first_service) + visit new_admins_service_request_path + + select first_service.name, from: 'service_request[service_id]' + + expect(page).to have_content "Field one" + expect(page).to have_content "Field two" + end + scenario 'I can see the requester full name and email' do visit admins_service_requests_path click_link service_request.service.name @@ -117,4 +132,9 @@ def set_location_as(lat:, lng:) find("#lat").set(lat) find("#lng").set(lng) end + + def given_service_with_extra_fields(service) + create :service_field, name: "field one", service: service + create :service_field, name: "field two", service: service + end end From f317b7bc4feb31a78ff70c22fc60130661078966 Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 19 Mar 2015 15:19:46 -0600 Subject: [PATCH 35/42] Added default value for service_field param --- app/controllers/admins/service_requests_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admins/service_requests_controller.rb b/app/controllers/admins/service_requests_controller.rb index 3f99b038..7d390e4f 100644 --- a/app/controllers/admins/service_requests_controller.rb +++ b/app/controllers/admins/service_requests_controller.rb @@ -47,7 +47,7 @@ def destroy def service_request_params service_fields = params[:service_request].delete(:service_fields) params.require(:service_request).permit(:address, :status_id, :service_id, :description, :media, :anonymous, :lat, :lng).tap do |whitelisted| - whitelisted[:service_fields] = service_fields + whitelisted[:service_fields] = service_fields || {} end end end From 8b60fb60eb3d911e9961b36f37228b4293dac040 Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 19 Mar 2015 17:38:09 -0600 Subject: [PATCH 36/42] Fix user service request managing spec --- .../service_requests_controller.rb | 7 ++++-- app/models/service_request.rb | 5 ++--- .../features/user_service_request_managing.rb | 22 ++++++++++--------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/controllers/service_requests_controller.rb b/app/controllers/service_requests_controller.rb index 95240192..58e8c752 100644 --- a/app/controllers/service_requests_controller.rb +++ b/app/controllers/service_requests_controller.rb @@ -1,5 +1,5 @@ class ServiceRequestsController < ApplicationController - before_filter :authenticate_user!, only: [:create, :new] + before_action :authenticate_user!, only: [:create, :new] def index @search = ServiceRequest.unscoped.search(params[:q]) @@ -49,6 +49,9 @@ def markers_for_gmap private def service_request_params - params.require(:service_request).permit(:name, :service_fields_attributes, :messages_attributes) + service_fields = params[:service_request].delete(:service_fields) + params.require(:service_request).permit(:address, :status_id, :service_id, :description, :media, :anonymous, :lat, :lng).tap do |whitelisted| + whitelisted[:service_fields] = service_fields || {} + end end end diff --git a/app/models/service_request.rb b/app/models/service_request.rb index 1a85835c..833dd545 100644 --- a/app/models/service_request.rb +++ b/app/models/service_request.rb @@ -111,9 +111,8 @@ def requested_by_user? end - ransacker :date do |parent| - Arel::Nodes::InfixOperation.new('||', - Arel::Nodes::InfixOperation.new('||', parent.table[:created_at], ' '), parent.table[:created_at]) + ransacker :date do + Arel.sql('date(created_at)') end private diff --git a/spec/features/user_service_request_managing.rb b/spec/features/user_service_request_managing.rb index 5120ced5..6eca6345 100644 --- a/spec/features/user_service_request_managing.rb +++ b/spec/features/user_service_request_managing.rb @@ -51,26 +51,29 @@ scenario 'can search for service requests by service' do service_requests = create_list(:service_request, 3) + first_service = service_requests.first + visit service_requests_path within '#service_request_search' do - select service_requests.first.service.name, from: 'q[service_id_eq]' + select first_service.service.name, from: 'q[service_id_eq]' click_button 'Buscar' end - expect(page).to have_content service_requests.first.description.truncate(30) - expect(page).to have_content service_requests[1].description.truncate(30) - expect(page).to have_content service_requests.last.description.truncate(30) + expect(page).to have_content first_service.description.truncate(30) + expect(page).not_to have_content service_requests[1].description.truncate(30) + expect(page).not_to have_content service_requests.last.description.truncate(30) end scenario 'can search for service requests by status' do - service_requests = create_list(:service_request, 3) + custom_status = create :status + service_requests = create_list(:service_request, 3, status: custom_status) visit service_requests_path within '#service_request_search' do select service_requests.first.status.name, from: 'q[status_id_eq]' click_button 'Buscar' end expect(page).to have_content service_requests.first.description.truncate(30) - expect(page).not_to have_content service_requests[1].description.truncate(30) - expect(page).not_to have_content service_requests.last.description.truncate(30) + expect(page).to have_content service_requests[1].description.truncate(30) + expect(page).to have_content service_requests.last.description.truncate(30) end scenario 'can go see a service request' do @@ -85,15 +88,14 @@ sign_in_user user end - scenario 'can create a new service request successfully', js: true do - service = create(:service_with_service_fields) + scenario 'can create a new service request successfully' do + service = create(:service) visit new_service_request_path within '#new_service_request' do attach_file 'service_request[media]', File.join(Rails.root, '/spec/support/features/images/avatar.png') fill_in 'service_request[address]', with: '123 Governor Dr, San Diego, CA 92122' fill_in 'service_request[description]', with: 'No water' select service.name, from: 'service_request[service_id]' - fill_in "service_request[service_fields][#{service.service_fields.first.name}]", with: 'more fields' click_button 'Guardar' end expect(page).to have_content '123 Governor Dr, San Diego, CA 92122' From c2b1883c3efc5d048ccaae26d43e3e9dfaeff0a4 Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 19 Mar 2015 17:40:22 -0600 Subject: [PATCH 37/42] Rename users specs to run with rspec --- spec/features/{user_account_flow.rb => user_account_flow_spec.rb} | 0 spec/features/{user_dashboard.rb => user_dashboard_spec.rb} | 0 ..._request_managing.rb => user_service_request_managing_spec.rb} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename spec/features/{user_account_flow.rb => user_account_flow_spec.rb} (100%) rename spec/features/{user_dashboard.rb => user_dashboard_spec.rb} (100%) rename spec/features/{user_service_request_managing.rb => user_service_request_managing_spec.rb} (100%) diff --git a/spec/features/user_account_flow.rb b/spec/features/user_account_flow_spec.rb similarity index 100% rename from spec/features/user_account_flow.rb rename to spec/features/user_account_flow_spec.rb diff --git a/spec/features/user_dashboard.rb b/spec/features/user_dashboard_spec.rb similarity index 100% rename from spec/features/user_dashboard.rb rename to spec/features/user_dashboard_spec.rb diff --git a/spec/features/user_service_request_managing.rb b/spec/features/user_service_request_managing_spec.rb similarity index 100% rename from spec/features/user_service_request_managing.rb rename to spec/features/user_service_request_managing_spec.rb From 75771076addcfd824f6da6ef45a9cb9d1154509a Mon Sep 17 00:00:00 2001 From: abisosa Date: Thu, 19 Mar 2015 18:03:17 -0600 Subject: [PATCH 38/42] Fix user dashboard specs --- spec/features/user_dashboard_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/features/user_dashboard_spec.rb b/spec/features/user_dashboard_spec.rb index 89190316..5d39147d 100644 --- a/spec/features/user_dashboard_spec.rb +++ b/spec/features/user_dashboard_spec.rb @@ -12,7 +12,9 @@ scenario 'I can vote on an service_request', js: true do visit root_path - page.find("a[href='/service_requests/#{service_requests.first.id}/vote']").click + within first(".js-vote_status") do + click_link "VOTA" + end expect(page).to have_content('Votaste') end end From 370de48bdf9f88f481a242e7253a0ba169e241bf Mon Sep 17 00:00:00 2001 From: abisosa Date: Fri, 20 Mar 2015 10:51:14 -0600 Subject: [PATCH 39/42] Fix user account flow specs (sign in and log in with twitter) --- .../users/registrations_controller.rb | 8 ++++++-- app/models/user.rb | 18 ++++++++---------- spec/features/user_account_flow_spec.rb | 4 ++++ spec/spec_helper.rb | 1 + 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 747042a9..7ebf908b 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -12,7 +12,7 @@ def create def finish_registration self.resource = resource_class.new - self.resource.apply_omniauth(session[:omniauth]) + self.resource.apply_omniauth(omniauth_hash) respond_with self.resource end @@ -21,8 +21,12 @@ def finish_registration def build_resource(hash=nil) super if session[:omniauth] - self.resource.apply_omniauth(session[:omniauth]) + self.resource.apply_omniauth(omniauth_hash) self.resource.valid? end end + + def omniauth_hash + session[:omniauth].deep_symbolize_keys + end end diff --git a/app/models/user.rb b/app/models/user.rb index 4af99fa5..2b5de2ad 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -14,19 +14,19 @@ class User < ActiveRecord::Base acts_as_voter def self.find_or_build_with_omniauth(omniauth) - user = User.find_by_email(omniauth.info.email) unless omniauth.info.email.nil? + user = User.find_by_email(omniauth[:info][:email]) unless omniauth[:info][:email].nil? if user.nil? user = User.new user.apply_omniauth(omniauth) else - user.authentications.build(provider: omniauth['provider'], uid: omniauth['uid']) + user.authentications.build(provider: omniauth[:provider], uid: omniauth[:uid]) end user end def apply_omniauth(omniauth) self.collect_omniauth_attributes(omniauth) - self.authentications.build(provider: omniauth['provider'], uid: omniauth['uid']) + self.authentications.build(provider: omniauth[:provider], uid: omniauth[:uid]) end def to_s @@ -42,10 +42,10 @@ def avatar_url end def collect_omniauth_attributes(omniauth) - self.name = omniauth.info.name - self.username = omniauth.info.nickname + self.name = omniauth[:info][:name] + self.username = omniauth[:info][:nickname] self.avatar = fetch_image_from_omniauth(omniauth) - self.email = omniauth.info.email if self.email.blank? + self.email = omniauth[:info][:email] if self.email.blank? end # Devise override @@ -77,11 +77,9 @@ def update_with_password(params, *options) private def fetch_image_from_omniauth(omniauth) - case omniauth.provider + case omniauth[:provider] when 'facebook' then "https://graph.facebook.com/#{omniauth.uid}/picture?type=large" - when 'twitter' then omniauth.info.image + when 'twitter' then omniauth[:info][:image] end end - - end diff --git a/spec/features/user_account_flow_spec.rb b/spec/features/user_account_flow_spec.rb index e5f18bbb..be69a785 100644 --- a/spec/features/user_account_flow_spec.rb +++ b/spec/features/user_account_flow_spec.rb @@ -14,6 +14,8 @@ OmniAuth.config.mock_auth[:twitter] = omniauth_twitter_valid_hash visit new_user_registration_path click_link 'Twitter' + fill_in 'user[email]', with: 'johnq@mail.com' + click_button "Completar" expect(page).to have_content 'John Q Public' expect(current_url).to eq root_url end @@ -55,6 +57,8 @@ OmniAuth.config.mock_auth[:twitter] = omniauth_twitter_valid_hash visit new_user_session_path click_link 'Twitter' + fill_in 'user[email]', with: 'johnq@mail.com' + click_button "Completar" expect(page).to have_content 'John Q Public' expect(current_url).to eq root_url end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d06223d0..327e2a9b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -40,3 +40,4 @@ def t *args config.include SessionHelpers, type: :feature end +OmniAuth.config.test_mode = true \ No newline at end of file From 57651bc125054b31b90f6a28d6762f42aa4cfe2f Mon Sep 17 00:00:00 2001 From: abisosa Date: Mon, 23 Mar 2015 12:38:39 -0600 Subject: [PATCH 40/42] Refactor status data for highchart chart, fix js index dependency --- app/assets/javascripts/graph.js.coffee | 12 +++++------- app/controllers/admins/dashboards_controller.rb | 2 +- app/controllers/pages_controller.rb | 2 +- app/views/admins/dashboards/index.html.haml | 2 +- app/views/pages/index.html.haml | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/graph.js.coffee b/app/assets/javascripts/graph.js.coffee index edcfe797..86b3317c 100644 --- a/app/assets/javascripts/graph.js.coffee +++ b/app/assets/javascripts/graph.js.coffee @@ -1,17 +1,15 @@ $(document).on 'ready page:load', -> $('#reports-chart').each -> chart_data = $('#reports-chart').data('chart-data') - status_names = $('#reports-chart').data('status-names') + status_data = $('#reports-chart').data('status-data') series = [] services_names = [] - index = 1 - for status_name in status_names + for status in status_data series.push({ - name: status_name - data: $.map chart_data, (e, i) -> parseInt(e["status_#{index}"]) + name: status["name"] + data: $.map chart_data, (e, i) -> parseInt(e["status_#{status['id']}"]) }) - index++ for service in chart_data services_names.push(service.name) @@ -26,7 +24,7 @@ $(document).on 'ready page:load', -> yAxis: allowDecimals: false gridLineWidth: 0 - max: $('#reports-stats').data('total') + max: $('.reports-stats').data('total') min: 0 title: 'Total de reportes' legend: diff --git a/app/controllers/admins/dashboards_controller.rb b/app/controllers/admins/dashboards_controller.rb index dcf44afa..cbb189b7 100644 --- a/app/controllers/admins/dashboards_controller.rb +++ b/app/controllers/admins/dashboards_controller.rb @@ -10,7 +10,7 @@ def index @closed_service_requests = ServiceRequest.closed.count @all_service_requests = ServiceRequest.count @chart_data = Service.chart_data.to_json - @status_names = Status.pluck(:name).to_json + @status_data = Status.select(:name, :id).to_json flash.now[:notice] = I18n.t('flash.dashboards.requests_not_found') if @service_requests.empty? end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 3297b0da..396310f4 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -5,7 +5,7 @@ def index @closed_service_requests = ServiceRequest.closed.count @all_service_requests = ServiceRequest.count @chart_data = Service.chart_data.to_json - @status_names = Status.pluck(:name).to_json + @status_data = Status.select(:name, :id).to_json flash.now[:notice] = "No se encontraron solicitudes de servicio." if @service_requests.empty? end end diff --git a/app/views/admins/dashboards/index.html.haml b/app/views/admins/dashboards/index.html.haml index 2bf2a658..641c912d 100644 --- a/app/views/admins/dashboards/index.html.haml +++ b/app/views/admins/dashboards/index.html.haml @@ -19,7 +19,7 @@ .row.blk-summary.l-margin-l-bottom .container %h2.blk-summary-title= t('dashboards.requests_by_service_chart') - #reports-chart{ data: { chart_data: @chart_data, status_names: @status_names }} + #reports-chart{ data: { chart_data: @chart_data, status_data: @status_data }} .row.blk-summary.l-margin-l-bottom diff --git a/app/views/pages/index.html.haml b/app/views/pages/index.html.haml index a513da21..b9e3d308 100644 --- a/app/views/pages/index.html.haml +++ b/app/views/pages/index.html.haml @@ -12,7 +12,7 @@ .row.blk-summary.l-margin-l-bottom .container %h2.blk-summary-title= t('dashboards.requests_by_service_chart') - #reports-chart{ data: { chart_data: @chart_data, status_names: @status_names }} + #reports-chart{ data: { chart_data: @chart_data, status_data: @status_data, }} .row.blk-summary.l-margin-l-bottom From 94bbde35cafb8fb73c88c0319cb7c6514cb2ca08 Mon Sep 17 00:00:00 2001 From: abisosa Date: Mon, 23 Mar 2015 13:22:55 -0600 Subject: [PATCH 41/42] Fix bounding box map loading --- app/assets/javascripts/services.js.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/services.js.coffee b/app/assets/javascripts/services.js.coffee index 2fec7871..fb04ab5f 100644 --- a/app/assets/javascripts/services.js.coffee +++ b/app/assets/javascripts/services.js.coffee @@ -1,3 +1,3 @@ -$ -> - if $('#bounding-box-map').length +$(document).on 'ready page:load', -> + $('#bounding-box-map').each -> $('#bounding-box-map').mapBounder($('.js-save-map')) From c5359bd202f1c36188c38a4a4e04f870dd53afc4 Mon Sep 17 00:00:00 2001 From: Juan Pablo Escobar Date: Thu, 26 Mar 2015 14:22:29 -0600 Subject: [PATCH 42/42] Updates dependencies on README --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6dad45db..75de9b40 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ de la comunicación con la ciudadanía y los reportes de cuestiones en sus servi [README English Version](https://github.com/CodeandoMexico/reporte-ciudadano/blob/master/README.en.md) ### Dependencias -- Ruby 2.0 -- Rails 3.2 +- Ruby 2.1.5 +- Rails 4.2.0 - Bootstrap 3.0 -- Rspec 2.14 -- Redis 2.8.6 +- Rspec 3.2.2 +- Redis 3.2.1 ### ¿Dudas? @@ -44,9 +44,10 @@ El core team: - [Eddie Ruvalcaba](https://github.com/eddie-ruva) - [Juan Pablo Escobar](https://github.com/juanpabloe) - [Abraham Kuri](https://github.com/kurenn) +- [Abi Sosa](https://github.com/abisosa) ### Licencia -Creado por [Codeando México](https://github.com/CodeandoMexico?tab=members), 2013 - 2014. +Creado por [Codeando México](https://github.com/CodeandoMexico?tab=members), 2013 - 2015. Disponible bajo la licencia GNU Affero General Public License (AGPL) v3.0. Ver el documento [LICENSE](/LICENSE) para más información.