From 9e7af846f5af6a625905ef0b67118260565ba151 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 23 May 2016 15:06:42 -0700 Subject: [PATCH 01/35] Set up gemset and gemfile --- shipping-api/.gitignore | 17 ++ shipping-api/.ruby-gemset | 1 + shipping-api/.ruby-version | 1 + shipping-api/Gemfile | 65 +++++ shipping-api/Gemfile.lock | 252 ++++++++++++++++++ shipping-api/README.rdoc | 28 ++ shipping-api/Rakefile | 6 + shipping-api/app/assets/images/.keep | 0 .../app/assets/javascripts/application.js | 16 ++ .../app/assets/stylesheets/application.css | 15 ++ .../app/controllers/application_controller.rb | 5 + shipping-api/app/controllers/concerns/.keep | 0 .../app/helpers/application_helper.rb | 2 + shipping-api/app/mailers/.keep | 0 shipping-api/app/models/.keep | 0 shipping-api/app/models/concerns/.keep | 0 .../app/views/layouts/application.html.erb | 14 + shipping-api/bin/bundle | 3 + shipping-api/bin/rails | 9 + shipping-api/bin/rake | 9 + shipping-api/bin/setup | 29 ++ shipping-api/bin/spring | 15 ++ shipping-api/config.ru | 4 + shipping-api/config/application.rb | 26 ++ shipping-api/config/boot.rb | 3 + shipping-api/config/database.yml | 25 ++ shipping-api/config/environment.rb | 5 + .../config/environments/development.rb | 41 +++ .../config/environments/production.rb | 79 ++++++ shipping-api/config/environments/test.rb | 42 +++ shipping-api/config/initializers/assets.rb | 11 + .../initializers/backtrace_silencers.rb | 7 + .../config/initializers/cookies_serializer.rb | 3 + .../initializers/filter_parameter_logging.rb | 4 + .../config/initializers/inflections.rb | 16 ++ .../config/initializers/mime_types.rb | 4 + .../config/initializers/session_store.rb | 3 + .../config/initializers/wrap_parameters.rb | 14 + shipping-api/config/locales/en.yml | 23 ++ shipping-api/config/routes.rb | 56 ++++ shipping-api/config/secrets.yml | 22 ++ shipping-api/db/seeds.rb | 7 + shipping-api/lib/assets/.keep | 0 shipping-api/lib/tasks/.keep | 0 shipping-api/log/.keep | 0 shipping-api/public/404.html | 67 +++++ shipping-api/public/422.html | 67 +++++ shipping-api/public/500.html | 66 +++++ shipping-api/public/favicon.ico | 0 shipping-api/public/robots.txt | 5 + shipping-api/test/controllers/.keep | 0 shipping-api/test/fixtures/.keep | 0 shipping-api/test/helpers/.keep | 0 shipping-api/test/integration/.keep | 0 shipping-api/test/mailers/.keep | 0 shipping-api/test/models/.keep | 0 shipping-api/test/test_helper.rb | 10 + shipping-api/vendor/assets/javascripts/.keep | 0 shipping-api/vendor/assets/stylesheets/.keep | 0 59 files changed, 1097 insertions(+) create mode 100644 shipping-api/.gitignore create mode 100644 shipping-api/.ruby-gemset create mode 100644 shipping-api/.ruby-version create mode 100644 shipping-api/Gemfile create mode 100644 shipping-api/Gemfile.lock create mode 100644 shipping-api/README.rdoc create mode 100644 shipping-api/Rakefile create mode 100644 shipping-api/app/assets/images/.keep create mode 100644 shipping-api/app/assets/javascripts/application.js create mode 100644 shipping-api/app/assets/stylesheets/application.css create mode 100644 shipping-api/app/controllers/application_controller.rb create mode 100644 shipping-api/app/controllers/concerns/.keep create mode 100644 shipping-api/app/helpers/application_helper.rb create mode 100644 shipping-api/app/mailers/.keep create mode 100644 shipping-api/app/models/.keep create mode 100644 shipping-api/app/models/concerns/.keep create mode 100644 shipping-api/app/views/layouts/application.html.erb create mode 100755 shipping-api/bin/bundle create mode 100755 shipping-api/bin/rails create mode 100755 shipping-api/bin/rake create mode 100755 shipping-api/bin/setup create mode 100755 shipping-api/bin/spring create mode 100644 shipping-api/config.ru create mode 100644 shipping-api/config/application.rb create mode 100644 shipping-api/config/boot.rb create mode 100644 shipping-api/config/database.yml create mode 100644 shipping-api/config/environment.rb create mode 100644 shipping-api/config/environments/development.rb create mode 100644 shipping-api/config/environments/production.rb create mode 100644 shipping-api/config/environments/test.rb create mode 100644 shipping-api/config/initializers/assets.rb create mode 100644 shipping-api/config/initializers/backtrace_silencers.rb create mode 100644 shipping-api/config/initializers/cookies_serializer.rb create mode 100644 shipping-api/config/initializers/filter_parameter_logging.rb create mode 100644 shipping-api/config/initializers/inflections.rb create mode 100644 shipping-api/config/initializers/mime_types.rb create mode 100644 shipping-api/config/initializers/session_store.rb create mode 100644 shipping-api/config/initializers/wrap_parameters.rb create mode 100644 shipping-api/config/locales/en.yml create mode 100644 shipping-api/config/routes.rb create mode 100644 shipping-api/config/secrets.yml create mode 100644 shipping-api/db/seeds.rb create mode 100644 shipping-api/lib/assets/.keep create mode 100644 shipping-api/lib/tasks/.keep create mode 100644 shipping-api/log/.keep create mode 100644 shipping-api/public/404.html create mode 100644 shipping-api/public/422.html create mode 100644 shipping-api/public/500.html create mode 100644 shipping-api/public/favicon.ico create mode 100644 shipping-api/public/robots.txt create mode 100644 shipping-api/test/controllers/.keep create mode 100644 shipping-api/test/fixtures/.keep create mode 100644 shipping-api/test/helpers/.keep create mode 100644 shipping-api/test/integration/.keep create mode 100644 shipping-api/test/mailers/.keep create mode 100644 shipping-api/test/models/.keep create mode 100644 shipping-api/test/test_helper.rb create mode 100644 shipping-api/vendor/assets/javascripts/.keep create mode 100644 shipping-api/vendor/assets/stylesheets/.keep diff --git a/shipping-api/.gitignore b/shipping-api/.gitignore new file mode 100644 index 0000000..050c9d9 --- /dev/null +++ b/shipping-api/.gitignore @@ -0,0 +1,17 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/* +!/log/.keep +/tmp diff --git a/shipping-api/.ruby-gemset b/shipping-api/.ruby-gemset new file mode 100644 index 0000000..2fa5d76 --- /dev/null +++ b/shipping-api/.ruby-gemset @@ -0,0 +1 @@ +shipping-api diff --git a/shipping-api/.ruby-version b/shipping-api/.ruby-version new file mode 100644 index 0000000..c1026d2 --- /dev/null +++ b/shipping-api/.ruby-version @@ -0,0 +1 @@ +ruby-2.3.1 diff --git a/shipping-api/Gemfile b/shipping-api/Gemfile new file mode 100644 index 0000000..7d71160 --- /dev/null +++ b/shipping-api/Gemfile @@ -0,0 +1,65 @@ +source 'https://rubygems.org' +ruby '2.3.1' + +gem 'httparty' +gem 'rest-client' +gem 'omniauth' +gem 'graphviz' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.2.6' +# Use sqlite3 as the database for Active Record +gem 'pg' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.1.0' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'therubyracer', platforms: :ruby + +# Use jquery as the JavaScript library +gem 'jquery-rails' +# 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 +gem 'jbuilder', '~> 2.0' +# bundle exec rake doc:rails generates the API under doc/api. +gem 'sdoc', '~> 0.4.0', group: :doc + +# Use ActiveModel has_secure_password +# gem 'bcrypt', '~> 3.1.7' + +# Use Unicorn as the app server +# gem 'unicorn' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug' + gem 'pry-rails' + gem 'better_errors' + gem 'simplecov' + gem 'minitest-vcr' + gem 'minitest-reporters' + gem 'webmock' + gem 'dotenv-rails' +end + +group :development do + # Access an IRB console on exception pages or by using <%= console %> in views + gem 'web-console', '~> 2.0' + gem 'erd' + gem 'bootstrap-sass' + + + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + # gem 'spring' +end + +group :production do + gem 'rails_12factor' +end diff --git a/shipping-api/Gemfile.lock b/shipping-api/Gemfile.lock new file mode 100644 index 0000000..c0da126 --- /dev/null +++ b/shipping-api/Gemfile.lock @@ -0,0 +1,252 @@ +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.2.6) + actionpack (= 4.2.6) + actionview (= 4.2.6) + activejob (= 4.2.6) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.6) + actionview (= 4.2.6) + activesupport (= 4.2.6) + 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.6) + activesupport (= 4.2.6) + 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.6) + activesupport (= 4.2.6) + globalid (>= 0.3.0) + activemodel (4.2.6) + activesupport (= 4.2.6) + builder (~> 3.1) + activerecord (4.2.6) + activemodel (= 4.2.6) + activesupport (= 4.2.6) + arel (~> 6.0) + activesupport (4.2.6) + i18n (~> 0.7) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.4.0) + ansi (1.5.0) + arel (6.0.3) + autoprefixer-rails (6.3.6.1) + execjs + 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.3.6) + autoprefixer-rails (>= 5.2.1) + sass (>= 3.3.4) + builder (3.2.2) + byebug (9.0.4) + choice (0.2.0) + coderay (1.1.1) + coffee-rails (4.1.1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.1.x) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.10.0) + concurrent-ruby (1.0.2) + crack (0.4.3) + safe_yaml (~> 1.0.0) + debug_inspector (0.0.2) + docile (1.1.5) + dotenv (2.1.1) + dotenv-rails (2.1.1) + dotenv (= 2.1.1) + railties (>= 4.0, < 5.1) + erd (0.4.0) + nokogiri + rails-erd (>= 0.4.5) + erubis (2.7.0) + execjs (2.7.0) + globalid (0.3.6) + activesupport (>= 4.1.0) + graphviz (0.3.0) + hashdiff (0.3.0) + hashie (3.4.4) + httparty (0.13.7) + json (~> 1.8) + multi_xml (>= 0.5.2) + i18n (0.7.0) + jbuilder (2.4.1) + activesupport (>= 3.0.0, < 5.1) + multi_json (~> 1.2) + jquery-rails (4.1.1) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + json (1.8.3) + loofah (2.0.3) + nokogiri (>= 1.5.9) + mail (2.6.4) + mime-types (>= 1.16, < 4) + method_source (0.8.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mini_portile2 (2.0.0) + minispec-metadata (2.0.0) + minitest + minitest (5.9.0) + minitest-reporters (1.1.9) + ansi + builder + minitest (>= 5.0) + ruby-progressbar + minitest-vcr (1.4.0) + minispec-metadata (~> 2.0) + minitest (>= 4.7.5) + vcr (>= 2.9) + multi_json (1.12.1) + multi_xml (0.5.5) + nokogiri (1.6.7.2) + mini_portile2 (~> 2.0.0.rc2) + omniauth (1.3.1) + hashie (>= 1.2, < 4) + rack (>= 1.0, < 3) + pg (0.18.4) + pry (0.10.3) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-rails (0.3.4) + pry (>= 0.9.10) + rack (1.6.4) + rack-test (0.6.3) + rack (>= 1.0) + rails (4.2.6) + actionmailer (= 4.2.6) + actionpack (= 4.2.6) + actionview (= 4.2.6) + activejob (= 4.2.6) + activemodel (= 4.2.6) + activerecord (= 4.2.6) + activesupport (= 4.2.6) + bundler (>= 1.3.0, < 2.0) + railties (= 4.2.6) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.7) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-erd (1.4.7) + activerecord (>= 3.2) + activesupport (>= 3.2) + choice (~> 0.2.0) + ruby-graphviz (~> 1.2) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + rails_12factor (0.0.3) + rails_serve_static_assets + rails_stdout_logging + rails_serve_static_assets (0.0.5) + rails_stdout_logging (0.0.5) + railties (4.2.6) + actionpack (= 4.2.6) + activesupport (= 4.2.6) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (11.1.2) + rdoc (4.2.2) + json (~> 1.4) + rest-client (1.6.7) + mime-types (>= 1.16) + ruby-graphviz (1.2.2) + ruby-progressbar (1.8.1) + safe_yaml (1.0.4) + sass (3.4.22) + sass-rails (5.0.4) + railties (>= 4.0.0, < 5.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sdoc (0.4.1) + json (~> 1.7, >= 1.7.7) + rdoc (~> 4.0) + simplecov (0.11.2) + docile (~> 1.1.0) + json (~> 1.8) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.0) + slop (3.6.0) + sprockets (3.6.0) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.0.4) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (0.19.1) + thread_safe (0.3.5) + tilt (2.0.4) + turbolinks (2.5.3) + coffee-rails + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (3.0.0) + execjs (>= 0.3.0, < 3) + vcr (3.0.3) + web-console (2.3.0) + activemodel (>= 4.0) + binding_of_caller (>= 0.7.2) + railties (>= 4.0) + sprockets-rails (>= 2.0, < 4.0) + webmock (2.0.3) + addressable (>= 2.3.6) + crack (>= 0.3.2) + hashdiff + +PLATFORMS + ruby + +DEPENDENCIES + better_errors + bootstrap-sass + byebug + coffee-rails (~> 4.1.0) + dotenv-rails + erd + graphviz + httparty + jbuilder (~> 2.0) + jquery-rails + minitest-reporters + minitest-vcr + omniauth + pg + pry-rails + rails (= 4.2.6) + rails_12factor + rest-client + sass-rails (~> 5.0) + sdoc (~> 0.4.0) + simplecov + turbolinks + uglifier (>= 1.3.0) + web-console (~> 2.0) + webmock + +RUBY VERSION + ruby 2.3.1p112 + +BUNDLED WITH + 1.12.4 diff --git a/shipping-api/README.rdoc b/shipping-api/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/shipping-api/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/shipping-api/Rakefile b/shipping-api/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/shipping-api/Rakefile @@ -0,0 +1,6 @@ +# 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__) + +Rails.application.load_tasks diff --git a/shipping-api/app/assets/images/.keep b/shipping-api/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/app/assets/javascripts/application.js b/shipping-api/app/assets/javascripts/application.js new file mode 100644 index 0000000..e07c5a8 --- /dev/null +++ b/shipping-api/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/shipping-api/app/assets/stylesheets/application.css b/shipping-api/app/assets/stylesheets/application.css new file mode 100644 index 0000000..f9cd5b3 --- /dev/null +++ b/shipping-api/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/shipping-api/app/controllers/application_controller.rb b/shipping-api/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/shipping-api/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/shipping-api/app/controllers/concerns/.keep b/shipping-api/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/app/helpers/application_helper.rb b/shipping-api/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/shipping-api/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/shipping-api/app/mailers/.keep b/shipping-api/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/app/models/.keep b/shipping-api/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/app/models/concerns/.keep b/shipping-api/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/app/views/layouts/application.html.erb b/shipping-api/app/views/layouts/application.html.erb new file mode 100644 index 0000000..4e5d29f --- /dev/null +++ b/shipping-api/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + ShippingApi + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/shipping-api/bin/bundle b/shipping-api/bin/bundle new file mode 100755 index 0000000..66e9889 --- /dev/null +++ b/shipping-api/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/shipping-api/bin/rails b/shipping-api/bin/rails new file mode 100755 index 0000000..0138d79 --- /dev/null +++ b/shipping-api/bin/rails @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/shipping-api/bin/rake b/shipping-api/bin/rake new file mode 100755 index 0000000..d87d5f5 --- /dev/null +++ b/shipping-api/bin/rake @@ -0,0 +1,9 @@ +#!/usr/bin/env ruby +begin + load File.expand_path('../spring', __FILE__) +rescue LoadError => e + raise unless e.message.include?('spring') +end +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/shipping-api/bin/setup b/shipping-api/bin/setup new file mode 100755 index 0000000..acdb2c1 --- /dev/null +++ b/shipping-api/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/shipping-api/bin/spring b/shipping-api/bin/spring new file mode 100755 index 0000000..7fe232c --- /dev/null +++ b/shipping-api/bin/spring @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby + +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. + +unless defined?(Spring) + require 'rubygems' + require 'bundler' + + if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)) + Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) } + gem 'spring', match[1] + require 'spring/binstub' + end +end diff --git a/shipping-api/config.ru b/shipping-api/config.ru new file mode 100644 index 0000000..bd83b25 --- /dev/null +++ b/shipping-api/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/shipping-api/config/application.rb b/shipping-api/config/application.rb new file mode 100644 index 0000000..227ccf1 --- /dev/null +++ b/shipping-api/config/application.rb @@ -0,0 +1,26 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module ShippingApi + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + + # Do not swallow errors in after_commit/after_rollback callbacks. + config.active_record.raise_in_transactional_callbacks = true + end +end diff --git a/shipping-api/config/boot.rb b/shipping-api/config/boot.rb new file mode 100644 index 0000000..6b750f0 --- /dev/null +++ b/shipping-api/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/shipping-api/config/database.yml b/shipping-api/config/database.yml new file mode 100644 index 0000000..1c1a37c --- /dev/null +++ b/shipping-api/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# 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: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/shipping-api/config/environment.rb b/shipping-api/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/shipping-api/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/shipping-api/config/environments/development.rb b/shipping-api/config/environments/development.rb new file mode 100644 index 0000000..b55e214 --- /dev/null +++ b/shipping-api/config/environments/development.rb @@ -0,0 +1,41 @@ +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 + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # 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 + + # 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 + + # 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 + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/shipping-api/config/environments/production.rb b/shipping-api/config/environments/production.rb new file mode 100644 index 0000000..5c1b32e --- /dev/null +++ b/shipping-api/config/environments/production.rb @@ -0,0 +1,79 @@ +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 + + # 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.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # 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 + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # 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 +end diff --git a/shipping-api/config/environments/test.rb b/shipping-api/config/environments/test.rb new file mode 100644 index 0000000..1c19f08 --- /dev/null +++ b/shipping-api/config/environments/test.rb @@ -0,0 +1,42 @@ +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 + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # 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 file server for tests with Cache-Control for performance. + config.serve_static_files = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + 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 + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # 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 +end diff --git a/shipping-api/config/initializers/assets.rb b/shipping-api/config/initializers/assets.rb new file mode 100644 index 0000000..01ef3e6 --- /dev/null +++ b/shipping-api/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/shipping-api/config/initializers/backtrace_silencers.rb b/shipping-api/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/shipping-api/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/shipping-api/config/initializers/cookies_serializer.rb b/shipping-api/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7f70458 --- /dev/null +++ b/shipping-api/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/shipping-api/config/initializers/filter_parameter_logging.rb b/shipping-api/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/shipping-api/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/shipping-api/config/initializers/inflections.rb b/shipping-api/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/shipping-api/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# 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(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/shipping-api/config/initializers/mime_types.rb b/shipping-api/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/shipping-api/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/shipping-api/config/initializers/session_store.rb b/shipping-api/config/initializers/session_store.rb new file mode 100644 index 0000000..b0cd549 --- /dev/null +++ b/shipping-api/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_shipping-api_session' diff --git a/shipping-api/config/initializers/wrap_parameters.rb b/shipping-api/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/shipping-api/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# 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] if respond_to?(:wrap_parameters) +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/shipping-api/config/locales/en.yml b/shipping-api/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/shipping-api/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/shipping-api/config/routes.rb b/shipping-api/config/routes.rb new file mode 100644 index 0000000..3f66539 --- /dev/null +++ b/shipping-api/config/routes.rb @@ -0,0 +1,56 @@ +Rails.application.routes.draw do + # The priority is based upon order of creation: first created -> highest priority. + # See how all your routes lay out with "rake routes". + + # You can have the root of your site routed with "root" + # root 'welcome#index' + + # Example of regular route: + # get 'products/:id' => 'catalog#view' + + # Example of named route that can be invoked with purchase_url(id: product.id) + # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase + + # Example resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Example resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Example resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Example resource route with more complex sub-resources: + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', on: :collection + # end + # end + + # Example resource route with concerns: + # concern :toggleable do + # post 'toggle' + # end + # resources :posts, concerns: :toggleable + # resources :photos, concerns: :toggleable + + # Example resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end +end diff --git a/shipping-api/config/secrets.yml b/shipping-api/config/secrets.yml new file mode 100644 index 0000000..64da5ec --- /dev/null +++ b/shipping-api/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: 1bddcb4a02acf26eb6d69432893b55619fe61bd61b5a383e555e738b0ff1545787e3ce73d48be109b17292470904b59dc97bfc623047877b003a71dbb07522e5 + +test: + secret_key_base: 7ded01bee0435a73e41c67bb7bfd8bf39f9415a02073c4b82cf360da6c861384fe618ac029fe7cc51b1b7ac3a9de009c5430bede2488c3e3e1dfcf2c63302b1e + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/shipping-api/db/seeds.rb b/shipping-api/db/seeds.rb new file mode 100644 index 0000000..4edb1e8 --- /dev/null +++ b/shipping-api/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/shipping-api/lib/assets/.keep b/shipping-api/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/lib/tasks/.keep b/shipping-api/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/log/.keep b/shipping-api/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/public/404.html b/shipping-api/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/shipping-api/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/shipping-api/public/422.html b/shipping-api/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/shipping-api/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/shipping-api/public/500.html b/shipping-api/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/shipping-api/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/shipping-api/public/favicon.ico b/shipping-api/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/public/robots.txt b/shipping-api/public/robots.txt new file mode 100644 index 0000000..3c9c7c0 --- /dev/null +++ b/shipping-api/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/shipping-api/test/controllers/.keep b/shipping-api/test/controllers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/test/fixtures/.keep b/shipping-api/test/fixtures/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/test/helpers/.keep b/shipping-api/test/helpers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/test/integration/.keep b/shipping-api/test/integration/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/test/mailers/.keep b/shipping-api/test/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/test/models/.keep b/shipping-api/test/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/test/test_helper.rb b/shipping-api/test/test_helper.rb new file mode 100644 index 0000000..92e39b2 --- /dev/null +++ b/shipping-api/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/shipping-api/vendor/assets/javascripts/.keep b/shipping-api/vendor/assets/javascripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/shipping-api/vendor/assets/stylesheets/.keep b/shipping-api/vendor/assets/stylesheets/.keep new file mode 100644 index 0000000..e69de29 From 8344da4ab8f7a9bd72535a37836b485ff5a12fc6 Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 23 May 2016 15:12:57 -0700 Subject: [PATCH 02/35] fixed messed up folder structure --- .DS_Store | Bin 0 -> 6148 bytes shipping-api/Gemfile => Gemfile | 0 shipping-api/Gemfile.lock => Gemfile.lock | 0 shipping-api/README.rdoc => README.rdoc | 0 shipping-api/Rakefile => Rakefile | 0 {shipping-api/app => app}/assets/images/.keep | 0 .../assets/javascripts/application.js | 0 .../assets/stylesheets/application.css | 0 .../controllers/application_controller.rb | 0 .../app => app}/controllers/concerns/.keep | 0 .../app => app}/helpers/application_helper.rb | 0 {shipping-api/app => app}/mailers/.keep | 0 {shipping-api/app => app}/models/.keep | 0 .../app => app}/models/concerns/.keep | 0 .../views/layouts/application.html.erb | 0 {shipping-api/bin => bin}/bundle | 0 {shipping-api/bin => bin}/rails | 0 {shipping-api/bin => bin}/rake | 0 {shipping-api/bin => bin}/setup | 0 {shipping-api/bin => bin}/spring | 0 shipping-api/config.ru => config.ru | 0 .../config => config}/application.rb | 0 {shipping-api/config => config}/boot.rb | 0 {shipping-api/config => config}/database.yml | 0 .../config => config}/environment.rb | 0 .../environments/development.rb | 0 .../environments/production.rb | 0 .../config => config}/environments/test.rb | 0 .../config => config}/initializers/assets.rb | 0 .../initializers/backtrace_silencers.rb | 0 .../initializers/cookies_serializer.rb | 0 .../initializers/filter_parameter_logging.rb | 0 .../initializers/inflections.rb | 0 .../initializers/mime_types.rb | 0 .../initializers/session_store.rb | 0 .../initializers/wrap_parameters.rb | 0 .../config => config}/locales/en.yml | 0 {shipping-api/config => config}/routes.rb | 0 {shipping-api/db => db}/seeds.rb | 0 {shipping-api/lib => lib}/assets/.keep | 0 {shipping-api/lib => lib}/tasks/.keep | 0 {shipping-api/public => public}/404.html | 0 {shipping-api/public => public}/422.html | 0 {shipping-api/public => public}/500.html | 0 {shipping-api/public => public}/favicon.ico | 0 {shipping-api/public => public}/robots.txt | 0 shipping-api/.gitignore | 17 -------------- shipping-api/.ruby-gemset | 1 - shipping-api/.ruby-version | 1 - shipping-api/config/secrets.yml | 22 ------------------ shipping-api/vendor/assets/stylesheets/.keep | 0 {shipping-api/log => test/controllers}/.keep | 0 .../test/controllers => test/fixtures}/.keep | 0 .../test/fixtures => test/helpers}/.keep | 0 .../test/helpers => test/integration}/.keep | 0 .../test/integration => test/mailers}/.keep | 0 .../test/mailers => test/models}/.keep | 0 {shipping-api/test => test}/test_helper.rb | 0 .../assets/javascripts}/.keep | 0 .../assets/stylesheets}/.keep | 0 60 files changed, 41 deletions(-) create mode 100644 .DS_Store rename shipping-api/Gemfile => Gemfile (100%) rename shipping-api/Gemfile.lock => Gemfile.lock (100%) rename shipping-api/README.rdoc => README.rdoc (100%) rename shipping-api/Rakefile => Rakefile (100%) rename {shipping-api/app => app}/assets/images/.keep (100%) rename {shipping-api/app => app}/assets/javascripts/application.js (100%) rename {shipping-api/app => app}/assets/stylesheets/application.css (100%) rename {shipping-api/app => app}/controllers/application_controller.rb (100%) rename {shipping-api/app => app}/controllers/concerns/.keep (100%) rename {shipping-api/app => app}/helpers/application_helper.rb (100%) rename {shipping-api/app => app}/mailers/.keep (100%) rename {shipping-api/app => app}/models/.keep (100%) rename {shipping-api/app => app}/models/concerns/.keep (100%) rename {shipping-api/app => app}/views/layouts/application.html.erb (100%) rename {shipping-api/bin => bin}/bundle (100%) rename {shipping-api/bin => bin}/rails (100%) rename {shipping-api/bin => bin}/rake (100%) rename {shipping-api/bin => bin}/setup (100%) rename {shipping-api/bin => bin}/spring (100%) rename shipping-api/config.ru => config.ru (100%) rename {shipping-api/config => config}/application.rb (100%) rename {shipping-api/config => config}/boot.rb (100%) rename {shipping-api/config => config}/database.yml (100%) rename {shipping-api/config => config}/environment.rb (100%) rename {shipping-api/config => config}/environments/development.rb (100%) rename {shipping-api/config => config}/environments/production.rb (100%) rename {shipping-api/config => config}/environments/test.rb (100%) rename {shipping-api/config => config}/initializers/assets.rb (100%) rename {shipping-api/config => config}/initializers/backtrace_silencers.rb (100%) rename {shipping-api/config => config}/initializers/cookies_serializer.rb (100%) rename {shipping-api/config => config}/initializers/filter_parameter_logging.rb (100%) rename {shipping-api/config => config}/initializers/inflections.rb (100%) rename {shipping-api/config => config}/initializers/mime_types.rb (100%) rename {shipping-api/config => config}/initializers/session_store.rb (100%) rename {shipping-api/config => config}/initializers/wrap_parameters.rb (100%) rename {shipping-api/config => config}/locales/en.yml (100%) rename {shipping-api/config => config}/routes.rb (100%) rename {shipping-api/db => db}/seeds.rb (100%) rename {shipping-api/lib => lib}/assets/.keep (100%) rename {shipping-api/lib => lib}/tasks/.keep (100%) rename {shipping-api/public => public}/404.html (100%) rename {shipping-api/public => public}/422.html (100%) rename {shipping-api/public => public}/500.html (100%) rename {shipping-api/public => public}/favicon.ico (100%) rename {shipping-api/public => public}/robots.txt (100%) delete mode 100644 shipping-api/.gitignore delete mode 100644 shipping-api/.ruby-gemset delete mode 100644 shipping-api/.ruby-version delete mode 100644 shipping-api/config/secrets.yml delete mode 100644 shipping-api/vendor/assets/stylesheets/.keep rename {shipping-api/log => test/controllers}/.keep (100%) rename {shipping-api/test/controllers => test/fixtures}/.keep (100%) rename {shipping-api/test/fixtures => test/helpers}/.keep (100%) rename {shipping-api/test/helpers => test/integration}/.keep (100%) rename {shipping-api/test/integration => test/mailers}/.keep (100%) rename {shipping-api/test/mailers => test/models}/.keep (100%) rename {shipping-api/test => test}/test_helper.rb (100%) rename {shipping-api/test/models => vendor/assets/javascripts}/.keep (100%) rename {shipping-api/vendor/assets/javascripts => vendor/assets/stylesheets}/.keep (100%) diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 diff --git a/shipping-api/vendor/assets/stylesheets/.keep b/shipping-api/vendor/assets/stylesheets/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/shipping-api/log/.keep b/test/controllers/.keep similarity index 100% rename from shipping-api/log/.keep rename to test/controllers/.keep diff --git a/shipping-api/test/controllers/.keep b/test/fixtures/.keep similarity index 100% rename from shipping-api/test/controllers/.keep rename to test/fixtures/.keep diff --git a/shipping-api/test/fixtures/.keep b/test/helpers/.keep similarity index 100% rename from shipping-api/test/fixtures/.keep rename to test/helpers/.keep diff --git a/shipping-api/test/helpers/.keep b/test/integration/.keep similarity index 100% rename from shipping-api/test/helpers/.keep rename to test/integration/.keep diff --git a/shipping-api/test/integration/.keep b/test/mailers/.keep similarity index 100% rename from shipping-api/test/integration/.keep rename to test/mailers/.keep diff --git a/shipping-api/test/mailers/.keep b/test/models/.keep similarity index 100% rename from shipping-api/test/mailers/.keep rename to test/models/.keep diff --git a/shipping-api/test/test_helper.rb b/test/test_helper.rb similarity index 100% rename from shipping-api/test/test_helper.rb rename to test/test_helper.rb diff --git a/shipping-api/test/models/.keep b/vendor/assets/javascripts/.keep similarity index 100% rename from shipping-api/test/models/.keep rename to vendor/assets/javascripts/.keep diff --git a/shipping-api/vendor/assets/javascripts/.keep b/vendor/assets/stylesheets/.keep similarity index 100% rename from shipping-api/vendor/assets/javascripts/.keep rename to vendor/assets/stylesheets/.keep From 7f42a310addd6837112c500147a8b94f8317c944 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 23 May 2016 15:20:19 -0700 Subject: [PATCH 03/35] Re-added gemset and version since we messed around with folders and they kinda disappeared --- .ruby-gemset | 1 + .ruby-version | 1 + 2 files changed, 2 insertions(+) create mode 100644 .ruby-gemset create mode 100644 .ruby-version diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 index 0000000..91ffe71 --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1 @@ +shipping-service diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..c1026d2 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +ruby-2.3.1 From 8c3bda35e88c93178ec0beb702b2ee5cea567768 Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 23 May 2016 16:56:53 -0700 Subject: [PATCH 04/35] still trying to figure out what we are doing --- Gemfile | 1 + app/models/shipping.rb | 2 ++ config/database.yml | 8 ++++---- db/migrate/20160523232953_create_shippings.rb | 8 ++++++++ .../20160523233048_add_column_to_shipping.rb | 5 +++++ db/schema.rb | 19 +++++++++++++++++++ test/fixtures/shippings.yml | 11 +++++++++++ test/models/shipping_test.rb | 7 +++++++ 8 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 app/models/shipping.rb create mode 100644 db/migrate/20160523232953_create_shippings.rb create mode 100644 db/migrate/20160523233048_add_column_to_shipping.rb create mode 100644 db/schema.rb create mode 100644 test/fixtures/shippings.yml create mode 100644 test/models/shipping_test.rb diff --git a/Gemfile b/Gemfile index 7d71160..422bdfe 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ gem 'httparty' gem 'rest-client' gem 'omniauth' gem 'graphviz' +gem 'active_shipping' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.6' diff --git a/app/models/shipping.rb b/app/models/shipping.rb new file mode 100644 index 0000000..7843be9 --- /dev/null +++ b/app/models/shipping.rb @@ -0,0 +1,2 @@ +class Shipping < ActiveRecord::Base +end diff --git a/config/database.yml b/config/database.yml index 1c1a37c..e661255 100644 --- a/config/database.yml +++ b/config/database.yml @@ -5,21 +5,21 @@ # gem 'sqlite3' # default: &default - adapter: sqlite3 + adapter: postgresql pool: 5 timeout: 5000 development: <<: *default - database: db/development.sqlite3 + database: shipping_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: <<: *default - database: db/test.sqlite3 + database: shipping_test production: <<: *default - database: db/production.sqlite3 + database: shipping_production diff --git a/db/migrate/20160523232953_create_shippings.rb b/db/migrate/20160523232953_create_shippings.rb new file mode 100644 index 0000000..8c8eed7 --- /dev/null +++ b/db/migrate/20160523232953_create_shippings.rb @@ -0,0 +1,8 @@ +class CreateShippings < ActiveRecord::Migration + def change + create_table :shippings do |t| + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160523233048_add_column_to_shipping.rb b/db/migrate/20160523233048_add_column_to_shipping.rb new file mode 100644 index 0000000..7f33292 --- /dev/null +++ b/db/migrate/20160523233048_add_column_to_shipping.rb @@ -0,0 +1,5 @@ +class AddColumnToShipping < ActiveRecord::Migration + def change + + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..ea89ed5 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,19 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# 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 that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 0) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + +end diff --git a/test/fixtures/shippings.yml b/test/fixtures/shippings.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/shippings.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb new file mode 100644 index 0000000..1e045ff --- /dev/null +++ b/test/models/shipping_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ShippingTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From be6cdf7037d73034abf3074e750a7a535c5ce068 Mon Sep 17 00:00:00 2001 From: Valerie Date: Tue, 24 May 2016 09:40:04 -0700 Subject: [PATCH 05/35] Updated gemfile --- Gemfile | 1 + Gemfile.lock | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Gemfile b/Gemfile index 7d71160..422bdfe 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ gem 'httparty' gem 'rest-client' gem 'omniauth' gem 'graphviz' +gem 'active_shipping' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.6' diff --git a/Gemfile.lock b/Gemfile.lock index c0da126..81c17f2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -20,6 +20,14 @@ GEM erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) + active_shipping (1.7.2) + active_utils (~> 3.2.0) + activesupport (>= 3.2, < 5.0.0) + nokogiri (>= 1.6) + quantified (~> 1.0.1) + active_utils (3.2.0) + activesupport (>= 3.2) + i18n activejob (4.2.6) activesupport (= 4.2.6) globalid (>= 0.3.0) @@ -127,6 +135,7 @@ GEM slop (~> 3.4) pry-rails (0.3.4) pry (>= 0.9.10) + quantified (1.0.1) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) @@ -219,6 +228,7 @@ PLATFORMS ruby DEPENDENCIES + active_shipping better_errors bootstrap-sass byebug From 9ec82426331e3fdd00bb8a876c887deeffaa63f9 Mon Sep 17 00:00:00 2001 From: Valerie Date: Tue, 24 May 2016 10:52:19 -0700 Subject: [PATCH 06/35] Added env variable for login key security and wrote test to make sure USPS key works --- .gitignore | 1 + db/schema.rb | 7 ++++++- test/models/shipping_test.rb | 15 ++++++++++++--- test/test_helper.rb | 16 ++++++++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 14e3ed5..ec080ba 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ /test/tmp/ /test/version_tmp/ /tmp/ +.env ## Specific to RubyMotion: .dat* diff --git a/db/schema.rb b/db/schema.rb index ea89ed5..13a2206 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,9 +11,14 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 0) do +ActiveRecord::Schema.define(version: 20160523233048) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "shippings", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + end diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb index 1e045ff..55e386e 100644 --- a/test/models/shipping_test.rb +++ b/test/models/shipping_test.rb @@ -1,7 +1,16 @@ require 'test_helper' class ShippingTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end + describe "API" do + + # setup do + # + # end + + it "should return an instance of USPS", :vcr do + usps = ActiveShipping::USPS.new(login: ENV["USPS_LOGIN_KEY"]) + assert usps.is_a? ActiveShipping::USPS + end + + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 92e39b2..c06cba4 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,22 @@ require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require 'active_shipping' +require 'minitest/spec' +require "minispec-metadata" +require 'vcr' +require 'minitest-vcr' +require 'webmock/minitest' +require "minitest/reporters" + +VCR.configure do |c| + c.cassette_library_dir = 'test/cassettes' + c.hook_into :webmock +end + +Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new +MinitestVcr::Spec.configure! + class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all From 411cc18e1f1714c96c585cad34917dc78bd0e2b1 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 24 May 2016 10:53:13 -0700 Subject: [PATCH 07/35] making changes to test helper --- test/test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 92e39b2..bf3bf79 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,7 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' - +require 'active_shipping' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all From 11f0cdf1a492159cfffbda5f9212285a5d8a059c Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 24 May 2016 10:59:55 -0700 Subject: [PATCH 08/35] starting testing --- test/models/shipping_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb index 55e386e..c7c26e9 100644 --- a/test/models/shipping_test.rb +++ b/test/models/shipping_test.rb @@ -12,5 +12,9 @@ class ShippingTest < ActiveSupport::TestCase assert usps.is_a? ActiveShipping::USPS end + it "shuld return an instance of Fedex", :vcr do + fedex = ActiveShipping::FedEx.new(login: '999999999', password: '7777777', key: '1BXXXXXXXXXxrcB', account: '51XXXXX20') + end + end end From 8209f78684a85ddfd994b763e00765f4d572914e Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 24 May 2016 11:11:42 -0700 Subject: [PATCH 09/35] first passing test --- test/models/shipping_test.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb index c7c26e9..d39240c 100644 --- a/test/models/shipping_test.rb +++ b/test/models/shipping_test.rb @@ -13,7 +13,9 @@ class ShippingTest < ActiveSupport::TestCase end it "shuld return an instance of Fedex", :vcr do - fedex = ActiveShipping::FedEx.new(login: '999999999', password: '7777777', key: '1BXXXXXXXXXxrcB', account: '51XXXXX20') + fedex = ActiveShipping::FedEx.new(login: ENV['FEDEX_METER_NUMBER'], + password: ENV['FEDEX_TEST_PASSWORD'], key: ENV['FEDEX_TEST_KEY'], account: ENV['FEDEX_ACCOUNT_NUMBER']) + assert fedex.is_a? ActiveShipping::FedEx end end From 3fecaa6cf3def3b2806b64f1ee334eecc6e38086 Mon Sep 17 00:00:00 2001 From: Valerie Date: Tue, 24 May 2016 11:23:27 -0700 Subject: [PATCH 10/35] USPS test works --- test/models/shipping_test.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb index 55e386e..f3667c4 100644 --- a/test/models/shipping_test.rb +++ b/test/models/shipping_test.rb @@ -3,10 +3,6 @@ class ShippingTest < ActiveSupport::TestCase describe "API" do - # setup do - # - # end - it "should return an instance of USPS", :vcr do usps = ActiveShipping::USPS.new(login: ENV["USPS_LOGIN_KEY"]) assert usps.is_a? ActiveShipping::USPS From 5fe40255351fafca3588d388e8bc5cdc03e24298 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 24 May 2016 11:26:13 -0700 Subject: [PATCH 11/35] testing fedex api --- test/models/shipping_test.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb index 59dd960..3b55e27 100644 --- a/test/models/shipping_test.rb +++ b/test/models/shipping_test.rb @@ -3,10 +3,9 @@ class ShippingTest < ActiveSupport::TestCase describe "API" do - it "should return an instance of USPS", :vcr do - usps = ActiveShipping::USPS.new(login: ENV["USPS_LOGIN_KEY"]) - assert usps.is_a? ActiveShipping::USPS - end + # setup do + # + # end it "shuld return an instance of Fedex", :vcr do fedex = ActiveShipping::FedEx.new(login: ENV['FEDEX_METER_NUMBER'], @@ -14,5 +13,8 @@ class ShippingTest < ActiveSupport::TestCase assert fedex.is_a? ActiveShipping::FedEx end + + it "" + end end From e114a623c1ff38a07225eb672c68cbc23bd846b9 Mon Sep 17 00:00:00 2001 From: Valerie Date: Tue, 24 May 2016 11:32:17 -0700 Subject: [PATCH 12/35] Somehow lost the USPS test in some weird merge thing, but luckily I had given that code to someone on Slack so I was able to paste it back in, whoops. This commit contains that USPS test code. --- test/models/shipping_test.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb index 3b55e27..a58d883 100644 --- a/test/models/shipping_test.rb +++ b/test/models/shipping_test.rb @@ -3,18 +3,16 @@ class ShippingTest < ActiveSupport::TestCase describe "API" do - # setup do - # - # end + it "should return an instance of USPS", :vcr do + usps = ActiveShipping::USPS.new(login: ENV["USPS_LOGIN_KEY"]) + assert usps.is_a? ActiveShipping::USPS + end - it "shuld return an instance of Fedex", :vcr do + it "should return an instance of Fedex", :vcr do fedex = ActiveShipping::FedEx.new(login: ENV['FEDEX_METER_NUMBER'], password: ENV['FEDEX_TEST_PASSWORD'], key: ENV['FEDEX_TEST_KEY'], account: ENV['FEDEX_ACCOUNT_NUMBER']) assert fedex.is_a? ActiveShipping::FedEx end - - it "" - end end From 96ce580192a088576dd31553903f8d0f9f139c43 Mon Sep 17 00:00:00 2001 From: Valerie Date: Tue, 24 May 2016 14:23:06 -0700 Subject: [PATCH 13/35] Figured out what activeshipping find_rates method returns by using a test --- ...eturn_an_array_when_finding_USPS_rates.yml | 103 ++++++++++++++++++ test/models/shipping_test.rb | 41 ++++++- 2 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 test/cassettes/API/USPS/should_return_an_array_when_finding_USPS_rates.yml diff --git a/test/cassettes/API/USPS/should_return_an_array_when_finding_USPS_rates.yml b/test/cassettes/API/USPS/should_return_an_array_when_finding_USPS_rates.yml new file mode 100644 index 0000000..3e91320 --- /dev/null +++ b/test/cassettes/API/USPS/should_return_an_array_when_finding_USPS_rates.yml @@ -0,0 +1,103 @@ +--- +http_interactions: +- request: + method: get + uri: http://production.shippingapis.com/ShippingAPI.dll?API=RateV4&XML=%3C?xml%20version=%221.0%22?%3E%0A%3CRateV4Request%20USERID=%22801ADADE3686%22%3E%0A%20%20%3CPackage%20ID=%220%22%3E%0A%20%20%20%20%3CService%3EALL%3C/Service%3E%0A%20%20%20%20%3CFirstClassMailType/%3E%0A%20%20%20%20%3CZipOrigination%3E90210%3C/ZipOrigination%3E%0A%20%20%20%20%3CZipDestination%3E72201%3C/ZipDestination%3E%0A%20%20%20%20%3CPounds%3E0%3C/Pounds%3E%0A%20%20%20%20%3COunces%3E3.5%3C/Ounces%3E%0A%20%20%20%20%3CContainer%3ENONRECTANGULAR%3C/Container%3E%0A%20%20%20%20%3CSize%3ELARGE%3C/Size%3E%0A%20%20%20%20%3CWidth%3E3.94%3C/Width%3E%0A%20%20%20%20%3CLength%3E36.61%3C/Length%3E%0A%20%20%20%20%3CHeight%3E3.94%3C/Height%3E%0A%20%20%20%20%3CGirth%3E12.37%3C/Girth%3E%0A%20%20%20%20%3CMachinable%3EFALSE%3C/Machinable%3E%0A%20%20%3C/Package%3E%0A%20%20%3CPackage%20ID=%221%22%3E%0A%20%20%20%20%3CService%3EALL%3C/Service%3E%0A%20%20%20%20%3CFirstClassMailType/%3E%0A%20%20%20%20%3CZipOrigination%3E90210%3C/ZipOrigination%3E%0A%20%20%20%20%3CZipDestination%3E72201%3C/ZipDestination%3E%0A%20%20%20%20%3CPounds%3E0%3C/Pounds%3E%0A%20%20%20%20%3COunces%3E120.0%3C/Ounces%3E%0A%20%20%20%20%3CContainer%3ERECTANGULAR%3C/Container%3E%0A%20%20%20%20%3CSize%3ELARGE%3C/Size%3E%0A%20%20%20%20%3CWidth%3E10.00%3C/Width%3E%0A%20%20%20%20%3CLength%3E15.00%3C/Length%3E%0A%20%20%20%20%3CHeight%3E4.50%3C/Height%3E%0A%20%20%20%20%3CGirth%3E29.00%3C/Girth%3E%0A%20%20%20%20%3CMachinable%3ETRUE%3C/Machinable%3E%0A%20%20%3C/Package%3E%0A%3C/RateV4Request%3E%0A + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + X-Backside-Transport: + - OK OK + Cache-Control: + - private + Content-Type: + - text/xml + Server: + - Microsoft-IIS/7.5 + X-Aspnet-Version: + - 2.0.50727 + X-Powered-By: + - ASP.NET + Date: + - Tue, 24 May 2016 20:53:14 GMT + X-Client-Ip: + - 56.0.70.6 + X-Global-Transaction-Id: + - '2248910545' + Access-Control-Allow-Origin: + - "*" + Connection: + - Keep-Alive + Cteonnt-Length: + - '2216' + X-Frame-Options: + - SAMEORIGIN + Content-Length: + - '492' + body: + encoding: ASCII-8BIT + string: |- + + 902107220103.5LARGEFALSE7Priority Mail Express 1-Day&lt;sup&gt;&#8482;&lt;/sup&gt;29.25Priority Mail Express 1-Day&lt;sup&gt;&#8482;&lt;/sup&gt; Hold For Pickup29.25Priority Mail 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt;7.30First-Class Mail&lt;sup&gt;&#174;&lt;/sup&gt; Parcel2.64USPS Retail Ground&lt;sup&gt;&#8482;&lt;/sup&gt;7.29Media Mail Parcel2.61Library Mail Parcel2.4890210722010120.0LARGETRUE7Priority Mail Express 1-Day&lt;sup&gt;&#8482;&lt;/sup&gt;73.05Priority Mail Express 1-Day&lt;sup&gt;&#8482;&lt;/sup&gt; Hold For Pickup73.05Priority Mail 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt;27.80USPS Retail Ground&lt;sup&gt;&#8482;&lt;/sup&gt;23.93Media Mail Parcel5.97Library Mail Parcel5.70 + http_version: + recorded_at: Tue, 24 May 2016 20:53:14 GMT +- request: + method: post + uri: https://gatewaybeta.fedex.com/xml + body: + encoding: UTF-8 + string: wTCb9AumfkXtr27Q RHz0ShHCr73OwFqQu5RC1CL7B 510087224 118727760 ActiveShipping crs 13 0 0 true SATURDAY_DELIVERY 2016-05-24T13:53:15-07:00 REGULAR_PICKUP YOUR_PACKAGING
Beverly + Hills 90210 US true
Little + Rock 72201 US true
PARCEL_SELECT 5902 ACCOUNT 2 1 LB 0.22 37 4 4 IN 1 LB 7.5 15 10 5 IN
+ headers: + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 24 May 2016 20:53:15 GMT + Server: + - Apache + Set-Cookie: + - siteDC=edc; path=/; domain=.fedex.com; expires=Wed, 25-May-2016 20:53:15 GMT + X-Wily-Servlet: + - Encrypt1 GaMcoOotgOSMyoYj73M4djxB/BFdu6Bd7dK9l2vKcsLoBxuCEbM12kwUffT0WqzWwhNfXxOuv1xkOK5NUzCbP46u7vtBQL8InqrXYgHsCoR6RU11Zne5eRfVnPz2s4QorsTJGp6CmyYymgSUI+wxBxsf5OU5gsdEA72cMkRv/fgqELt9eafqj4Lrwr4CAfmKraE28AJvbqJTb+A/db2E4A== + X-Powered-By: + - Servlet/2.5 JSP/2.1 + X-Wily-Info: + - Clear guid=E48B022DCC87128E0F000C2DF0CC26EB + Vary: + - Accept-Encoding + Transfer-Encoding: + - chunked + Content-Type: + - text/xml; charset=utf-8 + body: + encoding: ASCII-8BIT + string: |- + + NOTENOTEcrs819The origin state/province code has been changed. The origin state/province code has been changed. NOTEcrs820The destination state/province code has been changed. The destination state/province code has been changed. ActiveShippingcrs1300FIRST_OVERNIGHTYOUR_PACKAGINGLITA WED2016-05-25T08:00:00FIRST_OVERNIGHT2016-05-25T08:00:00WEDA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD9.17USD250.83USD0.0USD250.83USD0.0USD0.0USD250.83RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.87RATED_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD9.17USD250.83USD0.0USD250.83USD0.0USD0.0USD250.83RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.87PRIORITY_OVERNIGHTYOUR_PACKAGINGLITA WED2016-05-25T10:30:00PRIORITY_OVERNIGHT2016-05-25T10:30:00WEDA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD7.91USD81.91USD0.0USD81.91USD0.0USD0.0USD81.91RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.61RATED_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD7.91USD81.91USD0.0USD81.91USD0.0USD0.0USD81.91RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.61STANDARD_OVERNIGHTYOUR_PACKAGINGLITA WED2016-05-25T20:00:00STANDARD_OVERNIGHT2016-05-25T20:00:00WEDA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE13937PACKAGEMIXED00.75LB12.0USD170.7USD0.0USD170.7USD8.63USD179.33USD0.0USD179.33USD0.0USD0.0USD179.33RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.33RATED_ACCOUNT_PACKAGE13937PACKAGEMIXED00.75LB12.0USD170.7USD0.0USD170.7USD8.63USD179.33USD0.0USD179.33USD0.0USD0.0USD179.33RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.33FEDEX_2_DAY_AMYOUR_PACKAGINGLITA THU2016-05-26T10:30:00FEDEX_2_DAY_AM2016-05-26T10:30:00THUA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE147PACKAGEMIXED00.75LB12.0USD108.07USD0.0USD108.07USD8.17USD116.24USD0.0USD116.24USD0.0USD0.0USD116.24RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.87RATED_ACCOUNT_PACKAGE147PACKAGEMIXED00.75LB12.0USD108.07USD0.0USD108.07USD8.17USD116.24USD0.0USD116.24USD0.0USD0.0USD116.24RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.87FEDEX_2_DAYYOUR_PACKAGINGLITA THU2016-05-26T20:00:00FEDEX_2_DAY2016-05-26T20:00:00THUA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE60907PACKAGEMIXED00.75LB12.0USD93.97USD0.0USD93.97USD8.06USD102.03USD0.0USD102.03USD0.0USD0.0USD102.03RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.76RATED_ACCOUNT_PACKAGE60907PACKAGEMIXED00.75LB12.0USD93.97USD0.0USD93.97USD8.06USD102.03USD0.0USD102.03USD0.0USD0.0USD102.03RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.76FEDEX_EXPRESS_SAVERYOUR_PACKAGINGLITA FRI2016-05-27T20:00:00FEDEX_EXPRESS_SAVER2016-05-27T20:00:00FRIA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE71777PACKAGEMIXED00.75LB12.0USD64.24USD0.0USD64.24USD7.84USD72.08USD0.0USD72.08USD0.0USD0.0USD72.08RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.54RATED_ACCOUNT_PACKAGE71777PACKAGEMIXED00.75LB12.0USD64.24USD0.0USD64.24USD7.84USD72.08USD0.0USD72.08USD0.0USD0.0USD72.08RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.54GROUND_HOME_DELIVERYYOUR_PACKAGINGGROUND_HOME_DELIVERYTHREE_DAYS0LITfalseTHREE_DAYSSERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE7MIXED1663.75LB12.0LB4.0USD23.56USD1.89USD21.67USD7.55USD29.22USD0.0USD29.22USD0.0USD0.0USD29.22VOLUMEBaseUSD1.890.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD6.5FUELPACKAGEFedEx Ground FuelUSD1.050PAYOR_ACCOUNT_PACKAGEDIMLB4.0LB4.0USD11.09USD0.89USD10.2USD3.75USD13.95USD0.0USD13.95USD0.0VOLUMEBaseUSD0.890.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD3.25FUELPACKAGEFedEx Ground FuelUSD0.50PAYOR_ACCOUNT_PACKAGEACTUALLB8.0USD12.47USD1.0USD11.47USD3.8USD15.27USD0.0USD15.27USD0.0VOLUMEBaseUSD1.00.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD3.25FUELPACKAGEFedEx Ground FuelUSD0.55 + http_version: + recorded_at: Tue, 24 May 2016 20:53:17 GMT +recorded_with: VCR 3.0.3 diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb index a58d883..620e935 100644 --- a/test/models/shipping_test.rb +++ b/test/models/shipping_test.rb @@ -3,15 +3,46 @@ class ShippingTest < ActiveSupport::TestCase describe "API" do + before do + @usps = ActiveShipping::USPS.new(login: ENV["USPS_LOGIN_KEY"]) + @fedex = ActiveShipping::FedEx.new(login: ENV['FEDEX_METER_NUMBER'], + password: ENV['FEDEX_TEST_PASSWORD'], key: ENV['FEDEX_TEST_KEY'], account: ENV['FEDEX_ACCOUNT_NUMBER'], test: true) + @packages = [ + ActiveShipping::Package.new(100, [93,10], cylinder: true), + ActiveShipping::Package.new(7.5 * 16, [15, 10, 4.5], units: :imperial) + ] + # You live in Beverly Hills, he lives in Ottawa + @origin = ActiveShipping::Location.new(country: 'US', + state: 'CA', + city: 'Beverly Hills', + zip: '90210') + @destination = ActiveShipping::Location.new(country: 'US', + state: 'AK', + city: 'Little Rock', + zip: '72201') + end + it "should return an instance of USPS", :vcr do - usps = ActiveShipping::USPS.new(login: ENV["USPS_LOGIN_KEY"]) - assert usps.is_a? ActiveShipping::USPS + # usps = ActiveShipping::USPS.new(login: ENV["USPS_LOGIN_KEY"]) + assert @usps.is_a? ActiveShipping::USPS end it "should return an instance of Fedex", :vcr do - fedex = ActiveShipping::FedEx.new(login: ENV['FEDEX_METER_NUMBER'], - password: ENV['FEDEX_TEST_PASSWORD'], key: ENV['FEDEX_TEST_KEY'], account: ENV['FEDEX_ACCOUNT_NUMBER']) - assert fedex.is_a? ActiveShipping::FedEx + assert @fedex.is_a? ActiveShipping::FedEx + end + + describe "USPS" do + + it "should return an array when finding USPS rates", :vcr do + response = @usps.find_rates(@origin, @destination, @packages) + usps_rates = response.rates.sort_by(&:price).collect {|rate| [rate.service_name, rate.price]} + binding.pry + assert usps_rates.is_a? Array + end + + + + end end From 8b8cb3777c339a8314fe88eddd8905a26998f6bf Mon Sep 17 00:00:00 2001 From: Valerie Date: Wed, 25 May 2016 09:11:14 -0700 Subject: [PATCH 14/35] Set up quotes controller and route and index method for that --- app/assets/javascripts/quotes.coffee | 3 +++ app/assets/stylesheets/quotes.scss | 3 +++ app/controllers/quotes_controller.rb | 9 +++++++++ app/helpers/quotes_helper.rb | 2 ++ config/routes.rb | 3 +++ test/controllers/quotes_controller_test.rb | 7 +++++++ 6 files changed, 27 insertions(+) create mode 100644 app/assets/javascripts/quotes.coffee create mode 100644 app/assets/stylesheets/quotes.scss create mode 100644 app/controllers/quotes_controller.rb create mode 100644 app/helpers/quotes_helper.rb create mode 100644 test/controllers/quotes_controller_test.rb diff --git a/app/assets/javascripts/quotes.coffee b/app/assets/javascripts/quotes.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/quotes.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/quotes.scss b/app/assets/stylesheets/quotes.scss new file mode 100644 index 0000000..7cb1ab7 --- /dev/null +++ b/app/assets/stylesheets/quotes.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the quotes controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb new file mode 100644 index 0000000..c3b9715 --- /dev/null +++ b/app/controllers/quotes_controller.rb @@ -0,0 +1,9 @@ +class QuotesController < ApplicationController + + def index + @packages = [ + ActiveShipping::Package.new(params[:something][:height], [93,10], cylinder: true), + ActiveShipping::Package.new(7.5 * 16, [15, 10, 4.5], units: :imperial) + ] + end +end diff --git a/app/helpers/quotes_helper.rb b/app/helpers/quotes_helper.rb new file mode 100644 index 0000000..32b09df --- /dev/null +++ b/app/helpers/quotes_helper.rb @@ -0,0 +1,2 @@ +module QuotesHelper +end diff --git a/config/routes.rb b/config/routes.rb index 3f66539..cf25b87 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,7 @@ Rails.application.routes.draw do + + get '/quote' => 'quotes#index' + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/test/controllers/quotes_controller_test.rb b/test/controllers/quotes_controller_test.rb new file mode 100644 index 0000000..01c55fd --- /dev/null +++ b/test/controllers/quotes_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class QuotesControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end From 1b64f53148c700eb82339bd297b9322e5b81f1de Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 25 May 2016 09:12:35 -0700 Subject: [PATCH 15/35] tried to do some testing --- app/controllers/shipping_controller.rb | 11 ++++ app/models/shipping.rb | 23 +++++++++ config/routes.rb | 2 + test/cassettes/API/should_a_hash.yml | 50 +++++++++++++++++++ .../API/should_a_instance_of_Fedex.yml | 50 +++++++++++++++++++ test/cassettes/API/should_be_an_array_.yml | 50 +++++++++++++++++++ .../API/should_return_shipping_cost.yml | 50 +++++++++++++++++++ test/controllers/shipping_controller_test.rb | 17 +++++++ test/models/shipping_test.rb | 23 +++++++-- 9 files changed, 271 insertions(+), 5 deletions(-) create mode 100644 app/controllers/shipping_controller.rb create mode 100644 test/cassettes/API/should_a_hash.yml create mode 100644 test/cassettes/API/should_a_instance_of_Fedex.yml create mode 100644 test/cassettes/API/should_be_an_array_.yml create mode 100644 test/cassettes/API/should_return_shipping_cost.yml create mode 100644 test/controllers/shipping_controller_test.rb diff --git a/app/controllers/shipping_controller.rb b/app/controllers/shipping_controller.rb new file mode 100644 index 0000000..b64b997 --- /dev/null +++ b/app/controllers/shipping_controller.rb @@ -0,0 +1,11 @@ +class ShippingController < ApplicationController + + + + + def valid_json? + render json:[] + + end + +end diff --git a/app/models/shipping.rb b/app/models/shipping.rb index 7843be9..09d2478 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -1,2 +1,25 @@ class Shipping < ActiveRecord::Base + + def package_dimension(weight,length,shape) + package = ActiveShipping::Package.new(weight,length) + + end + + def origin_of_package(country,state,city,zip) + origin = ActiveShipping::Location.new(country: country, state: state, zip: zip) + + end + + def destination(country,state,city,zip) + destination = ActiveShipping::Location.new(country: country,province: state,city: city,postal_code: zip) + end + + + + def how_much_will_the_package_be_for_ups + ups = ActiveShipping::UPS.new(login: 'auntjudy', password: 'secret', key: 'xml-access-key') + response = ups.find_rates(origin, destination, packages) + end + + end diff --git a/config/routes.rb b/config/routes.rb index 3f66539..f96f8b2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Rails.application.routes.draw do + get "shipping/valid_json?" => "shipping#valid_json?" + # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/test/cassettes/API/should_a_hash.yml b/test/cassettes/API/should_a_hash.yml new file mode 100644 index 0000000..2c6b4dc --- /dev/null +++ b/test/cassettes/API/should_a_hash.yml @@ -0,0 +1,50 @@ +--- +http_interactions: +- request: + method: post + uri: https://gatewaybeta.fedex.com/xml + body: + encoding: UTF-8 + string: wTCb9AumfkXtr27Q RHz0ShHCr73OwFqQu5RC1CL7B 510087224 118727760 ActiveShipping crs 13 0 0 true SATURDAY_DELIVERY 2016-05-24T13:57:25-07:00 REGULAR_PICKUP YOUR_PACKAGING
Beverly + Hills 90210 US true
Ottawa K1P + 1J1 CA true
PARCEL_SELECT 5902 ACCOUNT 1 1 LB 0.22 37 4 4 IN
+ headers: + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 24 May 2016 20:57:26 GMT + Server: + - Apache + Set-Cookie: + - siteDC=edc; path=/; domain=.fedex.com; expires=Wed, 25-May-2016 20:57:26 GMT + X-Wily-Servlet: + - Encrypt1 GaMcoOotgOSMyoYj73M4dsxJg8pg+egXqWxT0tlCBMozxB2FJoHW86iPptGsWeEMNrrhgg+c1uCrVTL453EE8LUyyZJ0ssHZDmgz/H0Xk331Sy1KEH2kUmXY7Mq3Tf+CfqilOfvoO24JUs7Z6duDQzBDbr7hudkRV1vidonsMbUUBeIoWx/fKXVWWqtcEvhXJp/v93hA5q3ggWAPtS8Bww== + X-Powered-By: + - Servlet/2.5 JSP/2.1 + X-Wily-Info: + - Clear guid=E48ED41ECC87128A0DFC1C132786DA75 + Vary: + - Accept-Encoding + Transfer-Encoding: + - chunked + Content-Type: + - text/xml; charset=utf-8 + body: + encoding: ASCII-8BIT + string: |- + + NOTENOTEcrs886Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. NOTEcrs886Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. FDXGMoney Back Guarantee is not eligible for this pick up/delivery postal/zip code. FDXGOPERATING_COMPANYFDXGNOTEcrs819The origin state/province code has been changed. The origin state/province code has been changed. NOTEcrs820The destination state/province code has been changed. The destination state/province code has been changed. ActiveShippingcrs1300INTERNATIONAL_PRIORITYYOUR_PACKAGINGYOWA WED2016-05-25T12:00:00DOCUMENTSINTERNATIONAL_PRIORITY2016-05-25T12:00:00WEDAM0134REQUEST COMPLETEDBY NOON IF NO CUSTOMS DELAYDOCUMENTS_ONLYINTERNATIONAL_AIRWAY_BILLYOWfalseA1AMSERVICE_DEFAULTPAYOR_ACCOUNT_SHIPMENTPAYOR_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD110.52USD0.0USD110.52USD4.51USD115.03USD0.0USD115.03USD0.0USD0.0USD115.03RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.86RATED_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD110.52USD0.0USD110.52USD4.51USD115.03USD0.0USD115.03USD0.0USD0.0USD115.03RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.86INTERNATIONAL_ECONOMYYOUR_PACKAGINGYOWA THU2016-05-26T20:00:00DOCUMENTSINTERNATIONAL_ECONOMY2016-05-26T20:00:00THUAM0134REQUEST COMPLETED 8:00 P.M. IF NO CUSTOMS DELAYDOCUMENTS_ONLYINTERNATIONAL_AIRWAY_BILLYOWfalseA1AMSERVICE_DEFAULTPAYOR_ACCOUNT_SHIPMENTPAYOR_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD97.57USD0.0USD97.57USD4.41USD101.98USD0.0USD101.98USD0.0USD0.0USD101.98RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.76RATED_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD97.57USD0.0USD97.57USD4.41USD101.98USD0.0USD101.98USD0.0USD0.0USD101.98RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.76FEDEX_GROUNDYOUR_PACKAGINGFEDEX_GROUNDFIVE_DAYS0YOWtrueFIVE_DAYSSERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE51DIM1393.75LB5.0LB5.0USD23.14USD0.0USD23.14USD4.66USD27.8USD0.0USD27.8USD0.0USD0.0USD27.8RESIDENTIAL_DELIVERYPACKAGEResidential deliveryUSD3.65FUELPACKAGEFedEx Ground FuelUSD1.010PAYOR_ACCOUNT_PACKAGEDIMLB5.0LB5.0USD23.14USD0.0USD23.14USD4.66USD27.8USD0.0USD27.8USD0.0RESIDENTIAL_DELIVERYPACKAGEResidential deliveryUSD3.65FUELPACKAGEFedEx Ground FuelUSD1.01 + http_version: + recorded_at: Tue, 24 May 2016 20:57:27 GMT +recorded_with: VCR 3.0.3 diff --git a/test/cassettes/API/should_a_instance_of_Fedex.yml b/test/cassettes/API/should_a_instance_of_Fedex.yml new file mode 100644 index 0000000..cd07e93 --- /dev/null +++ b/test/cassettes/API/should_a_instance_of_Fedex.yml @@ -0,0 +1,50 @@ +--- +http_interactions: +- request: + method: post + uri: https://gatewaybeta.fedex.com/xml + body: + encoding: UTF-8 + string: wTCb9AumfkXtr27Q RHz0ShHCr73OwFqQu5RC1CL7B 510087224 118727760 ActiveShipping crs 13 0 0 true SATURDAY_DELIVERY 2016-05-24T14:00:00-07:00 REGULAR_PICKUP YOUR_PACKAGING
Beverly + Hills 90210 US true
Ottawa K1P + 1J1 CA true
PARCEL_SELECT 5902 ACCOUNT 1 1 LB 0.22 37 4 4 IN
+ headers: + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 24 May 2016 21:00:03 GMT + Server: + - Apache + Set-Cookie: + - siteDC=edc; path=/; domain=.fedex.com; expires=Wed, 25-May-2016 21:00:03 GMT + X-Wily-Servlet: + - Encrypt1 GaMcoOotgOSMyoYj73M4dsxJg8pg+egXqWxT0tlCBMozxB2FJoHW86iPptGsWeEMNrrhgg+c1uCrVTL453EE8LUyyZJ0ssHZDmgz/H0Xk331Sy1KEH2kUmXY7Mq3Tf+CfqilOfvoO24JUs7Z6duDQzBDbr7hudkRV1vidonsMbUUBeIoWx/fKXVWWqtcEvhXJp/v93hA5q3ggWAPtS8Bww== + X-Powered-By: + - Servlet/2.5 JSP/2.1 + X-Wily-Info: + - Clear guid=E49139A8CC87128A0DFC1C13824D793E + Vary: + - Accept-Encoding + Transfer-Encoding: + - chunked + Content-Type: + - text/xml; charset=utf-8 + body: + encoding: ASCII-8BIT + string: |- + + WARNINGWARNINGcrs608Commit Info could not be obtained for one or more services: INTERNATIONAL_PRIORITY; INTERNATIONAL_PRIORITY_DISTRIBUTION; INTERNATIONAL_ECONOMY; ; ; ; ; ; ; ; .Commit Info could not be obtained for one or more services: INTERNATIONAL_PRIORITY; INTERNATIONAL_PRIORITY_DISTRIBUTION; INTERNATIONAL_ECONOMY; ; ; ; ; ; ; ; .SERVICE_TYPE_1INTERNATIONAL_PRIORITYSERVICE_TYPE_2INTERNATIONAL_PRIORITY_DISTRIBUTIONSERVICE_TYPE_3INTERNATIONAL_ECONOMYNOTEcrs886Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. NOTEcrs886Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. FDXGMoney Back Guarantee is not eligible for this pick up/delivery postal/zip code. FDXGOPERATING_COMPANYFDXGNOTEcrs819The origin state/province code has been changed. The origin state/province code has been changed. NOTEcrs820The destination state/province code has been changed. The destination state/province code has been changed. ActiveShippingcrs1300INTERNATIONAL_PRIORITYYOUR_PACKAGINGYOWA DOCUMENTSINTERNATIONAL_PRIORITY0NON_DOCUMENTSYOWfalseA1AMSERVICE_DEFAULTPAYOR_ACCOUNT_SHIPMENTPAYOR_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD110.52USD0.0USD110.52USD4.51USD115.03USD0.0USD115.03USD0.0USD0.0USD115.03RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.86RATED_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD110.52USD0.0USD110.52USD4.51USD115.03USD0.0USD115.03USD0.0USD0.0USD115.03RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.86INTERNATIONAL_ECONOMYYOUR_PACKAGINGYOWA DOCUMENTSINTERNATIONAL_ECONOMY0NON_DOCUMENTSYOWfalseA1AMSERVICE_DEFAULTPAYOR_ACCOUNT_SHIPMENTPAYOR_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD97.57USD0.0USD97.57USD4.41USD101.98USD0.0USD101.98USD0.0USD0.0USD101.98RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.76RATED_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD97.57USD0.0USD97.57USD4.41USD101.98USD0.0USD101.98USD0.0USD0.0USD101.98RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.76FEDEX_GROUNDYOUR_PACKAGINGFEDEX_GROUNDFIVE_DAYS0YOWtrueFIVE_DAYSSERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE51DIM1393.75LB5.0LB5.0USD23.14USD0.0USD23.14USD4.66USD27.8USD0.0USD27.8USD0.0USD0.0USD27.8RESIDENTIAL_DELIVERYPACKAGEResidential deliveryUSD3.65FUELPACKAGEFedEx Ground FuelUSD1.010PAYOR_ACCOUNT_PACKAGEDIMLB5.0LB5.0USD23.14USD0.0USD23.14USD4.66USD27.8USD0.0USD27.8USD0.0RESIDENTIAL_DELIVERYPACKAGEResidential deliveryUSD3.65FUELPACKAGEFedEx Ground FuelUSD1.01 + http_version: + recorded_at: Tue, 24 May 2016 21:00:08 GMT +recorded_with: VCR 3.0.3 diff --git a/test/cassettes/API/should_be_an_array_.yml b/test/cassettes/API/should_be_an_array_.yml new file mode 100644 index 0000000..e32914c --- /dev/null +++ b/test/cassettes/API/should_be_an_array_.yml @@ -0,0 +1,50 @@ +--- +http_interactions: +- request: + method: post + uri: https://gatewaybeta.fedex.com/xml + body: + encoding: UTF-8 + string: wTCb9AumfkXtr27Q RHz0ShHCr73OwFqQu5RC1CL7B 510087224 118727760 ActiveShipping crs 13 0 0 true SATURDAY_DELIVERY 2016-05-24T14:16:36-07:00 REGULAR_PICKUP YOUR_PACKAGING
Beverly + Hills 90210 US true
Ottawa K1P + 1J1 CA true
PARCEL_SELECT 5902 ACCOUNT 1 1 LB 0.22 37 4 4 IN
+ headers: + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 24 May 2016 21:16:38 GMT + Server: + - Apache + Set-Cookie: + - siteDC=edc; path=/; domain=.fedex.com; expires=Wed, 25-May-2016 21:16:38 GMT + X-Wily-Servlet: + - Encrypt1 GaMcoOotgOSMyoYj73M4djxB/BFdu6Bd7dK9l2vKcsLoBxuCEbM12kwUffT0WqzWwhNfXxOuv1xkOK5NUzCbP46u7vtBQL8InqrXYgHsCoR6RU11Zne5eRfVnPz2s4QoPe1Z+CQvAGl4TWII9O/OWvtMAQtNaTfpLWdypqTSez/SymL6XCE0GqpKUl0sOsjLPy4hAFwgDB7dB2VpBiXONg== + X-Powered-By: + - Servlet/2.5 JSP/2.1 + X-Wily-Info: + - Clear guid=E4A06744CC87128E0F000C2D8BAC6158 + Vary: + - Accept-Encoding + Transfer-Encoding: + - chunked + Content-Type: + - text/xml; charset=utf-8 + body: + encoding: ASCII-8BIT + string: |- + + NOTENOTEcrs886Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. NOTEcrs886Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. FDXGMoney Back Guarantee is not eligible for this pick up/delivery postal/zip code. FDXGOPERATING_COMPANYFDXGNOTEcrs819The origin state/province code has been changed. The origin state/province code has been changed. NOTEcrs820The destination state/province code has been changed. The destination state/province code has been changed. ActiveShippingcrs1300INTERNATIONAL_PRIORITYYOUR_PACKAGINGYOWA WED2016-05-25T12:00:00DOCUMENTSINTERNATIONAL_PRIORITY2016-05-25T12:00:00WEDAM0134REQUEST COMPLETEDBY NOON IF NO CUSTOMS DELAYDOCUMENTS_ONLYINTERNATIONAL_AIRWAY_BILLYOWfalseA1AMSERVICE_DEFAULTPAYOR_ACCOUNT_SHIPMENTPAYOR_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD110.52USD0.0USD110.52USD4.51USD115.03USD0.0USD115.03USD0.0USD0.0USD115.03RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.86RATED_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD110.52USD0.0USD110.52USD4.51USD115.03USD0.0USD115.03USD0.0USD0.0USD115.03RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.86INTERNATIONAL_ECONOMYYOUR_PACKAGINGYOWA THU2016-05-26T20:00:00DOCUMENTSINTERNATIONAL_ECONOMY2016-05-26T20:00:00THUAM0134REQUEST COMPLETED 8:00 P.M. IF NO CUSTOMS DELAYDOCUMENTS_ONLYINTERNATIONAL_AIRWAY_BILLYOWfalseA1AMSERVICE_DEFAULTPAYOR_ACCOUNT_SHIPMENTPAYOR_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD97.57USD0.0USD97.57USD4.41USD101.98USD0.0USD101.98USD0.0USD0.0USD101.98RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.76RATED_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD97.57USD0.0USD97.57USD4.41USD101.98USD0.0USD101.98USD0.0USD0.0USD101.98RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.76FEDEX_GROUNDYOUR_PACKAGINGFEDEX_GROUNDFIVE_DAYS0YOWtrueFIVE_DAYSSERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE51DIM1393.75LB5.0LB5.0USD23.14USD0.0USD23.14USD4.66USD27.8USD0.0USD27.8USD0.0USD0.0USD27.8RESIDENTIAL_DELIVERYPACKAGEResidential deliveryUSD3.65FUELPACKAGEFedEx Ground FuelUSD1.010PAYOR_ACCOUNT_PACKAGEDIMLB5.0LB5.0USD23.14USD0.0USD23.14USD4.66USD27.8USD0.0USD27.8USD0.0RESIDENTIAL_DELIVERYPACKAGEResidential deliveryUSD3.65FUELPACKAGEFedEx Ground FuelUSD1.01 + http_version: + recorded_at: Tue, 24 May 2016 21:16:40 GMT +recorded_with: VCR 3.0.3 diff --git a/test/cassettes/API/should_return_shipping_cost.yml b/test/cassettes/API/should_return_shipping_cost.yml new file mode 100644 index 0000000..7c260a0 --- /dev/null +++ b/test/cassettes/API/should_return_shipping_cost.yml @@ -0,0 +1,50 @@ +--- +http_interactions: +- request: + method: post + uri: https://gatewaybeta.fedex.com/xml + body: + encoding: UTF-8 + string: wTCb9AumfkXtr27Q RHz0ShHCr73OwFqQu5RC1CL7B 510087224 118727760 ActiveShipping crs 13 0 0 true SATURDAY_DELIVERY 2016-05-24T13:53:52-07:00 REGULAR_PICKUP YOUR_PACKAGING
Beverly + Hills 90210 US true
Ottawa K1P + 1J1 CA true
PARCEL_SELECT 5902 ACCOUNT 1 1 LB 0.22 37 4 4 IN
+ headers: + Content-Type: + - application/x-www-form-urlencoded + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Tue, 24 May 2016 20:53:53 GMT + Server: + - Apache + Set-Cookie: + - siteDC=edc; path=/; domain=.fedex.com; expires=Wed, 25-May-2016 20:53:53 GMT + X-Wily-Servlet: + - Encrypt1 GaMcoOotgOSMyoYj73M4dsxJg8pg+egXqWxT0tlCBMozxB2FJoHW86iPptGsWeEMNrrhgg+c1uCrVTL453EE8LUyyZJ0ssHZDmgz/H0Xk331Sy1KEH2kUmXY7Mq3Tf+CjBsQwc8biS6WK8Iv0oquIj3fWF0QsEyP9ohPv91fym0DJiovsPngNJ1eFSsHTeOh3adKeCgL/LxW5tD8oEmLqQ== + X-Powered-By: + - Servlet/2.5 JSP/2.1 + X-Wily-Info: + - Clear guid=E48B9626CC87128A0DFC1C13FFE4FE42 + Vary: + - Accept-Encoding + Transfer-Encoding: + - chunked + Content-Type: + - text/xml; charset=utf-8 + body: + encoding: ASCII-8BIT + string: |- + + NOTENOTEcrs886Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. NOTEcrs886Money Back Guarantee is not eligible for this pick up/delivery postal/zip code. FDXGMoney Back Guarantee is not eligible for this pick up/delivery postal/zip code. FDXGOPERATING_COMPANYFDXGNOTEcrs819The origin state/province code has been changed. The origin state/province code has been changed. NOTEcrs820The destination state/province code has been changed. The destination state/province code has been changed. ActiveShippingcrs1300INTERNATIONAL_PRIORITYYOUR_PACKAGINGYOWA WED2016-05-25T12:00:00DOCUMENTSINTERNATIONAL_PRIORITY2016-05-25T12:00:00WEDAM0134REQUEST COMPLETEDBY NOON IF NO CUSTOMS DELAYDOCUMENTS_ONLYINTERNATIONAL_AIRWAY_BILLYOWfalseA1AMSERVICE_DEFAULTPAYOR_ACCOUNT_SHIPMENTPAYOR_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD110.52USD0.0USD110.52USD4.51USD115.03USD0.0USD115.03USD0.0USD0.0USD115.03RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.86RATED_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD110.52USD0.0USD110.52USD4.51USD115.03USD0.0USD115.03USD0.0USD0.0USD115.03RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.86INTERNATIONAL_ECONOMYYOUR_PACKAGINGYOWA THU2016-05-26T20:00:00DOCUMENTSINTERNATIONAL_ECONOMY2016-05-26T20:00:00THUAM0134REQUEST COMPLETED 8:00 P.M. IF NO CUSTOMS DELAYDOCUMENTS_ONLYINTERNATIONAL_AIRWAY_BILLYOWfalseA1AMSERVICE_DEFAULTPAYOR_ACCOUNT_SHIPMENTPAYOR_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD97.57USD0.0USD97.57USD4.41USD101.98USD0.0USD101.98USD0.0USD0.0USD101.98RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.76RATED_ACCOUNT_SHIPMENT0000000US001OACTUALDIMUSDUSD1.0139COUNTRY0.75LB5.0LB5.0USD97.57USD0.0USD97.57USD4.41USD101.98USD0.0USD101.98USD0.0USD0.0USD101.98RESIDENTIAL_DELIVERYResidential deliveryUSD3.65FUELFuelUSD0.76FEDEX_GROUNDYOUR_PACKAGINGFEDEX_GROUNDFIVE_DAYS0YOWtrueFIVE_DAYSSERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE51DIM1393.75LB5.0LB5.0USD23.14USD0.0USD23.14USD4.66USD27.8USD0.0USD27.8USD0.0USD0.0USD27.8RESIDENTIAL_DELIVERYPACKAGEResidential deliveryUSD3.65FUELPACKAGEFedEx Ground FuelUSD1.010PAYOR_ACCOUNT_PACKAGEDIMLB5.0LB5.0USD23.14USD0.0USD23.14USD4.66USD27.8USD0.0USD27.8USD0.0RESIDENTIAL_DELIVERYPACKAGEResidential deliveryUSD3.65FUELPACKAGEFedEx Ground FuelUSD1.01 + http_version: + recorded_at: Tue, 24 May 2016 20:53:55 GMT +recorded_with: VCR 3.0.3 diff --git a/test/controllers/shipping_controller_test.rb b/test/controllers/shipping_controller_test.rb new file mode 100644 index 0000000..a97271e --- /dev/null +++ b/test/controllers/shipping_controller_test.rb @@ -0,0 +1,17 @@ +require 'test_helper' +module ShippingControllerTest + + + class WhatAreWeDoing < ActionController::TestCase + + test "it accepts valid json" do + + get :valid_json? + assert valid_json?, true + + end + + + + end +end diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb index 3b55e27..9965190 100644 --- a/test/models/shipping_test.rb +++ b/test/models/shipping_test.rb @@ -6,15 +6,28 @@ class ShippingTest < ActiveSupport::TestCase # setup do # # end + before do + @packages = ActiveShipping::Package.new(100, [93,10],cylinder: true) + @origin = ActiveShipping::Location.new(country: 'US',state: 'CA', city: 'Beverly Hills', zip: '90210') + @destination = ActiveShipping::Location.new(country: 'CA',province: 'ON',city: 'Ottawa',postal_code: 'K1P 1J1') + + @fedex = ActiveShipping::FedEx.new(login: ENV['FEDEX_METER_NUMBER'], + password: ENV['FEDEX_TEST_PASSWORD'], key: ENV['FEDEX_TEST_KEY'], account: ENV['FEDEX_ACCOUNT_NUMBER'],test: true) + + end + + it "return an instance of Fedex", :vcr do + assert @fedex.is_a? ActiveShipping::FedEx - it "shuld return an instance of Fedex", :vcr do - fedex = ActiveShipping::FedEx.new(login: ENV['FEDEX_METER_NUMBER'], - password: ENV['FEDEX_TEST_PASSWORD'], key: ENV['FEDEX_TEST_KEY'], account: ENV['FEDEX_ACCOUNT_NUMBER']) - assert fedex.is_a? ActiveShipping::FedEx end + it "should be an array ", :vcr do + response = @fedex.find_rates(@origin, @destination, @packages) + price = response.rates.sort_by(&:price).collect {|rate| [rate.service_name, rate.price]} + price.is_a? Array + - it "" + end end end From a8761f72378af3a458c00475b1a863cdda48f416 Mon Sep 17 00:00:00 2001 From: Valerie Date: Wed, 25 May 2016 14:42:24 -0700 Subject: [PATCH 16/35] Started index method for quotes controller --- app/controllers/quotes_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index c3b9715..f9d5f9f 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -1,6 +1,9 @@ class QuotesController < ApplicationController def index + JSON.parse + + @packages = [ ActiveShipping::Package.new(params[:something][:height], [93,10], cylinder: true), ActiveShipping::Package.new(7.5 * 16, [15, 10, 4.5], units: :imperial) From 49e7c8ee0165bb0462c806aefbe9cf7c0447b2fe Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 25 May 2016 15:08:33 -0700 Subject: [PATCH 17/35] set up package origin and destination --- app/controllers/quotes_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index f9d5f9f..574efb7 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -4,9 +4,11 @@ def index JSON.parse - @packages = [ - ActiveShipping::Package.new(params[:something][:height], [93,10], cylinder: true), - ActiveShipping::Package.new(7.5 * 16, [15, 10, 4.5], units: :imperial) - ] + @package = ActiveShipping::Package.new(params[:product][:weight],[params[:product][:width], params[:product][:height]]) + + @origin = ActiveShipping::Location.new(params[:origin][:street_address],params[:origin][:city],params[:origin][:state],params[:origin][:zip]) + + @destination = ActiveShipping::Location.new(params[:destination][:street_address],params[:destination][:city],params[:destination][:state],params[:destination][:zip]) + end end From 5049b0090fd87a303be6d20eeabfa73ba3615a3d Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 25 May 2016 15:39:45 -0700 Subject: [PATCH 18/35] working on quotes controller --- app/controllers/quotes_controller.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index 574efb7..bad5f0b 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -1,14 +1,13 @@ class QuotesController < ApplicationController def index - JSON.parse - @package = ActiveShipping::Package.new(params[:product][:weight],[params[:product][:width], params[:product][:height]]) @origin = ActiveShipping::Location.new(params[:origin][:street_address],params[:origin][:city],params[:origin][:state],params[:origin][:zip]) @destination = ActiveShipping::Location.new(params[:destination][:street_address],params[:destination][:city],params[:destination][:state],params[:destination][:zip]) - end +#data base code + end From 1c6922da15e1b6780128d41a69aae9aced33e464 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 25 May 2016 15:44:09 -0700 Subject: [PATCH 19/35] changed file --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 422bdfe..9e0d8a8 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby +gem 'dotenv-rails' # Use jquery as the JavaScript library gem 'jquery-rails' @@ -47,7 +48,6 @@ group :development, :test do gem 'minitest-vcr' gem 'minitest-reporters' gem 'webmock' - gem 'dotenv-rails' end group :development do From db0676ed7e75a328c19bb3907dea8dbb94fa68c8 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 25 May 2016 18:33:45 -0700 Subject: [PATCH 20/35] used null session for csrf protection --- app/controllers/application_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e..1e3747a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception + protect_from_forgery with: :null_session + end From 1ea461710e2752e55eb76456d8273f823aaeb12c Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 25 May 2016 18:39:05 -0700 Subject: [PATCH 21/35] updated quote model --- app/models/shipping.rb | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/app/models/shipping.rb b/app/models/shipping.rb index 09d2478..e2c7ca8 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -1,25 +1,28 @@ class Shipping < ActiveRecord::Base - def package_dimension(weight,length,shape) - package = ActiveShipping::Package.new(weight,length) + def initialize(package,origin,destination) + @package = package + @origin = origin + @destination = destination + @usps = ActiveShipping::USPS.new(login: ENV["USPS_LOGIN_KEY"]) + @fedex = ActiveShipping::FedEx.new(login: ENV['FEDEX_METER_NUMBER'], + password: ENV['FEDEX_TEST_PASSWORD'], key: ENV['FEDEX_TEST_KEY'], account: ENV['FEDEX_ACCOUNT_NUMBER'], test: true) end - def origin_of_package(country,state,city,zip) - origin = ActiveShipping::Location.new(country: country, state: state, zip: zip) - - end - - def destination(country,state,city,zip) - destination = ActiveShipping::Location.new(country: country,province: state,city: city,postal_code: zip) + def self.create_by_params(params) + package = ActiveShipping::Package.new(params[:product][:weight],[params[:product][:width], params[:product][:height]]) + origin = ActiveShipping::Location.new( params[:origin].merge(:country => "US")) + destination = ActiveShipping::Location.new(params[:destination].merge(:country => "US")) + Shipping.new(package,origin,destination) end - - def how_much_will_the_package_be_for_ups - ups = ActiveShipping::UPS.new(login: 'auntjudy', password: 'secret', key: 'xml-access-key') - response = ups.find_rates(origin, destination, packages) + def find_rates + [@usps,@fedex].map do |carrier| + carrier.find_rates(@origin,@destination,@package).rates.sort_by(&:price).map do |rate| + {service_name: rate.service_name, price: rate.price} + end + end.flatten end - - end From f85a5923de70d7ac4bce0954a897b02a134b853f Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 25 May 2016 18:42:25 -0700 Subject: [PATCH 22/35] quote controller uses quote model --- app/controllers/quotes_controller.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index bad5f0b..88ff3d9 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -1,13 +1,8 @@ class QuotesController < ApplicationController def index - - @package = ActiveShipping::Package.new(params[:product][:weight],[params[:product][:width], params[:product][:height]]) - - @origin = ActiveShipping::Location.new(params[:origin][:street_address],params[:origin][:city],params[:origin][:state],params[:origin][:zip]) - - @destination = ActiveShipping::Location.new(params[:destination][:street_address],params[:destination][:city],params[:destination][:state],params[:destination][:zip]) + rate_quote = Shipping.create_by_params(params) + rates = rate_quote.find_rates + render json: rates.to_json end -#data base code - end From d4c74274257213b8589cca82f214c0db7d1ca745 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 25 May 2016 18:43:42 -0700 Subject: [PATCH 23/35] changed get to post for quote route --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index d62076a..060bdf3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,7 +1,7 @@ Rails.application.routes.draw do - get '/quote' => 'quotes#index' + post '/quote' => 'quotes#index' # The priority is based upon order of creation: first created -> highest priority. From 1ab44e3382a2705d058f7a7c1d33f9a7db9d4116 Mon Sep 17 00:00:00 2001 From: Valerie Date: Thu, 26 May 2016 09:29:40 -0700 Subject: [PATCH 24/35] Started setup for log table in database --- app/models/log.rb | 7 +++++++ db/migrate/20160525221831_create_logs.rb | 9 +++++++++ db/schema.rb | 9 ++++++++- test/fixtures/logs.yml | 11 +++++++++++ test/models/log_test.rb | 7 +++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 app/models/log.rb create mode 100644 db/migrate/20160525221831_create_logs.rb create mode 100644 test/fixtures/logs.yml create mode 100644 test/models/log_test.rb diff --git a/app/models/log.rb b/app/models/log.rb new file mode 100644 index 0000000..205ef53 --- /dev/null +++ b/app/models/log.rb @@ -0,0 +1,7 @@ +class Log < ActiveRecord::Base + + #should log, in a database, all requests for shipping information (from betsy, in our case) and all composed responses. + # This can be a single database table that stores the request json from betsy and the response json sent back to betsy, one row per request. + + +end diff --git a/db/migrate/20160525221831_create_logs.rb b/db/migrate/20160525221831_create_logs.rb new file mode 100644 index 0000000..96e90c4 --- /dev/null +++ b/db/migrate/20160525221831_create_logs.rb @@ -0,0 +1,9 @@ +class CreateLogs < ActiveRecord::Migration + def change + create_table :logs do |t| + t.string :request_from_betsy + t.string :response_to_betsy + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 13a2206..5001f4c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,18 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160523233048) do +ActiveRecord::Schema.define(version: 20160525221831) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "logs", force: :cascade do |t| + t.string "request_from_betsy" + t.string "response_to_betsy" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "shippings", force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false diff --git a/test/fixtures/logs.yml b/test/fixtures/logs.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/logs.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/log_test.rb b/test/models/log_test.rb new file mode 100644 index 0000000..f2afee2 --- /dev/null +++ b/test/models/log_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class LogTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 5c1fe11013c58b401a06e9b27575c8da45663de2 Mon Sep 17 00:00:00 2001 From: Valerie Date: Thu, 26 May 2016 11:06:41 -0700 Subject: [PATCH 25/35] Working on getting shipping quote showing --- app/models/shipping.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/models/shipping.rb b/app/models/shipping.rb index e2c7ca8..63be872 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -11,15 +11,23 @@ def initialize(package,origin,destination) end def self.create_by_params(params) - package = ActiveShipping::Package.new(params[:product][:weight],[params[:product][:width], params[:product][:height]]) - origin = ActiveShipping::Location.new( params[:origin].merge(:country => "US")) - destination = ActiveShipping::Location.new(params[:destination].merge(:country => "US")) + + package_info = params.keys[0] # this is a string + params = JSON.parse(package_info) + params["origin"]["zip"] = params["origin"]["zip"].to_i + # binding.pry + params["destination"]["zip"] = params["destination"]["zip"].to_i + package = ActiveShipping::Package.new(params["product"]["weight"],[params["product"]["width"], params["product"]["height"]]) + + origin = ActiveShipping::Location.new( params["origin"].merge("country" => "US")) + destination = ActiveShipping::Location.new(params["destination"].merge("country" => "US")) Shipping.new(package,origin,destination) end def find_rates [@usps,@fedex].map do |carrier| + binding.pry carrier.find_rates(@origin,@destination,@package).rates.sort_by(&:price).map do |rate| {service_name: rate.service_name, price: rate.price} end From 5d9b70313f442f27d4aa8e46910e7f48de13e164 Mon Sep 17 00:00:00 2001 From: Valerie Date: Thu, 26 May 2016 11:39:42 -0700 Subject: [PATCH 26/35] working on in controller --- app/controllers/quotes_controller.rb | 1 + app/models/shipping.rb | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index 88ff3d9..fdc2a2e 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -1,6 +1,7 @@ class QuotesController < ApplicationController def index + binding.pry rate_quote = Shipping.create_by_params(params) rates = rate_quote.find_rates render json: rates.to_json diff --git a/app/models/shipping.rb b/app/models/shipping.rb index 63be872..8ebecd5 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -19,15 +19,26 @@ def self.create_by_params(params) params["destination"]["zip"] = params["destination"]["zip"].to_i package = ActiveShipping::Package.new(params["product"]["weight"],[params["product"]["width"], params["product"]["height"]]) - origin = ActiveShipping::Location.new( params["origin"].merge("country" => "US")) - destination = ActiveShipping::Location.new(params["destination"].merge("country" => "US")) + # origin = ActiveShipping::Location.new( params["origin"].merge("country" => "US")) + origin = ActiveShipping::Location.new( + country: "US", + state: params["origin"]["state"], + city: params["origin"]["city"], + zip: params["origin"]["zip"] + ) + destination = ActiveShipping::Location.new(params["destination"].merge("country" => "US") + country: "US", + state: ["origin"]["state"], + city: params["origin"]["city"], + zip: params["origin"]["zip"] + ) Shipping.new(package,origin,destination) end def find_rates [@usps,@fedex].map do |carrier| - binding.pry + # binding.pry carrier.find_rates(@origin,@destination,@package).rates.sort_by(&:price).map do |rate| {service_name: rate.service_name, price: rate.price} end From c03343190a59283ae86afc58e0ab4ce805f8d430 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 26 May 2016 13:43:28 -0700 Subject: [PATCH 27/35] fixed keys for active shipping params --- app/controllers/quotes_controller.rb | 1 - app/models/shipping.rb | 4 ++-- test/models/shipping_test.rb | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index fdc2a2e..88ff3d9 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -1,7 +1,6 @@ class QuotesController < ApplicationController def index - binding.pry rate_quote = Shipping.create_by_params(params) rates = rate_quote.find_rates render json: rates.to_json diff --git a/app/models/shipping.rb b/app/models/shipping.rb index 8ebecd5..f02cc20 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -26,9 +26,9 @@ def self.create_by_params(params) city: params["origin"]["city"], zip: params["origin"]["zip"] ) - destination = ActiveShipping::Location.new(params["destination"].merge("country" => "US") + destination = ActiveShipping::Location.new( country: "US", - state: ["origin"]["state"], + state: params["origin"]["state"], city: params["origin"]["city"], zip: params["origin"]["zip"] ) diff --git a/test/models/shipping_test.rb b/test/models/shipping_test.rb index e7d59bb..e2dd3f7 100644 --- a/test/models/shipping_test.rb +++ b/test/models/shipping_test.rb @@ -36,7 +36,6 @@ class ShippingTest < ActiveSupport::TestCase it "should return an array when finding USPS rates", :vcr do response = @usps.find_rates(@origin, @destination, @packages) usps_rates = response.rates.sort_by(&:price).collect {|rate| [rate.service_name, rate.price]} - binding.pry assert usps_rates.is_a? Array end From 1051d36316c0da1d673bcf984e9c64de7b4ad0a1 Mon Sep 17 00:00:00 2001 From: Valerie Date: Thu, 26 May 2016 16:03:36 -0700 Subject: [PATCH 28/35] Got log addition process working --- app/controllers/quotes_controller.rb | 18 ++++++++++++++++++ app/models/log.rb | 7 +++++++ app/models/shipping.rb | 22 ++++++++++++++-------- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index 88ff3d9..5803775 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -1,8 +1,26 @@ class QuotesController < ApplicationController def index + # adds the request to the log?? + # HTTParty.post(log_path, body: params.to_json) + + + rate_quote = Shipping.create_by_params(params) rates = rate_quote.find_rates + + ## why does the existence of this line make the render json not work below? + Log.create_from_request_and_response(params, rates) + + # log_entry = Log.new(params, rates) + # binding.pry + # if log_entry.save + # puts "YAY you added to the log" + # else + # puts "NO it didn't save" + # end + # adds this response to the log?? + # HTTParty.post(log_path, body: rates.to_json) render json: rates.to_json end end diff --git a/app/models/log.rb b/app/models/log.rb index 205ef53..99fcec9 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -3,5 +3,12 @@ class Log < ActiveRecord::Base #should log, in a database, all requests for shipping information (from betsy, in our case) and all composed responses. # This can be a single database table that stores the request json from betsy and the response json sent back to betsy, one row per request. + def self.create_from_request_and_response(request, response) + # getting just the JSON we want... this could totally be refactored with the similar thing going on in shipping.rb, but we'll get there if we have time! + request = request[:request] + response = response.to_json + log_entry = Log.create(request_from_betsy: request, response_to_betsy: response) + end + end diff --git a/app/models/shipping.rb b/app/models/shipping.rb index f02cc20..c358c93 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -1,8 +1,8 @@ -class Shipping < ActiveRecord::Base +class Shipping - def initialize(package,origin,destination) - @package = package + def initialize(packages,origin,destination) + @packages = packages @origin = origin @destination = destination @usps = ActiveShipping::USPS.new(login: ENV["USPS_LOGIN_KEY"]) @@ -12,12 +12,18 @@ def initialize(package,origin,destination) def self.create_by_params(params) - package_info = params.keys[0] # this is a string + + # getting the actual JSON we want from that big ugly params hash + package_info = params[:request] # this is a string params = JSON.parse(package_info) + + # change zip code to integer because of numeric data error... is this actually needed? params["origin"]["zip"] = params["origin"]["zip"].to_i - # binding.pry params["destination"]["zip"] = params["destination"]["zip"].to_i - package = ActiveShipping::Package.new(params["product"]["weight"],[params["product"]["width"], params["product"]["height"]]) + + packages = params["products"].map do |product| + ActiveShipping::Package.new(product["weight"], [product["width"], product["height"]]) + end # origin = ActiveShipping::Location.new( params["origin"].merge("country" => "US")) origin = ActiveShipping::Location.new( @@ -32,14 +38,14 @@ def self.create_by_params(params) city: params["origin"]["city"], zip: params["origin"]["zip"] ) - Shipping.new(package,origin,destination) + Shipping.new(packages,origin,destination) end def find_rates [@usps,@fedex].map do |carrier| # binding.pry - carrier.find_rates(@origin,@destination,@package).rates.sort_by(&:price).map do |rate| + carrier.find_rates(@origin,@destination,@packages).rates.sort_by(&:price).map do |rate| {service_name: rate.service_name, price: rate.price} end end.flatten From c0dead90a910726d7a1c75dd53fbf4488bfbbbd6 Mon Sep 17 00:00:00 2001 From: Valerie Date: Thu, 26 May 2016 17:32:39 -0700 Subject: [PATCH 29/35] find_rates now keeps track of delivery date too --- app/controllers/quotes_controller.rb | 2 -- app/models/shipping.rb | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index 5803775..3f505bc 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -4,8 +4,6 @@ def index # adds the request to the log?? # HTTParty.post(log_path, body: params.to_json) - - rate_quote = Shipping.create_by_params(params) rates = rate_quote.find_rates diff --git a/app/models/shipping.rb b/app/models/shipping.rb index c358c93..fc6f4fe 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -12,7 +12,7 @@ def initialize(packages,origin,destination) def self.create_by_params(params) - + # getting the actual JSON we want from that big ugly params hash package_info = params[:request] # this is a string params = JSON.parse(package_info) @@ -44,9 +44,8 @@ def self.create_by_params(params) def find_rates [@usps,@fedex].map do |carrier| - # binding.pry carrier.find_rates(@origin,@destination,@packages).rates.sort_by(&:price).map do |rate| - {service_name: rate.service_name, price: rate.price} + {service_name: rate.service_name, price: rate.price, delivery_date: rate.delivery_date} # rate.delivery_date should go here I think end end.flatten end From 580532a1d98211ae42bfa34b0ade7a3ba2cade74 Mon Sep 17 00:00:00 2001 From: Valerie Date: Thu, 26 May 2016 18:28:55 -0700 Subject: [PATCH 30/35] Realized that destination was taking from origin instead of destination oops, fixed that --- app/controllers/quotes_controller.rb | 1 - app/models/shipping.rb | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index 3f505bc..9f9b15e 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -7,7 +7,6 @@ def index rate_quote = Shipping.create_by_params(params) rates = rate_quote.find_rates - ## why does the existence of this line make the render json not work below? Log.create_from_request_and_response(params, rates) # log_entry = Log.new(params, rates) diff --git a/app/models/shipping.rb b/app/models/shipping.rb index fc6f4fe..affe0ec 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -34,9 +34,9 @@ def self.create_by_params(params) ) destination = ActiveShipping::Location.new( country: "US", - state: params["origin"]["state"], - city: params["origin"]["city"], - zip: params["origin"]["zip"] + state: params["destination"]["state"], + city: params["destination"]["city"], + zip: params["destination"]["zip"] ) Shipping.new(packages,origin,destination) end From 5f7440993a7cc83f36ef3b41321fa16432490546 Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 27 May 2016 09:55:47 -0700 Subject: [PATCH 31/35] Removed superfluous commented out code --- app/controllers/quotes_controller.rb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index 9f9b15e..e5f4fa1 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -9,15 +9,6 @@ def index Log.create_from_request_and_response(params, rates) - # log_entry = Log.new(params, rates) - # binding.pry - # if log_entry.save - # puts "YAY you added to the log" - # else - # puts "NO it didn't save" - # end - # adds this response to the log?? - # HTTParty.post(log_path, body: rates.to_json) render json: rates.to_json end end From df5b0cde6a938a13a696c64fae2967e44b63d158 Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 27 May 2016 13:17:00 -0700 Subject: [PATCH 32/35] Added simplecov to test_helper --- test/test_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index cc4185a..1ac756f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,7 @@ +require 'simplecov' +SimpleCov.start + + ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' From 9eebb10f9c4936af4f0a43c360473787695d38ed Mon Sep 17 00:00:00 2001 From: Valerie Date: Fri, 27 May 2016 15:23:58 -0700 Subject: [PATCH 33/35] Fixed weird yaml problem, though controller test still doesnt work for some reason. oh well we will figure it out later --- app/controllers/quotes_controller.rb | 1 - app/models/shipping.rb | 3 +- .../API/USPS/_FEDEX/should_be_an_array_.yml | 14 ++--- ...eturn_an_array_when_finding_USPS_rates.yml | 57 ++----------------- test/controllers/quotes_controller_test.rb | 29 ++++++++-- test/fixtures/logs.yml | 11 ---- test/fixtures/shippings.yml | 11 ---- 7 files changed, 38 insertions(+), 88 deletions(-) delete mode 100644 test/fixtures/logs.yml delete mode 100644 test/fixtures/shippings.yml diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index e5f4fa1..06eeb6a 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -3,7 +3,6 @@ class QuotesController < ApplicationController def index # adds the request to the log?? # HTTParty.post(log_path, body: params.to_json) - rate_quote = Shipping.create_by_params(params) rates = rate_quote.find_rates diff --git a/app/models/shipping.rb b/app/models/shipping.rb index affe0ec..c588dec 100644 --- a/app/models/shipping.rb +++ b/app/models/shipping.rb @@ -11,10 +11,9 @@ def initialize(packages,origin,destination) end def self.create_by_params(params) - - # getting the actual JSON we want from that big ugly params hash package_info = params[:request] # this is a string + # binding.pry params = JSON.parse(package_info) # change zip code to integer because of numeric data error... is this actually needed? diff --git a/test/cassettes/API/USPS/_FEDEX/should_be_an_array_.yml b/test/cassettes/API/USPS/_FEDEX/should_be_an_array_.yml index 10da6ee..08c0c4b 100644 --- a/test/cassettes/API/USPS/_FEDEX/should_be_an_array_.yml +++ b/test/cassettes/API/USPS/_FEDEX/should_be_an_array_.yml @@ -5,7 +5,7 @@ http_interactions: uri: https://gatewaybeta.fedex.com/xml body: encoding: UTF-8 - string: wTCb9AumfkXtr27Q RHz0ShHCr73OwFqQu5RC1CL7B 510087224 118727760 ActiveShipping crs 13 0 0 true SATURDAY_DELIVERY 2016-05-25T09:20:34-07:00 REGULAR_PICKUP YOUR_PACKAGING
Beverly + string: wTCb9AumfkXtr27Q RHz0ShHCr73OwFqQu5RC1CL7B 510087224 118727760 ActiveShipping crs 13 0 0 true SATURDAY_DELIVERY 2016-05-27T15:22:09-07:00 REGULAR_PICKUP YOUR_PACKAGING
Beverly Hills 90210 US true
Little Rock 72201 US true
PARCEL_SELECT 5902 ACCOUNT 2 1 LB 0.22 37 4 4 IN 1 LB 7.5 15 10 5 IN
headers: @@ -23,17 +23,17 @@ http_interactions: message: OK headers: Date: - - Wed, 25 May 2016 16:20:33 GMT + - Fri, 27 May 2016 22:22:09 GMT Server: - Apache Set-Cookie: - - siteDC=edc; path=/; domain=.fedex.com; expires=Thu, 26-May-2016 16:20:33 GMT + - siteDC=edc; path=/; domain=.fedex.com; expires=Sat, 28-May-2016 22:22:09 GMT X-Wily-Servlet: - - Encrypt1 GaMcoOotgOSMyoYj73M4dsxJg8pg+egXqWxT0tlCBMozxB2FJoHW86iPptGsWeEMNrrhgg+c1uCrVTL453EE8LUyyZJ0ssHZDmgz/H0Xk331Sy1KEH2kUmXY7Mq3Tf+CfqilOfvoO24JUs7Z6duDQzBDbr7hudkRV1vidonsMbUUBeIoWx/fKXVWWqtcEvhXJp/v93hA5q3ggWAPtS8Bww== + - Encrypt1 GaMcoOotgOSMyoYj73M4dsxJg8pg+egXqWxT0tlCBMozxB2FJoHW86iPptGsWeEMNrrhgg+c1uCrVTL453EE8LUyyZJ0ssHZDmgz/H0Xk331Sy1KEH2kUmXY7Mq3Tf+CfLsZQ58K5V1E4eeDhMETKvBwLvMNt8gJh8obAQ/MRvj3dh5HU9S6si6S97cS/EHw3HFdeSg55+ZRUoQ6SOC/WA== X-Powered-By: - Servlet/2.5 JSP/2.1 X-Wily-Info: - - Clear guid=E8B7B29BCC87128A0DFC1C1329CB1E20 + - Clear guid=F44F7812CC87128A0DFC1C138FDC9216 Vary: - Accept-Encoding Transfer-Encoding: @@ -44,7 +44,7 @@ http_interactions: encoding: ASCII-8BIT string: |- - NOTENOTEcrs819The origin state/province code has been changed. The origin state/province code has been changed. NOTEcrs820The destination state/province code has been changed. The destination state/province code has been changed. ActiveShippingcrs1300FIRST_OVERNIGHTYOUR_PACKAGINGLITA THU2016-05-26T08:00:00FIRST_OVERNIGHT2016-05-26T08:00:00THUA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD9.17USD250.83USD0.0USD250.83USD0.0USD0.0USD250.83RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.87RATED_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD9.17USD250.83USD0.0USD250.83USD0.0USD0.0USD250.83RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.87PRIORITY_OVERNIGHTYOUR_PACKAGINGLITA THU2016-05-26T10:30:00PRIORITY_OVERNIGHT2016-05-26T10:30:00THUA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD7.91USD81.91USD0.0USD81.91USD0.0USD0.0USD81.91RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.61RATED_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD7.91USD81.91USD0.0USD81.91USD0.0USD0.0USD81.91RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.61STANDARD_OVERNIGHTYOUR_PACKAGINGLITA THU2016-05-26T20:00:00STANDARD_OVERNIGHT2016-05-26T20:00:00THUA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE13937PACKAGEMIXED00.75LB12.0USD170.7USD0.0USD170.7USD8.63USD179.33USD0.0USD179.33USD0.0USD0.0USD179.33RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.33RATED_ACCOUNT_PACKAGE13937PACKAGEMIXED00.75LB12.0USD170.7USD0.0USD170.7USD8.63USD179.33USD0.0USD179.33USD0.0USD0.0USD179.33RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.33FEDEX_2_DAY_AMYOUR_PACKAGINGLITA FRI2016-05-27T10:30:00FEDEX_2_DAY_AM2016-05-27T10:30:00FRIA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE147PACKAGEMIXED00.75LB12.0USD108.07USD0.0USD108.07USD8.17USD116.24USD0.0USD116.24USD0.0USD0.0USD116.24RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.87RATED_ACCOUNT_PACKAGE147PACKAGEMIXED00.75LB12.0USD108.07USD0.0USD108.07USD8.17USD116.24USD0.0USD116.24USD0.0USD0.0USD116.24RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.87FEDEX_2_DAYYOUR_PACKAGINGLITA FRI2016-05-27T20:00:00FEDEX_2_DAY2016-05-27T20:00:00FRIA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE60907PACKAGEMIXED00.75LB12.0USD93.97USD0.0USD93.97USD8.06USD102.03USD0.0USD102.03USD0.0USD0.0USD102.03RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.76RATED_ACCOUNT_PACKAGE60907PACKAGEMIXED00.75LB12.0USD93.97USD0.0USD93.97USD8.06USD102.03USD0.0USD102.03USD0.0USD0.0USD102.03RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.76FEDEX_EXPRESS_SAVERYOUR_PACKAGINGLITA TUE2016-05-31T20:00:00FEDEX_EXPRESS_SAVER2016-05-31T20:00:00TUEA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE71777PACKAGEMIXED00.75LB12.0USD64.24USD0.0USD64.24USD7.84USD72.08USD0.0USD72.08USD0.0USD0.0USD72.08RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.54RATED_ACCOUNT_PACKAGE71777PACKAGEMIXED00.75LB12.0USD64.24USD0.0USD64.24USD7.84USD72.08USD0.0USD72.08USD0.0USD0.0USD72.08RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.54GROUND_HOME_DELIVERYYOUR_PACKAGINGGROUND_HOME_DELIVERYTHREE_DAYS0LITfalseTHREE_DAYSSERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE7MIXED1663.75LB12.0LB4.0USD23.56USD1.89USD21.67USD7.55USD29.22USD0.0USD29.22USD0.0USD0.0USD29.22VOLUMEBaseUSD1.890.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD6.5FUELPACKAGEFedEx Ground FuelUSD1.050PAYOR_ACCOUNT_PACKAGEDIMLB4.0LB4.0USD11.09USD0.89USD10.2USD3.75USD13.95USD0.0USD13.95USD0.0VOLUMEBaseUSD0.890.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD3.25FUELPACKAGEFedEx Ground FuelUSD0.50PAYOR_ACCOUNT_PACKAGEACTUALLB8.0USD12.47USD1.0USD11.47USD3.8USD15.27USD0.0USD15.27USD0.0VOLUMEBaseUSD1.00.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD3.25FUELPACKAGEFedEx Ground FuelUSD0.55 + NOTENOTEcrs819The origin state/province code has been changed. The origin state/province code has been changed. NOTEcrs820The destination state/province code has been changed. The destination state/province code has been changed. ActiveShippingcrs1300FIRST_OVERNIGHTYOUR_PACKAGINGLITA TUE2016-05-31T08:00:00FIRST_OVERNIGHT2016-05-31T08:00:00TUEA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD9.17USD250.83USD0.0USD250.83USD0.0USD0.0USD250.83RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.87RATED_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD9.17USD250.83USD0.0USD250.83USD0.0USD0.0USD250.83RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.87PRIORITY_OVERNIGHTYOUR_PACKAGINGLITA TUE2016-05-31T10:30:00PRIORITY_OVERNIGHT2016-05-31T10:30:00TUEA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD7.91USD81.91USD0.0USD81.91USD0.0USD0.0USD81.91RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.61RATED_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD7.91USD81.91USD0.0USD81.91USD0.0USD0.0USD81.91RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.61STANDARD_OVERNIGHTYOUR_PACKAGINGLITA TUE2016-05-31T20:00:00STANDARD_OVERNIGHT2016-05-31T20:00:00TUEA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE13937PACKAGEMIXED00.75LB12.0USD170.7USD0.0USD170.7USD8.63USD179.33USD0.0USD179.33USD0.0USD0.0USD179.33RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.33RATED_ACCOUNT_PACKAGE13937PACKAGEMIXED00.75LB12.0USD170.7USD0.0USD170.7USD8.63USD179.33USD0.0USD179.33USD0.0USD0.0USD179.33RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.33FEDEX_2_DAY_AMYOUR_PACKAGINGLITA WED2016-06-01T10:30:00FEDEX_2_DAY_AM2016-06-01T10:30:00WEDA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE147PACKAGEMIXED00.75LB12.0USD108.07USD0.0USD108.07USD8.17USD116.24USD0.0USD116.24USD0.0USD0.0USD116.24RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.87RATED_ACCOUNT_PACKAGE147PACKAGEMIXED00.75LB12.0USD108.07USD0.0USD108.07USD8.17USD116.24USD0.0USD116.24USD0.0USD0.0USD116.24RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.87FEDEX_2_DAYYOUR_PACKAGINGLITA WED2016-06-01T20:00:00FEDEX_2_DAY2016-06-01T20:00:00WEDA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE60907PACKAGEMIXED00.75LB12.0USD93.97USD0.0USD93.97USD8.06USD102.03USD0.0USD102.03USD0.0USD0.0USD102.03RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.76RATED_ACCOUNT_PACKAGE60907PACKAGEMIXED00.75LB12.0USD93.97USD0.0USD93.97USD8.06USD102.03USD0.0USD102.03USD0.0USD0.0USD102.03RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.76FEDEX_EXPRESS_SAVERYOUR_PACKAGINGLITA THU2016-06-02T20:00:00FEDEX_EXPRESS_SAVER2016-06-02T20:00:00THUA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE71777PACKAGEMIXED00.75LB12.0USD64.24USD0.0USD64.24USD7.84USD72.08USD0.0USD72.08USD0.0USD0.0USD72.08RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.54RATED_ACCOUNT_PACKAGE71777PACKAGEMIXED00.75LB12.0USD64.24USD0.0USD64.24USD7.84USD72.08USD0.0USD72.08USD0.0USD0.0USD72.08RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.54FIRST_OVERNIGHTYOUR_PACKAGINGSATURDAY_DELIVERYLITA SAT2016-05-28T09:30:00FIRST_OVERNIGHTSATURDAY_DELIVERY2016-05-28T09:30:00SATA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD41.41USD283.07USD0.0USD283.07USD0.0USD0.0USD283.07SATURDAY_DELIVERYSaturday deliveryUSD32.0RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD2.11RATED_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD41.41USD283.07USD0.0USD283.07USD0.0USD0.0USD283.07SATURDAY_DELIVERYSaturday deliveryUSD32.0RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD2.11PRIORITY_OVERNIGHTYOUR_PACKAGINGSATURDAY_DELIVERYLITA SAT2016-05-28T12:00:00PRIORITY_OVERNIGHTSATURDAY_DELIVERY2016-05-28T12:00:00SATA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD40.15USD114.15USD0.0USD114.15USD0.0USD0.0USD114.15SATURDAY_DELIVERYSaturday deliveryUSD32.0RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.85RATED_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD40.15USD114.15USD0.0USD114.15USD0.0USD0.0USD114.15SATURDAY_DELIVERYSaturday deliveryUSD32.0RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.85GROUND_HOME_DELIVERYYOUR_PACKAGINGGROUND_HOME_DELIVERYTHREE_DAYS0LITfalseTHREE_DAYSSERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE7MIXED1663.0LB12.0LB4.0USD23.56USD1.89USD21.67USD7.35USD29.02USD0.0USD29.02USD0.0USD0.0USD29.02VOLUMEBaseUSD1.890.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD6.5FUELPACKAGEFedEx Ground FuelUSD0.850PAYOR_ACCOUNT_PACKAGEDIMLB4.0LB4.0USD11.09USD0.89USD10.2USD3.66USD13.86USD0.0USD13.86USD0.0VOLUMEBaseUSD0.890.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD3.25FUELPACKAGEFedEx Ground FuelUSD0.410PAYOR_ACCOUNT_PACKAGEACTUALLB8.0USD12.47USD1.0USD11.47USD3.69USD15.16USD0.0USD15.16USD0.0VOLUMEBaseUSD1.00.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD3.25FUELPACKAGEFedEx Ground FuelUSD0.44 http_version: - recorded_at: Wed, 25 May 2016 16:20:38 GMT + recorded_at: Fri, 27 May 2016 22:22:11 GMT recorded_with: VCR 3.0.3 diff --git a/test/cassettes/API/USPS/should_return_an_array_when_finding_USPS_rates.yml b/test/cassettes/API/USPS/should_return_an_array_when_finding_USPS_rates.yml index 3e91320..4251a26 100644 --- a/test/cassettes/API/USPS/should_return_an_array_when_finding_USPS_rates.yml +++ b/test/cassettes/API/USPS/should_return_an_array_when_finding_USPS_rates.yml @@ -31,11 +31,11 @@ http_interactions: X-Powered-By: - ASP.NET Date: - - Tue, 24 May 2016 20:53:14 GMT + - Fri, 27 May 2016 22:22:08 GMT X-Client-Ip: - 56.0.70.6 X-Global-Transaction-Id: - - '2248910545' + - '1301594749' Access-Control-Allow-Origin: - "*" Connection: @@ -45,59 +45,12 @@ http_interactions: X-Frame-Options: - SAMEORIGIN Content-Length: - - '492' + - '491' body: encoding: ASCII-8BIT string: |- - 902107220103.5LARGEFALSE7Priority Mail Express 1-Day&lt;sup&gt;&#8482;&lt;/sup&gt;29.25Priority Mail Express 1-Day&lt;sup&gt;&#8482;&lt;/sup&gt; Hold For Pickup29.25Priority Mail 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt;7.30First-Class Mail&lt;sup&gt;&#174;&lt;/sup&gt; Parcel2.64USPS Retail Ground&lt;sup&gt;&#8482;&lt;/sup&gt;7.29Media Mail Parcel2.61Library Mail Parcel2.4890210722010120.0LARGETRUE7Priority Mail Express 1-Day&lt;sup&gt;&#8482;&lt;/sup&gt;73.05Priority Mail Express 1-Day&lt;sup&gt;&#8482;&lt;/sup&gt; Hold For Pickup73.05Priority Mail 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt;27.80USPS Retail Ground&lt;sup&gt;&#8482;&lt;/sup&gt;23.93Media Mail Parcel5.97Library Mail Parcel5.70 + 902107220103.5LARGEFALSE7Priority Mail Express 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt;29.25Priority Mail Express 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt; Hold For Pickup29.25Priority Mail 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt;7.30First-Class Mail&lt;sup&gt;&#174;&lt;/sup&gt; Parcel2.64USPS Retail Ground&lt;sup&gt;&#8482;&lt;/sup&gt;7.29Media Mail Parcel2.61Library Mail Parcel2.4890210722010120.0LARGETRUE7Priority Mail Express 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt;73.05Priority Mail Express 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt; Hold For Pickup73.05Priority Mail 2-Day&lt;sup&gt;&#8482;&lt;/sup&gt;27.80USPS Retail Ground&lt;sup&gt;&#8482;&lt;/sup&gt;23.93Media Mail Parcel5.97Library Mail Parcel5.70 http_version: - recorded_at: Tue, 24 May 2016 20:53:14 GMT -- request: - method: post - uri: https://gatewaybeta.fedex.com/xml - body: - encoding: UTF-8 - string: wTCb9AumfkXtr27Q RHz0ShHCr73OwFqQu5RC1CL7B 510087224 118727760 ActiveShipping crs 13 0 0 true SATURDAY_DELIVERY 2016-05-24T13:53:15-07:00 REGULAR_PICKUP YOUR_PACKAGING
Beverly - Hills 90210 US true
Little - Rock 72201 US true
PARCEL_SELECT 5902 ACCOUNT 2 1 LB 0.22 37 4 4 IN 1 LB 7.5 15 10 5 IN
- headers: - Content-Type: - - application/x-www-form-urlencoded - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Date: - - Tue, 24 May 2016 20:53:15 GMT - Server: - - Apache - Set-Cookie: - - siteDC=edc; path=/; domain=.fedex.com; expires=Wed, 25-May-2016 20:53:15 GMT - X-Wily-Servlet: - - Encrypt1 GaMcoOotgOSMyoYj73M4djxB/BFdu6Bd7dK9l2vKcsLoBxuCEbM12kwUffT0WqzWwhNfXxOuv1xkOK5NUzCbP46u7vtBQL8InqrXYgHsCoR6RU11Zne5eRfVnPz2s4QorsTJGp6CmyYymgSUI+wxBxsf5OU5gsdEA72cMkRv/fgqELt9eafqj4Lrwr4CAfmKraE28AJvbqJTb+A/db2E4A== - X-Powered-By: - - Servlet/2.5 JSP/2.1 - X-Wily-Info: - - Clear guid=E48B022DCC87128E0F000C2DF0CC26EB - Vary: - - Accept-Encoding - Transfer-Encoding: - - chunked - Content-Type: - - text/xml; charset=utf-8 - body: - encoding: ASCII-8BIT - string: |- - - NOTENOTEcrs819The origin state/province code has been changed. The origin state/province code has been changed. NOTEcrs820The destination state/province code has been changed. The destination state/province code has been changed. ActiveShippingcrs1300FIRST_OVERNIGHTYOUR_PACKAGINGLITA WED2016-05-25T08:00:00FIRST_OVERNIGHT2016-05-25T08:00:00WEDA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD9.17USD250.83USD0.0USD250.83USD0.0USD0.0USD250.83RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.87RATED_ACCOUNT_PACKAGE167PACKAGEMIXED00.75LB12.0USD241.66USD0.0USD241.66USD9.17USD250.83USD0.0USD250.83USD0.0USD0.0USD250.83RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.87PRIORITY_OVERNIGHTYOUR_PACKAGINGLITA WED2016-05-25T10:30:00PRIORITY_OVERNIGHT2016-05-25T10:30:00WEDA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD7.91USD81.91USD0.0USD81.91USD0.0USD0.0USD81.91RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.61RATED_ACCOUNT_PACKAGE1PACKAGEMIXED00.75LB12.0USD74.0USD0.0USD74.0USD7.91USD81.91USD0.0USD81.91USD0.0USD0.0USD81.91RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.61STANDARD_OVERNIGHTYOUR_PACKAGINGLITA WED2016-05-25T20:00:00STANDARD_OVERNIGHT2016-05-25T20:00:00WEDA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE13937PACKAGEMIXED00.75LB12.0USD170.7USD0.0USD170.7USD8.63USD179.33USD0.0USD179.33USD0.0USD0.0USD179.33RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.33RATED_ACCOUNT_PACKAGE13937PACKAGEMIXED00.75LB12.0USD170.7USD0.0USD170.7USD8.63USD179.33USD0.0USD179.33USD0.0USD0.0USD179.33RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD1.33FEDEX_2_DAY_AMYOUR_PACKAGINGLITA THU2016-05-26T10:30:00FEDEX_2_DAY_AM2016-05-26T10:30:00THUA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE147PACKAGEMIXED00.75LB12.0USD108.07USD0.0USD108.07USD8.17USD116.24USD0.0USD116.24USD0.0USD0.0USD116.24RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.87RATED_ACCOUNT_PACKAGE147PACKAGEMIXED00.75LB12.0USD108.07USD0.0USD108.07USD8.17USD116.24USD0.0USD116.24USD0.0USD0.0USD116.24RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.87FEDEX_2_DAYYOUR_PACKAGINGLITA THU2016-05-26T20:00:00FEDEX_2_DAY2016-05-26T20:00:00THUA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE60907PACKAGEMIXED00.75LB12.0USD93.97USD0.0USD93.97USD8.06USD102.03USD0.0USD102.03USD0.0USD0.0USD102.03RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.76RATED_ACCOUNT_PACKAGE60907PACKAGEMIXED00.75LB12.0USD93.97USD0.0USD93.97USD8.06USD102.03USD0.0USD102.03USD0.0USD0.0USD102.03RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.76FEDEX_EXPRESS_SAVERYOUR_PACKAGINGLITA FRI2016-05-27T20:00:00FEDEX_EXPRESS_SAVER2016-05-27T20:00:00FRIA10NON_DOCUMENTSLITfalseA1A1SERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE71777PACKAGEMIXED00.75LB12.0USD64.24USD0.0USD64.24USD7.84USD72.08USD0.0USD72.08USD0.0USD0.0USD72.08RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.54RATED_ACCOUNT_PACKAGE71777PACKAGEMIXED00.75LB12.0USD64.24USD0.0USD64.24USD7.84USD72.08USD0.0USD72.08USD0.0USD0.0USD72.08RESIDENTIAL_DELIVERYResidential deliveryUSD7.3FUELFuelUSD0.54GROUND_HOME_DELIVERYYOUR_PACKAGINGGROUND_HOME_DELIVERYTHREE_DAYS0LITfalseTHREE_DAYSSERVICE_DEFAULTPAYOR_ACCOUNT_PACKAGEPAYOR_ACCOUNT_PACKAGE7MIXED1663.75LB12.0LB4.0USD23.56USD1.89USD21.67USD7.55USD29.22USD0.0USD29.22USD0.0USD0.0USD29.22VOLUMEBaseUSD1.890.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD6.5FUELPACKAGEFedEx Ground FuelUSD1.050PAYOR_ACCOUNT_PACKAGEDIMLB4.0LB4.0USD11.09USD0.89USD10.2USD3.75USD13.95USD0.0USD13.95USD0.0VOLUMEBaseUSD0.890.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD3.25FUELPACKAGEFedEx Ground FuelUSD0.50PAYOR_ACCOUNT_PACKAGEACTUALLB8.0USD12.47USD1.0USD11.47USD3.8USD15.27USD0.0USD15.27USD0.0VOLUMEBaseUSD1.00.0RESIDENTIAL_DELIVERYPACKAGEFedEx Home Delivery Urban/Rural ChargeUSD3.25FUELPACKAGEFedEx Ground FuelUSD0.55 - http_version: - recorded_at: Tue, 24 May 2016 20:53:17 GMT + recorded_at: Fri, 27 May 2016 22:22:09 GMT recorded_with: VCR 3.0.3 diff --git a/test/controllers/quotes_controller_test.rb b/test/controllers/quotes_controller_test.rb index 01c55fd..fd2b249 100644 --- a/test/controllers/quotes_controller_test.rb +++ b/test/controllers/quotes_controller_test.rb @@ -1,7 +1,28 @@ require 'test_helper' -class QuotesControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end +module QuotesControllerTest + class IndexAction < ActionController::TestCase + setup do + @request.headers['Accept'] = Mime::JSON + @request.headers['Content-Type'] = Mime::JSON.to_s + + @params = { + origin: + # default address of Ada (treating it like a central warehouse) + { street_address: "1215 4th Ave", city: "Seattle", state: "WA", zip: "98161" }, + destination: + { street_address: "1600 Pennsylvania Ave NW", city: "Washington", state: "DC", zip: "20500" }, + products: + [ { height: 5, width: 2, weight: 0.3 }, { height: 3, width: 4, weight: 6 } ] + } + end + + test "can get index action" do + # binding.pry + post :index, request: @params, :format => 'json' + @body = JSON.parse(response.body) + assert_response :success + end + + end end diff --git a/test/fixtures/logs.yml b/test/fixtures/logs.yml deleted file mode 100644 index 937a0c0..0000000 --- a/test/fixtures/logs.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/shippings.yml b/test/fixtures/shippings.yml deleted file mode 100644 index 937a0c0..0000000 --- a/test/fixtures/shippings.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value From 4105492db55e347c5d5e3ac1cb652de97faf5f3f Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 27 May 2016 16:10:44 -0700 Subject: [PATCH 34/35] commit --- test/models/log_test.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/models/log_test.rb b/test/models/log_test.rb index f2afee2..7845856 100644 --- a/test/models/log_test.rb +++ b/test/models/log_test.rb @@ -1,7 +1,8 @@ require 'test_helper' class LogTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end + + + + end From dd69336d71b5678d4de314a3b75a42aac1c34773 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 27 May 2016 16:33:56 -0700 Subject: [PATCH 35/35] took file out of gitignore --- .gitignore | 1 - config/secrets.yml | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 config/secrets.yml diff --git a/.gitignore b/.gitignore index ec080ba..2658fe3 100644 --- a/.gitignore +++ b/.gitignore @@ -53,7 +53,6 @@ pickle-email-*.html # TODO Comment out these rules if you are OK with secrets being uploaded to the repo config/initializers/secret_token.rb -config/secrets.yml ## Environment normalization: /.bundle diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 0000000..64da5ec --- /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: 1bddcb4a02acf26eb6d69432893b55619fe61bd61b5a383e555e738b0ff1545787e3ce73d48be109b17292470904b59dc97bfc623047877b003a71dbb07522e5 + +test: + secret_key_base: 7ded01bee0435a73e41c67bb7bfd8bf39f9415a02073c4b82cf360da6c861384fe618ac029fe7cc51b1b7ac3a9de009c5430bede2488c3e3e1dfcf2c63302b1e + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>