Skip to content

Commit

Permalink
Merge branch 'hotfix/0.3.2' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sukima committed Jan 13, 2011
2 parents 14ef3da + 8956e8e commit dee2ffc
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.rdoc
@@ -1,5 +1,5 @@
= Equipment Status Viewer
Version 0.3.1
Version 0.3.2

Equipment Status Viewer is a Redmine plugin that tracks the location of
equipment. It uses a check in system to track where each item is. It can also
Expand Down
11 changes: 7 additions & 4 deletions app/controllers/asset_check_ins_controller.rb
Expand Up @@ -27,6 +27,7 @@ def new
@asset_check_in = @equipment_asset.asset_check_ins.new(params[:asset_check_in])
@asset_check_in.equipment_asset_oos = @equipment_asset.oos
@asset_check_in.person ||= cookies[:asset_check_in_person]
@asset_check_in.location ||= @equipment_asset.location if !@equipment_asset.asset_check_ins.empty?
@asset_check_in.location ||= cookies[:asset_check_in_location]

respond_to do |wants|
Expand All @@ -41,15 +42,17 @@ def new
def loclist
@asset_check_in = @equipment_asset.asset_check_ins.new(params[:asset_check_in])
@query = params[:query]
if @query && !@query.empty?
@locations = AssetCheckIn.find(:all, :conditions => ["location LIKE ?", "%#{@query}%" ] ).map(&:location)
if @query.blank?
@locations = AssetCheckIn.find(:all, :group => 'location').map(&:location)
else
@locations = AssetCheckIn.find(:all).map(&:location)
@locations = AssetCheckIn.find(:all, :group => 'location', :conditions => ["location LIKE ?", "%#{@query}%"] ).map(&:location)
@asset_check_in.location ||= @query
end

respond_to do |wants|
# Only iPhone uses this action
wants.html do
@locations.unshift(@query) if @query && !@query.empty?
@locations.unshift(@query) if !@query.blank? && !@locations.include?(@query)
render 'loclist_iphone', :layout => false
end
wants.js do
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/equipment_assets_controller.rb
Expand Up @@ -27,10 +27,15 @@ class EquipmentAssetsController < ApplicationController
before_filter :authorize_global

def index
if assets_grouped_by != 'none'
# location is not a SQL query-able variable. Make a concession here.
if assets_grouped_by != 'none' && assets_grouped_by == 'location'
@equipment_assets = EquipmentAsset.find(:all, :order => "name asc")
@groups = AssetCheckIn.count(:all, :group => 'location')
elsif assets_grouped_by != 'none'
@equipment_assets = EquipmentAsset.find(:all, :order => "#{assets_grouped_by}, name asc")
@groups =EquipmentAsset.count(:all, :group => "#{assets_grouped_by}")
@groups = EquipmentAsset.count(:all, :group => "#{assets_grouped_by}")
else
@equipment_assets = EquipmentAsset.find(:all, :order => "name asc")
@groups = { }
end
@asset_check_ins = AssetCheckIn.find(:all, :order => "id desc", :limit => 20)
Expand Down
4 changes: 2 additions & 2 deletions app/views/asset_check_ins/loclist_iphone.rhtml
Expand Up @@ -26,9 +26,9 @@
</div>

<div class="searchbox">
<% form_tag(loclist_equipment_asset_asset_check_ins_path([@equipment_asset, @asset_check_in]), :method => :get) do %>
<% form_tag(loclist_equipment_asset_asset_check_ins_path([@equipment_asset]), :method => :get) do %>
<%= hidden_field_tag :person, @asset_check_in.person %>
<%= text_field_tag :query, @query, :placeholder => "Search" %>
<%= text_field_tag :query, @query, :placeholder => "Search / New Location" %>
<%= hidden_field_tag :submit %>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/asset_check_ins/new_iphone.rhtml
Expand Up @@ -51,7 +51,7 @@
<%= f.hidden_field :location %>
<% location = @asset_check_in.location %>
<% location ||= "Location" %>
<%= link_to "<span class=\"name\">#{location}</span>", loclist_equipment_asset_asset_check_ins_path([@equipment_asset, @asset_check_in]) %>
<%= link_to "<span class=\"name\">#{location}</span>", loclist_equipment_asset_asset_check_ins_path([@equipment_asset]) %>
<span class="arrow"></span>
</li>
<li class="checkbox">
Expand Down
2 changes: 1 addition & 1 deletion init.rb
Expand Up @@ -29,7 +29,7 @@
name 'Redmine Equipment Status Viewer plugin'
author 'Devin Weaver'
description 'Allows admins to make a list of equipment and track if they are inservice or not'
version '0.3.1'
version '0.3.2'
url 'http://github.com/sukima/redmine_equipment_status_viewer'
author_url 'http://github.com/sukima'

Expand Down
29 changes: 21 additions & 8 deletions test/functional/equipment_assets_controller_test.rb
Expand Up @@ -41,15 +41,28 @@ def setup
should_route :delete, "/equipment_assets/1", :action => :destroy, :id => 1
should_route :get, "/equipment_assets/1/print", :action => :print, :id => 1

context "GET :index" do
setup do
get :index
%(none asset_type location).each do |test_setting|
context "When asset_grouped_by == none" do
setup do
# Re-define the method to stub out the
# Setting.plugin_redmine_equipment_status_viewer logic
module EquipmentAssetsHelper
def asset_grouped_by
"#{test_setting}"
end
end
end
context "GET :index" do
setup do
get :index
end
should_respond_with :success
should_assign_to :equipment_assets
should_assign_to :asset_check_ins
should_assign_to :groups
should_render_template :index
end
end
should_respond_with :success
should_assign_to :equipment_assets
should_assign_to :asset_check_ins
should_assign_to :groups
should_render_template :index
end

context "GET :new" do
Expand Down

0 comments on commit dee2ffc

Please sign in to comment.