[#4180] Move the CSS and JS includes to the layout hooks.
This commit is contained in:
@@ -9,7 +9,3 @@
|
||||
<% semantic_form_for resource, :url => contract_path(@project, resource), :html => {:class => 'tabular'} do |form| %>
|
||||
<%= render :partial => 'form', :object => form, :locals => {:cancel_path => contract_path(@project, resource)} %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:header_tags) do %>
|
||||
<%= stylesheet_link_tag "redmine_contracts", :plugin => "redmine_contracts", :media => "screen" %>
|
||||
<% end %>
|
||||
|
||||
@@ -3,7 +3,3 @@
|
||||
<% semantic_form_for resource, :html => {:class => 'tabular'} do |form| %>
|
||||
<%= render :partial => 'form', :object => form, :locals => {:cancel_path => contracts_path} %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:header_tags) do %>
|
||||
<%= stylesheet_link_tag "redmine_contracts", :plugin => "redmine_contracts", :media => "screen" %>
|
||||
<% end %>
|
||||
|
||||
@@ -3,7 +3,3 @@
|
||||
<% semantic_form_for [@project, @contract, resource], :url => contract_deliverable_path(@project, @contract, resource), :html => {:class => 'tabular'} do |form| %>
|
||||
<%= render :partial => 'form', :object => form, :locals => {:cancel_path => contract_path(@project, @contract)} %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:header_tags) do %>
|
||||
<%= stylesheet_link_tag "redmine_contracts", :plugin => "redmine_contracts", :media => "screen" %>
|
||||
<% end %>
|
||||
|
||||
@@ -3,7 +3,3 @@
|
||||
<% semantic_form_for [@project, @contract, resource], :url => contract_deliverables_path(@project, @contract), :html => {:class => 'tabular'} do |form| %>
|
||||
<%= render :partial => 'form', :object => form, :locals => {:cancel_path => contract_path(@project, @contract)} %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:header_tags) do %>
|
||||
<%= stylesheet_link_tag "redmine_contracts", :plugin => "redmine_contracts", :media => "screen" %>
|
||||
<% end %>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
jQuery.noConflict();
|
||||
|
||||
@@ -55,3 +55,5 @@ Dispatcher.to_prepare :redmine_contracts do
|
||||
require_dependency 'project'
|
||||
Project.send(:include, RedmineContracts::Patches::ProjectPatch)
|
||||
end
|
||||
|
||||
require 'redmine_contracts/hooks/view_layouts_base_html_head_hook'
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
module RedmineContracts
|
||||
module Hooks
|
||||
class ViewLayoutsBaseHtmlHeadHook < Redmine::Hook::ViewListener
|
||||
def view_layouts_base_html_head(context={})
|
||||
if context[:controller] && (
|
||||
context[:controller].is_a?(ContractsController) ||
|
||||
context[:controller].is_a?(DeliverablesController)
|
||||
)
|
||||
return stylesheet_link_tag("redmine_contracts", :plugin => "redmine_contracts", :media => "screen") +
|
||||
|
||||
javascript_include_tag('jquery-1.4.2.min.js', :plugin => 'redmine_contracts') +
|
||||
javascript_include_tag('contracts.js', :plugin => 'redmine_contracts')
|
||||
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,72 @@
|
||||
require File.dirname(__FILE__) + '/../../../../test_helper'
|
||||
|
||||
class RedmineContracts::Hooks::ViewLayoutsBaseHtmlHeadTest < ActionController::TestCase
|
||||
include Redmine::Hook::Helper
|
||||
|
||||
def controller
|
||||
@controller ||= ApplicationController.new
|
||||
@controller.response ||= ActionController::TestResponse.new
|
||||
@controller
|
||||
end
|
||||
|
||||
def request
|
||||
@request ||= ActionController::TestRequest.new
|
||||
end
|
||||
|
||||
def hook(args={})
|
||||
call_hook :view_layouts_base_html_head, args
|
||||
end
|
||||
|
||||
context "#view_layouts_base_html_head" do
|
||||
context "for any non-contracts plugin controller" do
|
||||
should "return an empty string" do
|
||||
@response.body = hook
|
||||
assert @response.body.blank?
|
||||
end
|
||||
end
|
||||
|
||||
context "for Contracts Controller" do
|
||||
setup do
|
||||
@controller = ContractsController.new
|
||||
@controller.response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
should "load the redmine_contracts.css stylesheet" do
|
||||
@response.body = hook
|
||||
assert_select "link[href*=?]", "redmine_contracts.css"
|
||||
end
|
||||
|
||||
should "load jquery" do
|
||||
@response.body = hook
|
||||
assert_select "script[src*=?]", "jquery-1.4.2.min.js"
|
||||
end
|
||||
|
||||
should "load the contracts.js JavaScript" do
|
||||
@response.body = hook
|
||||
assert_select "script[src*=?]", "contracts.js"
|
||||
end
|
||||
end
|
||||
|
||||
context "for Deliverables Controller" do
|
||||
setup do
|
||||
@controller = DeliverablesController.new
|
||||
@controller.response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
should "load the redmine_contracts.css stylesheet" do
|
||||
@response.body = hook
|
||||
assert_select "link[href*=?]", "redmine_contracts.css"
|
||||
end
|
||||
|
||||
should "load jquery" do
|
||||
@response.body = hook
|
||||
assert_select "script[src*=?]", "jquery-1.4.2.min.js"
|
||||
end
|
||||
|
||||
should "load the contracts.js JavaScript" do
|
||||
@response.body = hook
|
||||
assert_select "script[src*=?]", "contracts.js"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user