@@ -45,12 +45,8 class RepositoriesController < ApplicationController | |||||
45 | end |
|
45 | end | |
46 |
|
46 | |||
47 | def create |
|
47 | def create | |
48 | attrs = pickup_extra_info |
|
|||
49 | @repository = Repository.factory(params[:repository_scm]) |
|
48 | @repository = Repository.factory(params[:repository_scm]) | |
50 | @repository.safe_attributes = params[:repository] |
|
49 | @repository.safe_attributes = params[:repository] | |
51 | if attrs[:attrs_extra].keys.any? |
|
|||
52 | @repository.merge_extra_info(attrs[:attrs_extra]) |
|
|||
53 | end |
|
|||
54 | @repository.project = @project |
|
50 | @repository.project = @project | |
55 | if request.post? && @repository.save |
|
51 | if request.post? && @repository.save | |
56 | redirect_to settings_project_path(@project, :tab => 'repositories') |
|
52 | redirect_to settings_project_path(@project, :tab => 'repositories') | |
@@ -63,11 +59,7 class RepositoriesController < ApplicationController | |||||
63 | end |
|
59 | end | |
64 |
|
60 | |||
65 | def update |
|
61 | def update | |
66 | attrs = pickup_extra_info |
|
62 | @repository.safe_attributes = params[:repository] | |
67 | @repository.safe_attributes = attrs[:attrs] |
|
|||
68 | if attrs[:attrs_extra].keys.any? |
|
|||
69 | @repository.merge_extra_info(attrs[:attrs_extra]) |
|
|||
70 | end |
|
|||
71 | @repository.project = @project |
|
63 | @repository.project = @project | |
72 | if @repository.save |
|
64 | if @repository.save | |
73 | redirect_to settings_project_path(@project, :tab => 'repositories') |
|
65 | redirect_to settings_project_path(@project, :tab => 'repositories') | |
@@ -76,20 +68,6 class RepositoriesController < ApplicationController | |||||
76 | end |
|
68 | end | |
77 | end |
|
69 | end | |
78 |
|
70 | |||
79 | def pickup_extra_info |
|
|||
80 | p = {} |
|
|||
81 | p_extra = {} |
|
|||
82 | params[:repository].each do |k, v| |
|
|||
83 | if k =~ /^extra_/ |
|
|||
84 | p_extra[k] = v |
|
|||
85 | else |
|
|||
86 | p[k] = v |
|
|||
87 | end |
|
|||
88 | end |
|
|||
89 | {:attrs => p, :attrs_extra => p_extra} |
|
|||
90 | end |
|
|||
91 | private :pickup_extra_info |
|
|||
92 |
|
||||
93 | def committers |
|
71 | def committers | |
94 | @committers = @repository.committers |
|
72 | @committers = @repository.committers | |
95 | @users = @project.users.to_a |
|
73 | @users = @project.users.to_a |
@@ -185,7 +185,7 module RepositoriesHelper | |||||
185 | scm_path_info_tag(repository)) + |
|
185 | scm_path_info_tag(repository)) + | |
186 | scm_path_encoding_tag(form, repository) + |
|
186 | scm_path_encoding_tag(form, repository) + | |
187 | content_tag('p', form.check_box( |
|
187 | content_tag('p', form.check_box( | |
188 |
: |
|
188 | :report_last_commit, | |
189 | :label => l(:label_git_report_last_commit) |
|
189 | :label => l(:label_git_report_last_commit) | |
190 | )) |
|
190 | )) | |
191 | end |
|
191 | end |
@@ -22,6 +22,8 class Repository::Git < Repository | |||||
22 | attr_protected :root_url |
|
22 | attr_protected :root_url | |
23 | validates_presence_of :url |
|
23 | validates_presence_of :url | |
24 |
|
24 | |||
|
25 | safe_attributes 'report_last_commit' | |||
|
26 | ||||
25 | def self.human_attribute_name(attribute_key_name, *args) |
|
27 | def self.human_attribute_name(attribute_key_name, *args) | |
26 | attr_name = attribute_key_name.to_s |
|
28 | attr_name = attribute_key_name.to_s | |
27 | if attr_name == "url" |
|
29 | if attr_name == "url" | |
@@ -39,15 +41,15 class Repository::Git < Repository | |||||
39 | end |
|
41 | end | |
40 |
|
42 | |||
41 | def report_last_commit |
|
43 | def report_last_commit | |
42 | extra_report_last_commit |
|
|||
43 | end |
|
|||
44 |
|
||||
45 | def extra_report_last_commit |
|
|||
46 | return false if extra_info.nil? |
|
44 | return false if extra_info.nil? | |
47 | v = extra_info["extra_report_last_commit"] |
|
45 | v = extra_info["extra_report_last_commit"] | |
48 | return false if v.nil? |
|
46 | return false if v.nil? | |
49 | v.to_s != '0' |
|
47 | v.to_s != '0' | |
50 | end |
|
48 | end | |
|
49 | ||||
|
50 | def report_last_commit=(arg) | |||
|
51 | merge_extra_info "extra_report_last_commit" => arg | |||
|
52 | end | |||
51 |
|
53 | |||
52 | def supports_directory_revisions? |
|
54 | def supports_directory_revisions? | |
53 | true |
|
55 | true | |
@@ -94,7 +96,7 class Repository::Git < Repository | |||||
94 | end |
|
96 | end | |
95 |
|
97 | |||
96 | def scm_entries(path=nil, identifier=nil) |
|
98 | def scm_entries(path=nil, identifier=nil) | |
97 |
scm.entries(path, identifier, :report_last_commit => |
|
99 | scm.entries(path, identifier, :report_last_commit => report_last_commit) | |
98 | end |
|
100 | end | |
99 | protected :scm_entries |
|
101 | protected :scm_entries | |
100 |
|
102 |
@@ -49,6 +49,16 class RepositoriesControllerTest < Redmine::ControllerTest | |||||
49 | assert_select 'option[value=Git]:not([selected])' |
|
49 | assert_select 'option[value=Git]:not([selected])' | |
50 | end |
|
50 | end | |
51 | end |
|
51 | end | |
|
52 | ||||
|
53 | def test_get_new_with_type | |||
|
54 | @request.session[:user_id] = 1 | |||
|
55 | get :new, :project_id => 'subproject1', :repository_scm => 'Git' | |||
|
56 | assert_response :success | |||
|
57 | ||||
|
58 | assert_select 'select[name=?]', 'repository_scm' do | |||
|
59 | assert_select 'option[value=?][selected=selected]', 'Git' | |||
|
60 | end | |||
|
61 | end | |||
52 |
|
62 | |||
53 | def test_create |
|
63 | def test_create | |
54 | @request.session[:user_id] = 1 |
|
64 | @request.session[:user_id] = 1 |
@@ -60,22 +60,22 class RepositoriesGitControllerTest < Redmine::ControllerTest | |||||
60 | :url => '/test', |
|
60 | :url => '/test', | |
61 | :is_default => '0', |
|
61 | :is_default => '0', | |
62 | :identifier => 'test-create', |
|
62 | :identifier => 'test-create', | |
63 |
: |
|
63 | :report_last_commit => '1', | |
64 | } |
|
64 | } | |
65 | end |
|
65 | end | |
66 | assert_response 302 |
|
66 | assert_response 302 | |
67 | repository = Repository.order('id DESC').first |
|
67 | repository = Repository.order('id DESC').first | |
68 | assert_kind_of Repository::Git, repository |
|
68 | assert_kind_of Repository::Git, repository | |
69 | assert_equal '/test', repository.url |
|
69 | assert_equal '/test', repository.url | |
70 |
assert_equal true, repository. |
|
70 | assert_equal true, repository.report_last_commit | |
71 |
|
71 | |||
72 | put :update, :id => repository.id, |
|
72 | put :update, :id => repository.id, | |
73 | :repository => { |
|
73 | :repository => { | |
74 |
|
|
74 | :report_last_commit => '0' | |
75 | } |
|
75 | } | |
76 | assert_response 302 |
|
76 | assert_response 302 | |
77 | repo2 = Repository.find(repository.id) |
|
77 | repo2 = Repository.find(repository.id) | |
78 |
assert_equal false, repo2. |
|
78 | assert_equal false, repo2.report_last_commit | |
79 | end |
|
79 | end | |
80 |
|
80 | |||
81 | if File.directory?(REPOSITORY_PATH) |
|
81 | if File.directory?(REPOSITORY_PATH) |
@@ -243,22 +243,13 class RepositoryGitTest < ActiveSupport::TestCase | |||||
243 | assert_equal h1, h2 |
|
243 | assert_equal h1, h2 | |
244 | end |
|
244 | end | |
245 |
|
245 | |||
246 | def test_keep_extra_report_last_commit_in_clear_changesets |
|
246 | def test_clear_changesets_should_keep_report_last_commit | |
247 | assert_nil @repository.extra_info |
|
247 | assert_nil @repository.extra_info | |
248 | h = {} |
|
248 | @repository.report_last_commit = "1" | |
249 | h["extra_report_last_commit"] = "1" |
|
|||
250 | @repository.merge_extra_info(h) |
|
|||
251 | @repository.save |
|
249 | @repository.save | |
252 | @project.reload |
|
|||
253 |
|
||||
254 | assert_equal 0, @repository.changesets.count |
|
|||
255 | @repository.fetch_changesets |
|
|||
256 | @project.reload |
|
|||
257 |
|
||||
258 | assert_equal NUM_REV, @repository.changesets.count |
|
|||
259 | @repository.send(:clear_changesets) |
|
250 | @repository.send(:clear_changesets) | |
260 | assert_equal 1, @repository.extra_info.size |
|
251 | ||
261 |
assert_equal |
|
252 | assert_equal true, @repository.report_last_commit | |
262 | end |
|
253 | end | |
263 |
|
254 | |||
264 | def test_refetch_after_clear_changesets |
|
255 | def test_refetch_after_clear_changesets |
General Comments 0
You need to be logged in to leave comments.
Login now