From e8e351dd6a66bf6ed518f1eeb7aa7eb19e2fb85e 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 +- 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 | 2 +- 8 files changed, 25 insertions(+), 14 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/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..b3af83b 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: :asc) 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..03adcf9 100644 --- a/spec/requests/locations/holding_locations_json_view_spec.rb +++ b/spec/requests/locations/holding_locations_json_view_spec.rb @@ -14,7 +14,7 @@ module Locations it "/holding_locations looks as we'd expect" do 2.times { FactoryGirl.create(:holding_location) } expected = [] - HoldingLocation.all.each do |holding_location| + HoldingLocation.order(code: :asc).each do |holding_location| attrs = { label: holding_location.label, code: holding_location.code, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 021ca31..e6b03b5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../../spec/internal/config/environment', __FILE__) +require File.expand_path('../../.internal_test_app/config/environment', __FILE__) require 'factory_girl_rails' require 'rspec/rails' require 'engine_cart'
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 %>