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