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