#235 'You are not member of the project' when changing project notification.
This commit is contained in:
parent
2662c1f9ac
commit
ef3df86a10
@ -1,6 +1,7 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright (C) 2011 Vít Jonáš <vit.jonas@gmail.com>
|
||||
# Copyright (C) 2011-14 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -22,32 +23,18 @@ class DmsfStateController < ApplicationController
|
||||
menu_item :dmsf
|
||||
|
||||
before_filter :find_project
|
||||
before_filter :authorize
|
||||
|
||||
helper :all
|
||||
before_filter :authorize
|
||||
|
||||
def user_pref_save
|
||||
member = @project.members.find(:first, :conditions => {:user_id => User.current.id})
|
||||
member = @project.members.where(:user_id => User.current.id).first
|
||||
if member
|
||||
member.dmsf_mail_notification = params[:email_notify];
|
||||
member.dmsf_mail_notification = params[:email_notify]
|
||||
member.save!
|
||||
flash[:notice] = l(:notice_your_preferences_were_saved)
|
||||
else
|
||||
flash[:warning] = l(:user_is_not_project_member)
|
||||
end
|
||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'dmsf', :id => @project
|
||||
end
|
||||
redirect_to settings_project_path(@project, :tab => 'dmsf')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_project
|
||||
@project = Project.find(params[:id])
|
||||
end
|
||||
|
||||
def check_project(entry)
|
||||
if entry && entry.project != @project
|
||||
raise DmsfAccessError, l(:error_entry_project_does_not_match_current_project)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -169,7 +169,7 @@ en:
|
||||
warning_xapian_not_available: Xapian not available
|
||||
menu_dmsf: DMSF
|
||||
label_physical_file_delete: Physical file delete
|
||||
user_is_not_project_member: You are not member of the project
|
||||
user_is_not_project_member: You are not a member of the project
|
||||
heading_access_downloads_emails: Downloads/Emails
|
||||
heading_access_first: First
|
||||
heading_access_last: Last
|
||||
|
||||
@ -169,7 +169,7 @@ es:
|
||||
warning_xapian_not_available: Xapian not available
|
||||
menu_dmsf: DMSF
|
||||
label_physical_file_delete: Physical file delete
|
||||
user_is_not_project_member: You are not member of the project
|
||||
user_is_not_project_member: You are not a member of the project
|
||||
heading_access_downloads_emails: Downloads/Emails
|
||||
heading_access_first: First
|
||||
heading_access_last: Last
|
||||
|
||||
65
test/functional/dmsf_state_controller_test.rb
Normal file
65
test/functional/dmsf_state_controller_test.rb
Normal file
@ -0,0 +1,65 @@
|
||||
# Redmine plugin for Document Management System "Features"
|
||||
#
|
||||
# Copyright (C) 2011-14 Karel Pičman <karel.picman@kontron.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class DmsfStateControllerTest < RedmineDmsf::Test::TestCase
|
||||
include Redmine::I18n
|
||||
|
||||
fixtures :users, :projects, :members, :roles, :member_roles
|
||||
|
||||
def setup
|
||||
@user_admin = User.find_by_id 1 # Redmine admin
|
||||
@user_member = User.find_by_id 2 # John Smith - manager
|
||||
@user_non_member = User.find_by_id 3 # Dave Lopper
|
||||
@project = Project.find_by_id 1
|
||||
assert_not_nil @project
|
||||
@project.enable_module! :dmsf
|
||||
@role_manager = Role.find_by_name('Manager')
|
||||
@role_manager.add_permission! :user_preferences
|
||||
end
|
||||
|
||||
def test_truth
|
||||
assert_kind_of User, @user_admin
|
||||
assert_kind_of User, @user_member
|
||||
assert_kind_of User, @user_non_member
|
||||
assert_kind_of Project, @project
|
||||
assert_kind_of Role, @role_manager
|
||||
end
|
||||
|
||||
def test_user_pref_save
|
||||
# Member
|
||||
@request.session[:user_id] = @user_member.id
|
||||
post :user_pref_save, :id => @project.id, :email_notify => 1
|
||||
assert_redirected_to settings_project_path(@project, :tab => 'dmsf')
|
||||
assert_not_nil flash[:notice]
|
||||
assert_equal flash[:notice], l(:notice_your_preferences_were_saved)
|
||||
|
||||
# Non Member
|
||||
@request.session[:user_id] = @user_non_member.id
|
||||
post :user_pref_save, :id => @project.id, :email_notify => 1
|
||||
assert_response :forbidden
|
||||
|
||||
# Admin - non member
|
||||
@request.session[:user_id] = @user_admin.id
|
||||
post :user_pref_save, :id => @project.id, :email_notify => 1
|
||||
assert_redirected_to settings_project_path(@project, :tab => 'dmsf')
|
||||
assert_not_nil flash[:warning]
|
||||
assert_equal flash[:warning], l(:user_is_not_project_member)
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user