diff --git a/Gemfile b/Gemfile index e8196f0..339a1c9 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.3' +gem 'rails', '4.2.8' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets @@ -15,7 +15,7 @@ gem 'coffee-rails', '~> 4.1.0' # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library -gem 'jquery-rails' +gem 'jquery-rails', "2.3.0" # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder @@ -23,12 +23,16 @@ gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc +gem "rspec-rails", :group => [:development, :test] + +gem 'factory_girl_rails' + # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Unicorn as the app server # gem 'unicorn' - +gem 'json', github: 'flori/json', branch: 'v1.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development diff --git a/Gemfile.lock b/Gemfile.lock index 54a4293..84a525d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,137 +1,175 @@ +GIT + remote: git://github.com/flori/json.git + revision: 7f4cfd853f2c919d854fb95548a19980feff17e8 + branch: v1.8 + specs: + json (1.8.6) + GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.3) - actionpack (= 4.2.3) - actionview (= 4.2.3) - activejob (= 4.2.3) + actionmailer (4.2.8) + actionpack (= 4.2.8) + actionview (= 4.2.8) + activejob (= 4.2.8) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.3) - actionview (= 4.2.3) - activesupport (= 4.2.3) + actionpack (4.2.8) + actionview (= 4.2.8) + activesupport (= 4.2.8) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.3) - activesupport (= 4.2.3) + actionview (4.2.8) + activesupport (= 4.2.8) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.3) - activesupport (= 4.2.3) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (4.2.8) + activesupport (= 4.2.8) globalid (>= 0.3.0) - activemodel (4.2.3) - activesupport (= 4.2.3) + activemodel (4.2.8) + activesupport (= 4.2.8) builder (~> 3.1) - activerecord (4.2.3) - activemodel (= 4.2.3) - activesupport (= 4.2.3) + activerecord (4.2.8) + activemodel (= 4.2.8) + activesupport (= 4.2.8) arel (~> 6.0) - activesupport (4.2.3) + activesupport (4.2.8) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - arel (6.0.2) + arel (6.0.4) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - builder (3.2.2) - byebug (5.0.0) - columnize (= 0.9.0) - coffee-rails (4.1.0) + builder (3.2.3) + byebug (9.0.6) + coffee-rails (4.1.1) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) + railties (>= 4.0.0, < 5.1.x) coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.9.1.1) - columnize (0.9.0) - debug_inspector (0.0.2) + coffee-script-source (1.12.2) + concurrent-ruby (1.0.5) + debug_inspector (0.0.3) + diff-lcs (1.3) erubis (2.7.0) - execjs (2.5.2) - globalid (0.3.5) - activesupport (>= 4.1.0) - i18n (0.7.0) - jbuilder (2.3.1) - activesupport (>= 3.0.0, < 5) - multi_json (~> 1.2) - jquery-rails (4.0.4) - rails-dom-testing (~> 1.0) - railties (>= 4.2.0) + execjs (2.7.0) + factory_girl (4.8.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.8.0) + factory_girl (~> 4.8.0) + railties (>= 3.0.0) + ffi (1.9.18) + globalid (0.4.0) + activesupport (>= 4.2.0) + i18n (0.8.6) + jbuilder (2.7.0) + activesupport (>= 4.2.0) + multi_json (>= 1.2) + jquery-rails (2.3.0) + railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - json (1.8.3) - loofah (2.0.2) + loofah (2.0.3) nokogiri (>= 1.5.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) - mime-types (2.6.1) - mini_portile (0.6.2) - minitest (5.7.0) - multi_json (1.11.2) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - rack (1.6.4) + mail (2.6.6) + mime-types (>= 1.16, < 4) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mini_portile2 (2.2.0) + minitest (5.10.3) + multi_json (1.12.1) + nokogiri (1.8.0) + mini_portile2 (~> 2.2.0) + rack (1.6.8) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.3) - actionmailer (= 4.2.3) - actionpack (= 4.2.3) - actionview (= 4.2.3) - activejob (= 4.2.3) - activemodel (= 4.2.3) - activerecord (= 4.2.3) - activesupport (= 4.2.3) + rails (4.2.8) + actionmailer (= 4.2.8) + actionpack (= 4.2.8) + actionview (= 4.2.8) + activejob (= 4.2.8) + activemodel (= 4.2.8) + activerecord (= 4.2.8) + activesupport (= 4.2.8) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.3) + railties (= 4.2.8) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.6) + rails-dom-testing (1.0.8) activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) + nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) + rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (4.2.3) - actionpack (= 4.2.3) - activesupport (= 4.2.3) + railties (4.2.8) + actionpack (= 4.2.8) + activesupport (= 4.2.8) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) - rdoc (4.2.0) - sass (3.4.16) - sass-rails (5.0.3) - railties (>= 4.0.0, < 5.0) + rake (12.0.0) + rb-fsevent (0.10.2) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + rdoc (4.3.0) + rspec-core (3.6.0) + rspec-support (~> 3.6.0) + rspec-expectations (3.6.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.6.0) + rspec-mocks (3.6.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.6.0) + rspec-rails (3.6.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.6.0) + rspec-expectations (~> 3.6.0) + rspec-mocks (~> 3.6.0) + rspec-support (~> 3.6.0) + rspec-support (3.6.0) + sass (3.5.1) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.6) + railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) - tilt (~> 1.1) - sdoc (0.4.1) + tilt (>= 1.1, < 3) + sdoc (0.4.2) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - spring (1.3.6) - sprockets (3.2.0) - rack (~> 1.0) - sprockets-rails (2.3.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - sqlite3 (1.3.10) - thor (0.19.1) - thread_safe (0.3.5) - tilt (1.4.1) - turbolinks (2.5.3) - coffee-rails - tzinfo (1.2.2) + spring (2.0.2) + activesupport (>= 4.2) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.0) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.3.13) + thor (0.19.4) + thread_safe (0.3.6) + tilt (2.0.8) + turbolinks (5.0.1) + turbolinks-source (~> 5) + turbolinks-source (5.0.3) + tzinfo (1.2.3) thread_safe (~> 0.1) - uglifier (2.7.1) - execjs (>= 0.3.0) - json (>= 1.8.0) - web-console (2.2.1) + uglifier (3.2.0) + execjs (>= 0.3.0, < 3) + web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) railties (>= 4.0) @@ -143,9 +181,12 @@ PLATFORMS DEPENDENCIES byebug coffee-rails (~> 4.1.0) + factory_girl_rails jbuilder (~> 2.0) - jquery-rails - rails (= 4.2.3) + jquery-rails (= 2.3.0) + json! + rails (= 4.2.8) + rspec-rails sass-rails (~> 5.0) sdoc (~> 0.4.0) spring @@ -153,3 +194,6 @@ DEPENDENCIES turbolinks uglifier (>= 1.3.0) web-console (~> 2.0) + +BUNDLED WITH + 1.14.6 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e07c5a8..17eb7ad 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,7 +10,7 @@ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // -//= require jquery -//= require jquery_ujs -//= require turbolinks -//= require_tree . +// require jquery +// require jquery_ujs +// require turbolinks +// require_tree . diff --git a/app/services/utility_service.rb b/app/services/utility_service.rb index 8647fb2..d8e1d73 100644 --- a/app/services/utility_service.rb +++ b/app/services/utility_service.rb @@ -1,3 +1,5 @@ +require 'net/http' + class UtilityService STOCK_EXPIRY_TIME = 1.minute @@ -20,6 +22,7 @@ def get_stock_prices(stocks) uri.query = URI.encode_www_form({ q: query.join(",") }) fresh_response = Net::HTTP.get_response(uri) + if fresh_response.is_a?(Net::HTTPSuccess) # for some reason google's API returns result strating with `//` # https://finance.google.com/finance/info?q=INDEXDJX:.DJI,INDEXSP:.INX,INDEXNASDAQ:NDX diff --git a/config/application.rb b/config/application.rb index 9d95ae0..9f2244d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -4,7 +4,7 @@ # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. -Bundler.require(*Rails.groups) +# Bundler.require(*Rails.groups) module AndroidTest class Application < Rails::Application diff --git a/config/environment.rb b/config/environment.rb index ee8d90d..e30bc6d 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,6 @@ # Load the Rails application. require File.expand_path('../application', __FILE__) +# ENV['SSL_CERT_FILE'] = "/Users/karthik.yr/workspace/sample_app/cacert.pem" # Initialize the Rails application. Rails.application.initialize! diff --git a/test/controllers/saveks_controller_test.rb b/test/controllers/saveks_controller_test.rb index 15c7b58..1708c55 100644 --- a/test/controllers/saveks_controller_test.rb +++ b/test/controllers/saveks_controller_test.rb @@ -1,3 +1,46 @@ require_relative '../test_helper.rb' +# require_relative '../factories/savek_factory.rb' # space for controller tests + +class SavekControllerTest < ActionDispatch::IntegrationTest + + # include FactoryGirl::Syntax::Methods + + setup do + @savek = saveks(:one) + end + + test "should get index" do + get '/saveks' + assert_response :success + end + + test "should get new" do + get '/saveks/new' + assert_response :success + end + + test "should create savek" do + assert_difference('Savek.count') do + post '/saveks', :savek => @savek.attributes + end + assert_redirected_to savek_path(assigns(:savek)) + end + + test "should update savek" do + url= "/saveks/#{@savek.id}" + puts url + puts "savek ID "+@savek.attributes.to_s + put url, :savek => @savek.attributes + assert_redirected_to savek_path(assigns(:savek)) + end + + test "should destroy savek" do + url = "/saveks/#{@savek.id}" + assert_difference('Savek.count', -1) do + delete url + end + end + +end diff --git a/test/factories/savek_factory.rb b/test/factories/savek_factory.rb new file mode 100644 index 0000000..495b565 --- /dev/null +++ b/test/factories/savek_factory.rb @@ -0,0 +1,17 @@ + +FactoryGirl.define do + + factory :savek do |s| + s.first_name = "Karthik" + s.last_name = "YR" + s.occupation = "Engineer", + s.latitude = "12.35467", + s.longitude = "77.3524", + s.radius = "235", + s.avg_rating = "4.5", + s.ratings = "2", + s.gender = "Male", + s.address = "Marathahalli, Bangalore", + s.phone = "+91 9876543210" + end +end \ No newline at end of file diff --git a/test/fixtures/saveks.yml b/test/fixtures/saveks.yml index c94e406..001df56 100644 --- a/test/fixtures/saveks.yml +++ b/test/fixtures/saveks.yml @@ -1,15 +1,17 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html one: - first_name: MyString - last_name: MyString - occupation: MyString - latitude: - longitude: - radius: - avg_rating: + first_name: Karthik + last_name: YR + occupation: Engineer + latitude: 12.345645 + longitude: 77.235246 + radius: 230 + avg_rating: 2.4 ratings: 1 - gender: MyString + gender: Male + address: Marathahalli, Bangalore + phone: 9876543210 two: first_name: MyString diff --git a/test/integration/savek_test.rb b/test/integration/savek_test.rb new file mode 100644 index 0000000..bf4a330 --- /dev/null +++ b/test/integration/savek_test.rb @@ -0,0 +1,46 @@ +require_relative '../test_helper.rb' +# require_relative "../application_system_test_case" + +class SavekTest < ActionDispatch::IntegrationTest + + test "should list stock prices" do + get "/saveks" + assert_select "h1", "Listing Stock Prices" + assert_select "table" do + assert_select "thead" do + assert_select "tr" do + assert_select "th" do |elements| + assert_select elements, "