diff options
-rw-r--r-- | app/controllers/admin_controller.rb | 17 | ||||
-rw-r--r-- | app/views/admin/_no_data.rhtml | 8 | ||||
-rw-r--r-- | app/views/admin/index.rhtml | 2 | ||||
-rw-r--r-- | doc/INSTALL | 14 | ||||
-rw-r--r-- | lang/bg.yml | 4 | ||||
-rw-r--r-- | lang/cs.yml | 4 | ||||
-rw-r--r-- | lang/de.yml | 4 | ||||
-rw-r--r-- | lang/en.yml | 5 | ||||
-rw-r--r-- | lang/es.yml | 4 | ||||
-rw-r--r-- | lang/fr.yml | 7 | ||||
-rw-r--r-- | lang/he.yml | 4 | ||||
-rw-r--r-- | lang/it.yml | 4 | ||||
-rw-r--r-- | lang/ja.yml | 4 | ||||
-rw-r--r-- | lang/ko.yml | 4 | ||||
-rw-r--r-- | lang/nl.yml | 4 | ||||
-rw-r--r-- | lang/pl.yml | 4 | ||||
-rw-r--r-- | lang/pt-br.yml | 4 | ||||
-rw-r--r-- | lang/pt.yml | 4 | ||||
-rw-r--r-- | lang/ro.yml | 4 | ||||
-rw-r--r-- | lang/ru.yml | 4 | ||||
-rw-r--r-- | lang/sr.yml | 4 | ||||
-rw-r--r-- | lang/sv.yml | 4 | ||||
-rw-r--r-- | lang/zh-tw.yml | 4 | ||||
-rw-r--r-- | lang/zh.yml | 4 | ||||
-rw-r--r-- | lib/redmine/default_data/loader.rb | 215 | ||||
-rw-r--r-- | test/functional/admin_controller_test.rb | 28 |
26 files changed, 248 insertions, 120 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 0f8eb32a5..9e6a22822 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -22,7 +22,8 @@ class AdminController < ApplicationController helper :sort include SortHelper - def index + def index + @no_configuration_data = Redmine::DefaultData::Loader::no_data? end def projects @@ -56,6 +57,20 @@ class AdminController < ApplicationController end end + # Loads the default configuration + # (roles, trackers, statuses, workflow, enumerations) + def default_configuration + if request.post? + begin + Redmine::DefaultData::Loader::load(params[:lang]) + flash[:notice] = l(:notice_default_data_loaded) + rescue Exception => e + flash[:error] = l(:error_can_t_load_default_data, e.message) + end + end + redirect_to :action => 'index' + end + def test_email raise_delivery_errors = ActionMailer::Base.raise_delivery_errors # Force ActionMailer to raise delivery errors so we can catch it diff --git a/app/views/admin/_no_data.rhtml b/app/views/admin/_no_data.rhtml new file mode 100644 index 000000000..5d52dc059 --- /dev/null +++ b/app/views/admin/_no_data.rhtml @@ -0,0 +1,8 @@ +<div class="nodata"> +<% form_tag({:action => 'default_configuration'}) do %> + <%= simple_format(l(:text_no_configuration_data)) %> + <p><%= l(:field_language) %>: + <%= select_tag 'lang', options_for_select(lang_options_for_select(false), current_language.to_s) %> + <%= submit_tag l(:text_load_default_configuration) %></p> +<% end %> +</div> diff --git a/app/views/admin/index.rhtml b/app/views/admin/index.rhtml index 1c6cbdee5..2291c5415 100644 --- a/app/views/admin/index.rhtml +++ b/app/views/admin/index.rhtml @@ -1,5 +1,7 @@ <h2><%=l(:label_administration)%></h2> +<%= render :partial => 'no_data' if @no_configuration_data %> + <p class="icon22 icon22-projects"> <%= link_to l(:label_project_plural), :controller => 'admin', :action => 'projects' %> | <%= link_to l(:label_new), :controller => 'projects', :action => 'add' %> diff --git a/doc/INSTALL b/doc/INSTALL index 5eb4d5c68..035e97cab 100644 --- a/doc/INSTALL +++ b/doc/INSTALL @@ -33,24 +33,18 @@ Supported databases: rake db:migrate RAILS_ENV="production" It will create tables and an administrator account. -5. Insert default configuration data in the database: - rake redmine:load_default_data RAILS_ENV="production" - It will load default roles, trackers, statuses, workflows and enumerations. - This step is optional but *highly recommended* - -6. Test the installation by running WEBrick web server: +5. Test the installation by running WEBrick web server: ruby script/server -e production Once WEBrick has started, point your browser to http://localhost:3000/ You should now see the application welcome page -7. Use default administrator account to log in: +6. Use default administrator account to log in: login: admin password: admin -8. You can go to "Admin -> Settings" to modify application settings. - -9. Setup Apache or Lighttpd with fastcgi for best performance. +7. Go to "Administration" to load the default configuration data (roles, + trackers, statuses, workflow) and adjust application settings == SMTP server Configuration diff --git a/lang/bg.yml b/lang/bg.yml index 916e89268..eeb6ef80b 100644 --- a/lang/bg.yml +++ b/lang/bg.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/cs.yml b/lang/cs.yml index db2055f6c..e99fe061b 100644 --- a/lang/cs.yml +++ b/lang/cs.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/de.yml b/lang/de.yml index 2d4a95c2d..cd4e222ae 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/en.yml b/lang/en.yml index 2419b05db..7a1a2622f 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -76,6 +76,9 @@ notice_feeds_access_key_reseted: Your RSS access key was reseted. notice_failed_to_save_issues: "Failed to save %d issue(s) on %d selected: %s." notice_no_issue_selected: "No issue is selected! Please, check the issues you want to edit." notice_account_pending: "Your account was created and is now pending administrator approval." +notice_default_data_loaded: Default configuration successfully loaded. + +error_can_t_load_default_data: "Default configuration could not be loaded: %s" mail_subject_lost_password: Your Redmine password mail_body_lost_password: 'To change your Redmine password, click on the following link:' @@ -527,6 +530,8 @@ text_issue_category_destroy_question: Some issues (%d) are assigned to this cate text_issue_category_destroy_assignments: Remove category assignments text_issue_category_reassign_to: Reassign issues to this category text_user_mail_option: "For unselected projects, you will only receive notifications about things you watch or you're involved in (eg. issues you're the author or assignee)." +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +text_load_default_configuration: Load the default configuration default_role_manager: Manager default_role_developper: Developer diff --git a/lang/es.yml b/lang/es.yml index b7aaf1b39..bae295586 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -556,3 +556,7 @@ field_searchable: Incluir en las búsquedas label_display_per_page: 'Por página: %s' setting_per_page_options: Objetos por página label_age: Edad +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/fr.yml b/lang/fr.yml index 394865a21..d47feceb2 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -72,10 +72,13 @@ notice_scm_error: "L'entrée et/ou la révision demandée n'existe pas dans le d notice_not_authorized: "Vous n'êtes pas autorisés à accéder à cette page." notice_email_sent: "Un email a été envoyé à %s" notice_email_error: "Erreur lors de l'envoi de l'email (%s)" -notice_feeds_access_key_reseted: Votre clé d'accès aux flux RSS a été réinitialisée. +notice_feeds_access_key_reseted: "Votre clé d'accès aux flux RSS a été réinitialisée." notice_failed_to_save_issues: "%d demande(s) sur les %d sélectionnées n'ont pas pu être mise(s) à jour: %s." notice_no_issue_selected: "Aucune demande sélectionnée ! Cochez les demandes que vous voulez mettre à jour." notice_account_pending: "Votre compte a été créé et attend l'approbation de l'administrateur." +notice_default_data_loaded: Paramétrage par défaut chargé avec succès. + +error_can_t_load_default_data: "Une erreur s'est produite lors du chargement du paramétrage: %s" mail_subject_lost_password: Votre mot de passe redMine mail_body_lost_password: 'Pour changer votre mot de passe Redmine, cliquez sur le lien suivant:' @@ -527,6 +530,8 @@ text_issue_category_destroy_question: Des demandes (%d) sont affectées à cette text_issue_category_destroy_assignments: N'affecter les demandes à aucune autre catégorie text_issue_category_reassign_to: Réaffecter les demandes à cette catégorie text_user_mail_option: "Pour les projets non sélectionnés, vous recevrez seulement des notifications pour ce que vous surveillez ou à quoi vous participez (exemple: demandes dont vous êtes l'auteur ou la personne assignée)." +text_no_configuration_data: "Les rôles, trackers, statuts et le workflow ne sont pas encore paramétrés.\nIl est vivement recommandé de charger le paramétrage par defaut. Vous pourrez le modifier une fois chargé." +text_load_default_configuration: Charger le paramétrage par défaut default_role_manager: Manager default_role_developper: Développeur diff --git a/lang/he.yml b/lang/he.yml index 322b10b7c..e2277dc3d 100644 --- a/lang/he.yml +++ b/lang/he.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/it.yml b/lang/it.yml index 561215f78..709f41774 100644 --- a/lang/it.yml +++ b/lang/it.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/ja.yml b/lang/ja.yml index eb30edb26..286fb5971 100644 --- a/lang/ja.yml +++ b/lang/ja.yml @@ -554,3 +554,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/ko.yml b/lang/ko.yml index d0e03b364..52c9b5431 100644 --- a/lang/ko.yml +++ b/lang/ko.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/nl.yml b/lang/nl.yml index 74eff69ea..43e1704a4 100644 --- a/lang/nl.yml +++ b/lang/nl.yml @@ -554,3 +554,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/pl.yml b/lang/pl.yml index f1513ac92..77ae6bb66 100644 --- a/lang/pl.yml +++ b/lang/pl.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/pt-br.yml b/lang/pt-br.yml index 33719d11b..55e8b3fae 100644 --- a/lang/pt-br.yml +++ b/lang/pt-br.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s'
setting_per_page_options: Objects per page options
label_age: Age
+notice_default_data_loaded: Default configuration successfully loaded.
+text_load_default_configuration: Load the default configuration
+text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded."
+error_can_t_load_default_data: "Default configuration could not be loaded: %s"
diff --git a/lang/pt.yml b/lang/pt.yml index c042589e3..0a5661997 100644 --- a/lang/pt.yml +++ b/lang/pt.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/ro.yml b/lang/ro.yml index e615472ad..1381adba9 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/ru.yml b/lang/ru.yml index d40379788..b293dc309 100644 --- a/lang/ru.yml +++ b/lang/ru.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/sr.yml b/lang/sr.yml index 18e97d444..c842ec438 100644 --- a/lang/sr.yml +++ b/lang/sr.yml @@ -554,3 +554,7 @@ field_searchable: Searchable label_display_per_page: 'Po stranici: %s' setting_per_page_options: Objekata po stranici opcija label_age: Starost +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/sv.yml b/lang/sv.yml index dd4117115..85fb19bcb 100644 --- a/lang/sv.yml +++ b/lang/sv.yml @@ -554,3 +554,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml index 889f86a1c..719a2e868 100644 --- a/lang/zh-tw.yml +++ b/lang/zh-tw.yml @@ -553,3 +553,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lang/zh.yml b/lang/zh.yml index c758f5490..05134751f 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -556,3 +556,7 @@ field_searchable: Searchable label_display_per_page: 'Per page: %s' setting_per_page_options: Objects per page options label_age: Age +notice_default_data_loaded: Default configuration successfully loaded. +text_load_default_configuration: Load the default configuration +text_no_configuration_data: "Roles, trackers, issue statuses and workflow have not been configured yet.\nIt is highly recommended to load the default configuration. You will be able to modify it once loaded." +error_can_t_load_default_data: "Default configuration could not be loaded: %s" diff --git a/lib/redmine/default_data/loader.rb b/lib/redmine/default_data/loader.rb index 105219104..0abb5572a 100644 --- a/lib/redmine/default_data/loader.rb +++ b/lib/redmine/default_data/loader.rb @@ -38,19 +38,41 @@ module Redmine raise DataAlreadyLoaded.new("Some configuration data is already loaded.") unless no_data? set_language_if_valid(lang) - # Roles - manager = Role.create! :name => l(:default_role_manager), - :position => 1 - manager.permissions = manager.setable_permissions.collect {|p| p.name} - manager.save! - - developper = Role.create! :name => l(:default_role_developper), - :position => 2, - :permissions => [:manage_versions, - :manage_categories, - :add_issues, - :edit_issues, - :manage_issue_relations, + Role.transaction do + # Roles + manager = Role.create! :name => l(:default_role_manager), + :position => 1 + manager.permissions = manager.setable_permissions.collect {|p| p.name} + manager.save! + + developper = Role.create! :name => l(:default_role_developper), + :position => 2, + :permissions => [:manage_versions, + :manage_categories, + :add_issues, + :edit_issues, + :manage_issue_relations, + :add_issue_notes, + :change_issue_status, + :save_queries, + :view_gantt, + :view_calendar, + :log_time, + :view_time_entries, + :comment_news, + :view_documents, + :view_wiki_pages, + :edit_wiki_pages, + :delete_wiki_pages, + :add_messages, + :view_files, + :manage_files, + :browse_repository, + :view_changesets] + + reporter = Role.create! :name => l(:default_role_reporter), + :position => 3, + :permissions => [:add_issues, :add_issue_notes, :change_issue_status, :save_queries, @@ -61,108 +83,87 @@ module Redmine :comment_news, :view_documents, :view_wiki_pages, - :edit_wiki_pages, - :delete_wiki_pages, :add_messages, :view_files, - :manage_files, :browse_repository, :view_changesets] + + Role.non_member.update_attribute :permissions, [:add_issues, + :add_issue_notes, + :change_issue_status, + :save_queries, + :view_gantt, + :view_calendar, + :view_time_entries, + :comment_news, + :view_documents, + :view_wiki_pages, + :add_messages, + :view_files, + :browse_repository, + :view_changesets] - reporter = Role.create! :name => l(:default_role_reporter), - :position => 3, - :permissions => [:add_issues, - :add_issue_notes, - :change_issue_status, - :save_queries, - :view_gantt, - :view_calendar, - :log_time, - :view_time_entries, - :comment_news, - :view_documents, - :view_wiki_pages, - :add_messages, - :view_files, - :browse_repository, - :view_changesets] - - Role.non_member.update_attribute :permissions, [:add_issues, - :add_issue_notes, - :change_issue_status, - :save_queries, - :view_gantt, - :view_calendar, - :view_time_entries, - :comment_news, - :view_documents, - :view_wiki_pages, - :add_messages, - :view_files, - :browse_repository, - :view_changesets] - - Role.anonymous.update_attribute :permissions, [:view_gantt, - :view_calendar, - :view_time_entries, - :view_documents, - :view_wiki_pages, - :view_files, - :browse_repository, - :view_changesets] - - # Trackers - Tracker.create!(:name => l(:default_tracker_bug), :is_in_chlog => true, :is_in_roadmap => false, :position => 1) - Tracker.create!(:name => l(:default_tracker_feature), :is_in_chlog => true, :is_in_roadmap => true, :position => 2) - Tracker.create!(:name => l(:default_tracker_support), :is_in_chlog => false, :is_in_roadmap => false, :position => 3) - - # Issue statuses - new = IssueStatus.create!(:name => l(:default_issue_status_new), :is_closed => false, :is_default => true, :position => 1) - assigned = IssueStatus.create!(:name => l(:default_issue_status_assigned), :is_closed => false, :is_default => false, :position => 2) - resolved = IssueStatus.create!(:name => l(:default_issue_status_resolved), :is_closed => false, :is_default => false, :position => 3) - feedback = IssueStatus.create!(:name => l(:default_issue_status_feedback), :is_closed => false, :is_default => false, :position => 4) - closed = IssueStatus.create!(:name => l(:default_issue_status_closed), :is_closed => true, :is_default => false, :position => 5) - rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6) - - # Workflow - Tracker.find(:all).each { |t| - IssueStatus.find(:all).each { |os| - IssueStatus.find(:all).each { |ns| - Workflow.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns - } - } - } + Role.anonymous.update_attribute :permissions, [:view_gantt, + :view_calendar, + :view_time_entries, + :view_documents, + :view_wiki_pages, + :view_files, + :browse_repository, + :view_changesets] + + # Trackers + Tracker.create!(:name => l(:default_tracker_bug), :is_in_chlog => true, :is_in_roadmap => false, :position => 1) + Tracker.create!(:name => l(:default_tracker_feature), :is_in_chlog => true, :is_in_roadmap => true, :position => 2) + Tracker.create!(:name => l(:default_tracker_support), :is_in_chlog => false, :is_in_roadmap => false, :position => 3) + + # Issue statuses + new = IssueStatus.create!(:name => l(:default_issue_status_new), :is_closed => false, :is_default => true, :position => 1) + assigned = IssueStatus.create!(:name => l(:default_issue_status_assigned), :is_closed => false, :is_default => false, :position => 2) + resolved = IssueStatus.create!(:name => l(:default_issue_status_resolved), :is_closed => false, :is_default => false, :position => 3) + feedback = IssueStatus.create!(:name => l(:default_issue_status_feedback), :is_closed => false, :is_default => false, :position => 4) + closed = IssueStatus.create!(:name => l(:default_issue_status_closed), :is_closed => true, :is_default => false, :position => 5) + rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6) + + # Workflow + Tracker.find(:all).each { |t| + IssueStatus.find(:all).each { |os| + IssueStatus.find(:all).each { |ns| + Workflow.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns + } + } + } + + Tracker.find(:all).each { |t| + [new, assigned, resolved, feedback].each { |os| + [assigned, resolved, feedback, closed].each { |ns| + Workflow.create!(:tracker_id => t.id, :role_id => developper.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns + } + } + } + + Tracker.find(:all).each { |t| + [new, assigned, resolved, feedback].each { |os| + [closed].each { |ns| + Workflow.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns + } + } + Workflow.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => resolved.id, :new_status_id => feedback.id) + } - Tracker.find(:all).each { |t| - [new, assigned, resolved, feedback].each { |os| - [assigned, resolved, feedback, closed].each { |ns| - Workflow.create!(:tracker_id => t.id, :role_id => developper.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns - } - } - } + # Enumerations + Enumeration.create!(:opt => "DCAT", :name => l(:default_doc_category_user), :position => 1) + Enumeration.create!(:opt => "DCAT", :name => l(:default_doc_category_tech), :position => 2) - Tracker.find(:all).each { |t| - [new, assigned, resolved, feedback].each { |os| - [closed].each { |ns| - Workflow.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns - } - } - Workflow.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => resolved.id, :new_status_id => feedback.id) - } - - # Enumerations - Enumeration.create!(:opt => "DCAT", :name => l(:default_doc_category_user), :position => 1) - Enumeration.create!(:opt => "DCAT", :name => l(:default_doc_category_tech), :position => 2) - - Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_low), :position => 1) - Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_normal), :position => 2, :is_default => true) - Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_high), :position => 3) - Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_urgent), :position => 4) - Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_immediate), :position => 5) - - Enumeration.create!(:opt => "ACTI", :name => l(:default_activity_design), :position => 1) - Enumeration.create!(:opt => "ACTI", :name => l(:default_activity_development), :position => 2) + Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_low), :position => 1) + Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_normal), :position => 2, :is_default => true) + Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_high), :position => 3) + Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_urgent), :position => 4) + Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_immediate), :position => 5) + Enumeration.create!(:opt => "ACTI", :name => l(:default_activity_design), :position => 1) + Enumeration.create!(:opt => "ACTI", :name => l(:default_activity_development), :position => 2) + end true end end diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb index d49fe2dda..742c1f6bb 100644 --- a/test/functional/admin_controller_test.rb +++ b/test/functional/admin_controller_test.rb @@ -22,7 +22,7 @@ require 'admin_controller' class AdminController; def rescue_action(e) raise e end; end class AdminControllerTest < Test::Unit::TestCase - fixtures :projects, :users + fixtures :projects, :users, :roles def setup @controller = AdminController.new @@ -32,6 +32,25 @@ class AdminControllerTest < Test::Unit::TestCase @request.session[:user_id] = 1 # admin end + def test_index + get :index + assert_no_tag :tag => 'div', + :attributes => { :class => /nodata/ } + end + + def test_index_with_no_configuration_data + delete_configuration_data + get :index + assert_tag :tag => 'div', + :attributes => { :class => /nodata/ } + end + + def test_load_default_configuration_data + delete_configuration_data + post :default_configuration, :lang => 'fr' + assert IssueStatus.find_by_name('Nouveau') + end + def test_get_mail_options get :mail_options assert_response :success @@ -58,4 +77,11 @@ class AdminControllerTest < Test::Unit::TestCase assert_response :success assert_template 'info' end + + def delete_configuration_data + Role.delete_all('builtin = 0') + Tracker.delete_all + IssueStatus.delete_all + Enumeration.delete_all + end end |