@@ -21,8 +21,8 class IssueRelationsController < ApplicationController | |||||
21 | def new |
|
21 | def new | |
22 | @relation = IssueRelation.new(params[:relation]) |
|
22 | @relation = IssueRelation.new(params[:relation]) | |
23 | @relation.issue_from = @issue |
|
23 | @relation.issue_from = @issue | |
24 |
if params[:relation] && |
|
24 | if params[:relation] && m = params[:relation][:issue_to_id].to_s.match(/^#?(\d+)$/) | |
25 |
@relation.issue_to = Issue.visible.find_by_id( |
|
25 | @relation.issue_to = Issue.visible.find_by_id(m[1].to_i) | |
26 | end |
|
26 | end | |
27 | @relation.save if request.post? |
|
27 | @relation.save if request.post? | |
28 | respond_to do |format| |
|
28 | respond_to do |format| |
@@ -512,11 +512,23 class Project < ActiveRecord::Base | |||||
512 | unless project.wiki.nil? |
|
512 | unless project.wiki.nil? | |
513 | self.wiki ||= Wiki.new |
|
513 | self.wiki ||= Wiki.new | |
514 | wiki.attributes = project.wiki.attributes.dup.except("id", "project_id") |
|
514 | wiki.attributes = project.wiki.attributes.dup.except("id", "project_id") | |
|
515 | wiki_pages_map = {} | |||
515 | project.wiki.pages.each do |page| |
|
516 | project.wiki.pages.each do |page| | |
|
517 | # Skip pages without content | |||
|
518 | next if page.content.nil? | |||
516 | new_wiki_content = WikiContent.new(page.content.attributes.dup.except("id", "page_id", "updated_on")) |
|
519 | new_wiki_content = WikiContent.new(page.content.attributes.dup.except("id", "page_id", "updated_on")) | |
517 | new_wiki_page = WikiPage.new(page.attributes.dup.except("id", "wiki_id", "created_on", "parent_id")) |
|
520 | new_wiki_page = WikiPage.new(page.attributes.dup.except("id", "wiki_id", "created_on", "parent_id")) | |
518 | new_wiki_page.content = new_wiki_content |
|
521 | new_wiki_page.content = new_wiki_content | |
519 | wiki.pages << new_wiki_page |
|
522 | wiki.pages << new_wiki_page | |
|
523 | wiki_pages_map[page.id] = new_wiki_page | |||
|
524 | end | |||
|
525 | wiki.save | |||
|
526 | # Reproduce page hierarchy | |||
|
527 | project.wiki.pages.each do |page| | |||
|
528 | if page.parent_id && wiki_pages_map[page.id] | |||
|
529 | wiki_pages_map[page.id].parent = wiki_pages_map[page.parent_id] | |||
|
530 | wiki_pages_map[page.id].save | |||
|
531 | end | |||
520 | end |
|
532 | end | |
521 | end |
|
533 | end | |
522 | end |
|
534 | end |
@@ -728,6 +728,7 background-image:url('../images/close_hl.png'); | |||||
728 | padding:0; |
|
728 | padding:0; | |
729 | margin:0; |
|
729 | margin:0; | |
730 | line-height:0.8em; |
|
730 | line-height:0.8em; | |
|
731 | white-space:nowrap; | |||
731 | } |
|
732 | } | |
732 |
|
733 | |||
733 | .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; } |
|
734 | .task_late { background:#f66 url(../images/task_late.png); border: 1px solid #f66; } |
@@ -71,4 +71,28 wiki_contents_006: | |||||
71 | version: 1 |
|
71 | version: 1 | |
72 | author_id: 1 |
|
72 | author_id: 1 | |
73 | comments: |
|
73 | comments: | |
|
74 | wiki_contents_007: | |||
|
75 | text: This is a child page | |||
|
76 | updated_on: 2007-03-08 00:18:07 +01:00 | |||
|
77 | page_id: 7 | |||
|
78 | id: 7 | |||
|
79 | version: 1 | |||
|
80 | author_id: 1 | |||
|
81 | comments: | |||
|
82 | wiki_contents_008: | |||
|
83 | text: This is a parent page | |||
|
84 | updated_on: 2007-03-08 00:18:07 +01:00 | |||
|
85 | page_id: 8 | |||
|
86 | id: 8 | |||
|
87 | version: 1 | |||
|
88 | author_id: 1 | |||
|
89 | comments: | |||
|
90 | wiki_contents_009: | |||
|
91 | text: This is a child page | |||
|
92 | updated_on: 2007-03-08 00:18:07 +01:00 | |||
|
93 | page_id: 9 | |||
|
94 | id: 9 | |||
|
95 | version: 1 | |||
|
96 | author_id: 1 | |||
|
97 | comments: | |||
74 | No newline at end of file |
|
98 |
@@ -41,4 +41,25 wiki_pages_006: | |||||
41 | wiki_id: 1 |
|
41 | wiki_id: 1 | |
42 | protected: false |
|
42 | protected: false | |
43 | parent_id: 2 |
|
43 | parent_id: 2 | |
|
44 | wiki_pages_007: | |||
|
45 | created_on: 2007-03-08 00:18:07 +01:00 | |||
|
46 | title: Child_page_1 | |||
|
47 | id: 7 | |||
|
48 | wiki_id: 2 | |||
|
49 | protected: false | |||
|
50 | parent_id: 8 | |||
|
51 | wiki_pages_008: | |||
|
52 | created_on: 2007-03-08 00:18:07 +01:00 | |||
|
53 | title: Parent_page | |||
|
54 | id: 8 | |||
|
55 | wiki_id: 2 | |||
|
56 | protected: false | |||
|
57 | parent_id: | |||
|
58 | wiki_pages_009: | |||
|
59 | created_on: 2007-03-08 00:18:07 +01:00 | |||
|
60 | title: Child_page_2 | |||
|
61 | id: 9 | |||
|
62 | wiki_id: 2 | |||
|
63 | protected: false | |||
|
64 | parent_id: 8 | |||
44 | No newline at end of file |
|
65 |
@@ -40,6 +40,24 class IssueRelationsControllerTest < ActionController::TestCase | |||||
40 | end |
|
40 | end | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
|
43 | def test_new_should_accept_id_with_hash | |||
|
44 | assert_difference 'IssueRelation.count' do | |||
|
45 | @request.session[:user_id] = 3 | |||
|
46 | post :new, :issue_id => 1, | |||
|
47 | :relation => {:issue_to_id => '#2', :relation_type => 'relates', :delay => ''} | |||
|
48 | end | |||
|
49 | end | |||
|
50 | ||||
|
51 | def test_new_should_not_break_with_non_numerical_id | |||
|
52 | assert_no_difference 'IssueRelation.count' do | |||
|
53 | assert_nothing_raised do | |||
|
54 | @request.session[:user_id] = 3 | |||
|
55 | post :new, :issue_id => 1, | |||
|
56 | :relation => {:issue_to_id => 'foo', :relation_type => 'relates', :delay => ''} | |||
|
57 | end | |||
|
58 | end | |||
|
59 | end | |||
|
60 | ||||
43 | def test_should_create_relations_with_visible_issues_only |
|
61 | def test_should_create_relations_with_visible_issues_only | |
44 | Setting.cross_project_issue_relations = '1' |
|
62 | Setting.cross_project_issue_relations = '1' | |
45 | assert_nil Issue.visible(User.find(3)).find_by_id(4) |
|
63 | assert_nil Issue.visible(User.find(3)).find_by_id(4) |
@@ -723,16 +723,24 class ProjectTest < ActiveSupport::TestCase | |||||
723 | assert_equal "Start page", @project.wiki.start_page |
|
723 | assert_equal "Start page", @project.wiki.start_page | |
724 | end |
|
724 | end | |
725 |
|
725 | |||
726 | should "copy wiki pages and content" do |
|
726 | should "copy wiki pages and content with hierarchy" do | |
727 | assert @project.copy(@source_project) |
|
727 | assert_difference 'WikiPage.count', @source_project.wiki.pages.size do | |
728 |
|
728 | assert @project.copy(@source_project) | ||
|
729 | end | |||
|
730 | ||||
729 | assert @project.wiki |
|
731 | assert @project.wiki | |
730 |
assert_equal |
|
732 | assert_equal @source_project.wiki.pages.size, @project.wiki.pages.size | |
731 |
|
733 | |||
732 | @project.wiki.pages.each do |wiki_page| |
|
734 | @project.wiki.pages.each do |wiki_page| | |
733 | assert wiki_page.content |
|
735 | assert wiki_page.content | |
734 | assert !@source_project.wiki.pages.include?(wiki_page) |
|
736 | assert !@source_project.wiki.pages.include?(wiki_page) | |
735 | end |
|
737 | end | |
|
738 | ||||
|
739 | parent = @project.wiki.find_page('Parent_page') | |||
|
740 | child1 = @project.wiki.find_page('Child_page_1') | |||
|
741 | child2 = @project.wiki.find_page('Child_page_2') | |||
|
742 | assert_equal parent, child1.parent | |||
|
743 | assert_equal parent, child2.parent | |||
736 | end |
|
744 | end | |
737 |
|
745 | |||
738 | should "copy issue categories" do |
|
746 | should "copy issue categories" do |
General Comments 0
You need to be logged in to leave comments.
Login now