Permalink
Browse files

[#3432] Added a Sync button to the Auth Sources list.

  • Loading branch information...
1 parent aa7bd45 commit 7d0c56a156845d9b8bdff93ab68f1a4388588f1f @edavis10 committed Feb 9, 2010
@@ -0,0 +1,9 @@
+class LdapSyncsController < ApplicationController
+ unloadable
+ before_filter :require_admin
+
+ def show
+ flash[:notice] = l(:label_sync_completed)
+ redirect_to :controller => 'auth_sources', :action => 'list'
+ end
+end
@@ -1,3 +1,4 @@
# English strings go here for Rails i18n
en:
- my_label: "My label"
+ label_sync_auth_sources: "Sync"
+ label_sync_completed: "Sync completed"
View
@@ -0,0 +1,3 @@
+ActionController::Routing::Routes.draw do |map|
+ map.resource :ldap_sync
+end
View
@@ -15,3 +15,6 @@
require_dependency 'auth_source_ldap'
AuthSourceLdap.send(:include, RedmineExtraLdap::Patches::AuthSourceLdapPatch)
end
+
+require 'redmine_extra_ldap/hooks/auth_sources_hooks'
+
@@ -0,0 +1,10 @@
+module RedmineExtraLdap
+ module Hook
+ class AuthSourcesHooks < Redmine::Hook::ViewListener
+
+ def view_auth_sources_list_contextual(context={})
+ link_to(l(:label_sync_auth_sources), {:controller => 'ldap_syncs', :action => 'update'}, :class => 'icon icon-reload')
+ end
+ end
+ end
+end
@@ -0,0 +1,28 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class LdapSyncsControllerTest < ActionController::TestCase
+ context "for non-admins" do
+ should 'block access' do
+ @request.session[:user_id] = User.generate_with_protected!
+
+ get :show
+
+ assert_response 403
+ end
+ end
+
+ context "on GET to :show" do
+ setup do
+ @admin = User.generate_with_protected!
+ @admin.admin = true
+ @admin.save!
+ @request.session[:user_id] = @admin
+
+ get :show
+ end
+
+ should_respond_with :redirect
+ should_redirect_to("authentication source list") { {:controller => 'auth_sources', :action => 'list' }}
+ should_set_the_flash_to /complete/i
+ end
+end

0 comments on commit 7d0c56a

Please sign in to comment.