Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
link to holding location and sort based on code
Browse files Browse the repository at this point in the history
  • Loading branch information
tampakis committed Dec 16, 2015
1 parent ab14d3d commit 54695ae
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
log/*.log
pkg/
Gemfile.lock
spec/internal/
.internal_test_app/

# Ignore coverage
coverage/
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 16 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion app/controllers/locations/holding_locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/views/locations/holding_locations/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<table class="table">
<thead>
<tr>
<th>Label</th>
<th>Code</th>
<th>Label</th>
<th>Library</th>
<th>Hours Location</th>
<th>Aeon Location</th>
Expand All @@ -19,8 +19,8 @@
<tbody>
<% @holding_locations.each do |holding_location| %>
<tr>
<td><%= link_to holding_location.label, holding_location %></td>
<td><%= holding_location.code %></td>
<td><%= link_to holding_location.code, holding_location %></td>
<td><%= holding_location.label %></td>
<td><%= link_to holding_location.library.code, holding_location.library %></td>
<td><%= hours_render holding_location %></td>
<td><%= holding_location.aeon_location %></td>
Expand Down
2 changes: 1 addition & 1 deletion lib/locations/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Locations
VERSION = "0.1.1"
VERSION = "0.1.2"
end
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 8 additions & 4 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down
23 changes: 2 additions & 21 deletions spec/test_app_templates/lib/generators/test_app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 54695ae

Please sign in to comment.