Project

General

Profile

Patch #15906 » create_general_forum_by_default_v2.patch

Jean-Baptiste Barth, 2014-09-06 06:11

View differences:

app/models/enabled_module.rb
29 29
  # after_create callback used to do things when a module is enabled
30 30
  def module_enabled
31 31
    case name
32
    when 'boards'
33
      # Create general discussion board
34
      if project && project.boards.none?
35
        Board.create(:project => project, :name => l(:label_general), :description => l(:label_general_discussion))
36
      end
32 37
    when 'wiki'
33 38
      # Create a wiki with a default start page
34 39
      if project && project.wiki.nil?
config/locales/de.yml
544 544
  label_gantt: Gantt-Diagramm
545 545
  label_gantt_progress_line: Fortschrittslinie
546 546
  label_general: Allgemein
547
  label_general_discussion: Diskussion über allgemeine Themen
547 548
  label_generate_key: Generieren
548 549
  label_git_report_last_commit: Bericht des letzten Commits für Dateien und Verzeichnisse
549 550
  label_greater_or_equal: ">="
config/locales/en-GB.yml
757 757
  label_age: Age
758 758
  label_change_properties: Change properties
759 759
  label_general: General
760
  label_general_discussion: Discussion about general topics
760 761
  label_more: More
761 762
  label_scm: SCM
762 763
  label_plugins: Plugins
config/locales/en.yml
826 826
  label_age: Age
827 827
  label_change_properties: Change properties
828 828
  label_general: General
829
  label_general_discussion: Discussion about general topics
829 830
  label_more: More
830 831
  label_scm: SCM
831 832
  label_plugins: Plugins
config/locales/fr.yml
846 846
  label_age: Âge
847 847
  label_change_properties: Changer les propriétés
848 848
  label_general: Général
849
  label_general_discussion: Discussion générale
849 850
  label_more: Plus
850 851
  label_scm: SCM
851 852
  label_plugins: Plugins
test/unit/enabled_module_test.rb
18 18
require File.expand_path('../../test_helper', __FILE__)
19 19

  
20 20
class EnabledModuleTest < ActiveSupport::TestCase
21
  fixtures :projects, :wikis
21
  fixtures :projects, :wikis, :boards
22 22

  
23 23
  def test_enabling_wiki_should_create_a_wiki
24 24
    CustomField.delete_all
......
40 40
    end
41 41
    assert_not_nil project.wiki
42 42
  end
43

  
44
  def test_creating_a_project_with_board_modules_should_create_a_new_board
45
    project = Project.create!(:name => 'Project with boards', :identifier => 'boardsproject', :enabled_module_names => ['boards'])
46
    assert_equal 1, project.boards.count
47
    assert_equal 'General', project.boards.first.name
48
  end
49

  
50
  def test_enabling_boards_should_create_a_new_board
51
    project = Project.create!(:name => 'Project with boards', :identifier => 'boardsproject', :enabled_module_names => [])
52
    assert_equal 0, project.boards.count
53
    assert_difference 'project.boards.count', +1 do
54
      project.enabled_module_names = ['boards']
55
    end
56
    assert_equal 'General', project.boards.first.name
57
  end
58

  
59
  def test_reenabling_boards_should_not_create_another_board
60
    project = Project.find(1)
61
    assert project.boards.count > 0
62
    project.enabled_module_names = []
63
    assert_no_difference 'project.boards.count' do
64
      project.enabled_module_names = ['boards']
65
    end
66
  end
43 67
end
(2-2/2)