[#4177] Added a project module for contracts and a stubbed permission.
This commit is contained in:
1 parent
4ce7595111
commit
7892c577c8
4 files changed
+67
No files matched your search
@@ -2,4 +2,14 @@ class ContractsController < InheritedResources::Base
|
|||||||
unloadable
|
unloadable
|
||||||
|
|
||||||
respond_to :html
|
respond_to :html
|
||||||
|
|
||||||
|
before_filter :find_project
|
||||||
|
before_filter :authorize
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_project
|
||||||
|
@project = Project.find(params[:project_id])
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -10,6 +10,10 @@ Redmine::Plugin.register :redmine_contracts do
|
|||||||
|
|
||||||
requires_redmine :version_or_higher => '0.9.0'
|
requires_redmine :version_or_higher => '0.9.0'
|
||||||
requires_redmine_plugin :redmine_rate, :version_or_higher => '0.1.0'
|
requires_redmine_plugin :redmine_rate, :version_or_higher => '0.1.0'
|
||||||
|
|
||||||
|
project_module :contracts do
|
||||||
|
permission :manage_budget, {}, :require => :member
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'dispatcher'
|
require 'dispatcher'
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class DisabledContractsModuleTest < ActionController::IntegrationTest
|
||||||
|
def setup
|
||||||
|
@user = User.generate!(:login => 'existing', :password => 'existing', :password_confirmation => 'existing', :admin => true)
|
||||||
|
login_as
|
||||||
|
end
|
||||||
|
|
||||||
|
context "on a project with the Contracts module disabled" do
|
||||||
|
setup do
|
||||||
|
@project = Project.generate!
|
||||||
|
@project.enabled_modules.find_by_name('contracts').destroy
|
||||||
|
@project.reload
|
||||||
|
assert !@project.module_enabled?(:contracts), "Contracts enabled on project"
|
||||||
|
end
|
||||||
|
|
||||||
|
should "block access to list" do
|
||||||
|
visit '/'
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
click_link 'Projects'
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
click_link @project.name
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
assert_select "#main-menu" do
|
||||||
|
assert_select 'a', :text => /contracts/i, :count => 0
|
||||||
|
end
|
||||||
|
|
||||||
|
visit "/projects/#{@project.identifier}/contracts"
|
||||||
|
assert_response :forbidden
|
||||||
|
assert_template 'common/403'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -9,3 +9,19 @@ require "webrat"
|
|||||||
Webrat.configure do |config|
|
Webrat.configure do |config|
|
||||||
config.mode = :rails
|
config.mode = :rails
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module IntegrationTestHelper
|
||||||
|
def login_as(user="existing", password="existing")
|
||||||
|
visit "/login"
|
||||||
|
fill_in 'Login', :with => user
|
||||||
|
fill_in 'Password', :with => password
|
||||||
|
click_button 'login'
|
||||||
|
assert_response :success
|
||||||
|
assert User.current.logged?
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
class ActionController::IntegrationTest
|
||||||
|
include IntegrationTestHelper
|
||||||
|
end
|
||||||
Reference in new issue
Block a user