From 54695ae134e15cff8eeaa4d1c4819eeb262a909a Mon Sep 17 00:00:00 2001 From: Nikitas Tampakis Date: Tue, 15 Dec 2015 23:44:30 -0500 Subject: [PATCH] link to holding location and sort based on code --- .gitignore | 2 +- .travis.yml | 5 +--- Gemfile | 21 +++++++++++++---- .../locations/holding_locations_controller.rb | 2 +- .../holding_locations/index.html.erb | 6 ++--- lib/locations/version.rb | 2 +- .../location_views_associated_links_spec.rb | 2 +- .../holding_locations_json_view_spec.rb | 2 +- spec/spec_helper.rb | 12 ++++++---- .../lib/generators/test_app_generator.rb | 23 ++----------------- 10 files changed, 35 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 4ff6eb9..4c32161 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ log/*.log pkg/ Gemfile.lock -spec/internal/ +.internal_test_app/ # Ignore coverage coverage/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index db52e0a..58fb981 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,7 @@ rvm: - 2.1.5 - 2.2.0 -before_script: - - bundle exec rake engine_cart:regenerate - -script: bundle exec rake spec +script: bundle exec rake ci branches: only: diff --git a/Gemfile b/Gemfile index efe482c..25b4d64 100644 --- a/Gemfile +++ b/Gemfile @@ -5,17 +5,28 @@ source 'https://rubygems.org' # development dependencies will be added by default to the :development group. gemspec -file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path("../spec/internal", __FILE__)) -if File.exists?(file) - puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` - instance_eval File.read(file) +# BEGIN ENGINE_CART BLOCK +# engine_cart: 0.8.0 +# engine_cart stanza: 0.8.0 +# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app. +file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path(".internal_test_app", File.dirname(__FILE__))) +if File.exist?(file) + begin + eval_gemfile file + rescue Bundler::GemfileError => e + Bundler.ui.warn '[EngineCart] Skipping Rails application dependencies:' + Bundler.ui.warn e.message + end else + Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies" + gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION'] - if ENV['RAILS_VERSION'] and ENV['RAILS_VERSION'] =~ /^4.2/ + if ENV['RAILS_VERSION'].nil? || ENV['RAILS_VERSION'] =~ /^4.2/ gem 'responders', "~> 2.0" gem 'sass-rails', ">= 5.0" else gem 'sass-rails', "< 5.0" end end +# END ENGINE_CART BLOCK diff --git a/app/controllers/locations/holding_locations_controller.rb b/app/controllers/locations/holding_locations_controller.rb index 34acc53..2222a7a 100644 --- a/app/controllers/locations/holding_locations_controller.rb +++ b/app/controllers/locations/holding_locations_controller.rb @@ -6,7 +6,7 @@ class HoldingLocationsController < ApplicationController # GET /holding_locations def index - @holding_locations = HoldingLocation.all + @holding_locations = HoldingLocation.order(:code) end # GET /holding_locations/1 diff --git a/app/views/locations/holding_locations/index.html.erb b/app/views/locations/holding_locations/index.html.erb index d7e5449..c343075 100644 --- a/app/views/locations/holding_locations/index.html.erb +++ b/app/views/locations/holding_locations/index.html.erb @@ -3,8 +3,8 @@ - + @@ -19,8 +19,8 @@ <% @holding_locations.each do |holding_location| %> - - + + diff --git a/lib/locations/version.rb b/lib/locations/version.rb index 5205fea..2fbfcc1 100644 --- a/lib/locations/version.rb +++ b/lib/locations/version.rb @@ -1,3 +1,3 @@ module Locations - VERSION = "0.1.1" + VERSION = "0.1.2" end diff --git a/spec/features/locations/location_views_associated_links_spec.rb b/spec/features/locations/location_views_associated_links_spec.rb index c941981..4195767 100644 --- a/spec/features/locations/location_views_associated_links_spec.rb +++ b/spec/features/locations/location_views_associated_links_spec.rb @@ -22,7 +22,7 @@ scenario 'Link to holding location from holding location label rather than extra show link' do holding_location visit holding_locations_path - click_link holding_location.label + click_link holding_location.code end scenario 'Link to delivery location from delivery location label rather than extra show link' do diff --git a/spec/requests/locations/holding_locations_json_view_spec.rb b/spec/requests/locations/holding_locations_json_view_spec.rb index ef04c8f..ca475e6 100644 --- a/spec/requests/locations/holding_locations_json_view_spec.rb +++ b/spec/requests/locations/holding_locations_json_view_spec.rb @@ -56,7 +56,7 @@ module Locations } expected << attrs get holding_locations_path, format: :json - expect(response.body).to eq expected.to_json + expect(response.body).to eq expected.sort_by{ |k| k[:code] }.to_json end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 021ca31..9cfbdaf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,14 +1,18 @@ ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../spec/internal/config/environment', __FILE__) +require 'coveralls' + +Coveralls.wear!('rails') do + add_filter '/lib/generators/locations/install_generator.rb' + add_filter '/lib/locations/version.rb' +end + +require File.expand_path('../../.internal_test_app/config/environment', __FILE__) require 'factory_girl_rails' require 'rspec/rails' require 'engine_cart' require 'database_cleaner' require 'capybara/poltergeist' -require 'coveralls' - -Coveralls.wear!('rails') Capybara.javascript_driver = :poltergeist diff --git a/spec/test_app_templates/lib/generators/test_app_generator.rb b/spec/test_app_templates/lib/generators/test_app_generator.rb index 3c14a5e..349ae52 100644 --- a/spec/test_app_templates/lib/generators/test_app_generator.rb +++ b/spec/test_app_templates/lib/generators/test_app_generator.rb @@ -12,31 +12,12 @@ class TestAppGenerator < Rails::Generators::Base # end def add_gems - gem 'bootstrap-sass', '~> 3.3' - gem 'yaml_db', '~> 0.3.0' gem 'factory_girl_rails', '~> 4.5.0', group: [:development, :test] gem 'faker', '~> 1.4.3', group: [:development, :test] - Bundler.with_clean_env do - run "bundle install" - end end - def friendly_id - gem 'friendly_id', '~> 5.1.0' - generate 'friendly_id' - gsub_file 'config/initializers/friendly_id.rb', 'new edit', 'create edit' - end - - def inject_routes - inject_into_file 'config/routes.rb', after: %Q(Rails.application.routes.draw do\n) do - %Q( mount Locations::Engine, at: '/locations'\n)\ - end - end - - def run_migrations - rake 'locations:install:migrations' - rake "db:migrate" - rake "db:migrate RAILS_ENV=test" + def install_engine + generate 'locations:install', '-f' end end
Label CodeLabel Library Hours Location Aeon Location
<%= link_to holding_location.label, holding_location %><%= holding_location.code %><%= link_to holding_location.code, holding_location %><%= holding_location.label %> <%= link_to holding_location.library.code, holding_location.library %> <%= hours_render holding_location %> <%= holding_location.aeon_location %>