From 736f315b36127b251e54db4c54518fab195a5ad3 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 17 Jun 2010 16:02:09 -0700 Subject: [PATCH] [#4177] Added Project#contracts association. --- init.rb | 4 ++++ .../patches/project_patch.rb | 22 +++++++++++++++++++ .../patches/project_patch_test.rb | 9 ++++++++ 3 files changed, 35 insertions(+) create mode 100644 lib/redmine_contracts/patches/project_patch.rb create mode 100644 test/unit/lib/redmine_contracts/patches/project_patch_test.rb diff --git a/init.rb b/init.rb index 6f21f05..79c3c1e 100644 --- a/init.rb +++ b/init.rb @@ -24,7 +24,11 @@ end require 'dispatcher' Dispatcher.to_prepare :redmine_contracts do + gem 'inherited_resources', :version => '1.0.6' require_dependency 'inherited_resources' require_dependency 'inherited_resources/base' + + require_dependency 'project' + Project.send(:include, RedmineContracts::Patches::ProjectPatch) end diff --git a/lib/redmine_contracts/patches/project_patch.rb b/lib/redmine_contracts/patches/project_patch.rb new file mode 100644 index 0000000..9921bfb --- /dev/null +++ b/lib/redmine_contracts/patches/project_patch.rb @@ -0,0 +1,22 @@ +module RedmineContracts + module Patches + module ProjectPatch + def self.included(base) + base.extend(ClassMethods) + + base.send(:include, InstanceMethods) + base.class_eval do + unloadable + + has_many :contracts + end + end + + module ClassMethods + end + + module InstanceMethods + end + end + end +end diff --git a/test/unit/lib/redmine_contracts/patches/project_patch_test.rb b/test/unit/lib/redmine_contracts/patches/project_patch_test.rb new file mode 100644 index 0000000..9ab0aec --- /dev/null +++ b/test/unit/lib/redmine_contracts/patches/project_patch_test.rb @@ -0,0 +1,9 @@ +require File.dirname(__FILE__) + '/../../../../test_helper' + +class RedmineContracts::Patches::ProjectTest < ActionController::TestCase + + context "Project" do + subject { Project.new } + should_have_many :contracts + end +end