##// END OF EJS Templates
Limit the size of repository files displayed inline too....
Jean-Philippe Lang -
r2442:1c5a2ddfb07c
parent child
Show More
@@ -1,327 +1,327
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require 'SVG/Graph/Bar'
19 19 require 'SVG/Graph/BarHorizontal'
20 20 require 'digest/sha1'
21 21
22 22 class ChangesetNotFound < Exception; end
23 23 class InvalidRevisionParam < Exception; end
24 24
25 25 class RepositoriesController < ApplicationController
26 26 menu_item :repository
27 27 before_filter :find_repository, :except => :edit
28 28 before_filter :find_project, :only => :edit
29 29 before_filter :authorize
30 30 accept_key_auth :revisions
31 31
32 32 rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed
33 33
34 34 def edit
35 35 @repository = @project.repository
36 36 if !@repository
37 37 @repository = Repository.factory(params[:repository_scm])
38 38 @repository.project = @project if @repository
39 39 end
40 40 if request.post? && @repository
41 41 @repository.attributes = params[:repository]
42 42 @repository.save
43 43 end
44 44 render(:update) {|page| page.replace_html "tab-content-repository", :partial => 'projects/settings/repository'}
45 45 end
46 46
47 47 def committers
48 48 @committers = @repository.committers
49 49 @users = @project.users
50 50 additional_user_ids = @committers.collect(&:last).collect(&:to_i) - @users.collect(&:id)
51 51 @users += User.find_all_by_id(additional_user_ids) unless additional_user_ids.empty?
52 52 @users.compact!
53 53 @users.sort!
54 54 if request.post? && params[:committers].is_a?(Hash)
55 55 # Build a hash with repository usernames as keys and corresponding user ids as values
56 56 @repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h}
57 57 flash[:notice] = l(:notice_successful_update)
58 58 redirect_to :action => 'committers', :id => @project
59 59 end
60 60 end
61 61
62 62 def destroy
63 63 @repository.destroy
64 64 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'repository'
65 65 end
66 66
67 67 def show
68 68 # check if new revisions have been committed in the repository
69 69 @repository.fetch_changesets if Setting.autofetch_changesets?
70 70 # root entries
71 71 @entries = @repository.entries('', @rev)
72 72 # latest changesets
73 73 @changesets = @repository.changesets.find(:all, :limit => 10, :order => "committed_on DESC")
74 74 show_error_not_found unless @entries || @changesets.any?
75 75 end
76 76
77 77 def browse
78 78 @entries = @repository.entries(@path, @rev)
79 79 if request.xhr?
80 80 @entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
81 81 else
82 82 show_error_not_found and return unless @entries
83 83 @properties = @repository.properties(@path, @rev)
84 84 render :action => 'browse'
85 85 end
86 86 end
87 87
88 88 def changes
89 89 @entry = @repository.entry(@path, @rev)
90 90 show_error_not_found and return unless @entry
91 91 @changesets = @repository.changesets_for_path(@path, :limit => Setting.repository_log_display_limit.to_i)
92 92 @properties = @repository.properties(@path, @rev)
93 93 end
94 94
95 95 def revisions
96 96 @changeset_count = @repository.changesets.count
97 97 @changeset_pages = Paginator.new self, @changeset_count,
98 98 per_page_option,
99 99 params['page']
100 100 @changesets = @repository.changesets.find(:all,
101 101 :limit => @changeset_pages.items_per_page,
102 102 :offset => @changeset_pages.current.offset,
103 103 :include => :user)
104 104
105 105 respond_to do |format|
106 106 format.html { render :layout => false if request.xhr? }
107 107 format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") }
108 108 end
109 109 end
110 110
111 111 def entry
112 112 @entry = @repository.entry(@path, @rev)
113 113 show_error_not_found and return unless @entry
114 114
115 115 # If the entry is a dir, show the browser
116 116 browse and return if @entry.is_dir?
117 117
118 118 @content = @repository.cat(@path, @rev)
119 119 show_error_not_found and return unless @content
120 if 'raw' == params[:format] || @content.is_binary_data?
121 # Force the download if it's a binary file
120 if 'raw' == params[:format] || @content.is_binary_data? || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte)
121 # Force the download
122 122 send_data @content, :filename => @path.split('/').last
123 123 else
124 124 # Prevent empty lines when displaying a file with Windows style eol
125 125 @content.gsub!("\r\n", "\n")
126 126 end
127 127 end
128 128
129 129 def annotate
130 130 @entry = @repository.entry(@path, @rev)
131 131 show_error_not_found and return unless @entry
132 132
133 133 @annotate = @repository.scm.annotate(@path, @rev)
134 134 render_error l(:error_scm_annotate) and return if @annotate.nil? || @annotate.empty?
135 135 end
136 136
137 137 def revision
138 138 @changeset = @repository.changesets.find_by_revision(@rev)
139 139 raise ChangesetNotFound unless @changeset
140 140
141 141 respond_to do |format|
142 142 format.html
143 143 format.js {render :layout => false}
144 144 end
145 145 rescue ChangesetNotFound
146 146 show_error_not_found
147 147 end
148 148
149 149 def diff
150 150 if params[:format] == 'diff'
151 151 @diff = @repository.diff(@path, @rev, @rev_to)
152 152 show_error_not_found and return unless @diff
153 153 filename = "changeset_r#{@rev}"
154 154 filename << "_r#{@rev_to}" if @rev_to
155 155 send_data @diff.join, :filename => "#{filename}.diff",
156 156 :type => 'text/x-patch',
157 157 :disposition => 'attachment'
158 158 else
159 159 @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
160 160 @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
161 161
162 162 # Save diff type as user preference
163 163 if User.current.logged? && @diff_type != User.current.pref[:diff_type]
164 164 User.current.pref[:diff_type] = @diff_type
165 165 User.current.preference.save
166 166 end
167 167
168 168 @cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")
169 169 unless read_fragment(@cache_key)
170 170 @diff = @repository.diff(@path, @rev, @rev_to)
171 171 show_error_not_found unless @diff
172 172 end
173 173 end
174 174 end
175 175
176 176 def stats
177 177 end
178 178
179 179 def graph
180 180 data = nil
181 181 case params[:graph]
182 182 when "commits_per_month"
183 183 data = graph_commits_per_month(@repository)
184 184 when "commits_per_author"
185 185 data = graph_commits_per_author(@repository)
186 186 end
187 187 if data
188 188 headers["Content-Type"] = "image/svg+xml"
189 189 send_data(data, :type => "image/svg+xml", :disposition => "inline")
190 190 else
191 191 render_404
192 192 end
193 193 end
194 194
195 195 private
196 196 def find_project
197 197 @project = Project.find(params[:id])
198 198 rescue ActiveRecord::RecordNotFound
199 199 render_404
200 200 end
201 201
202 202 REV_PARAM_RE = %r{^[a-f0-9]*$}
203 203
204 204 def find_repository
205 205 @project = Project.find(params[:id])
206 206 @repository = @project.repository
207 207 render_404 and return false unless @repository
208 208 @path = params[:path].join('/') unless params[:path].nil?
209 209 @path ||= ''
210 210 @rev = params[:rev]
211 211 @rev_to = params[:rev_to]
212 212 raise InvalidRevisionParam unless @rev.to_s.match(REV_PARAM_RE) && @rev.to_s.match(REV_PARAM_RE)
213 213 rescue ActiveRecord::RecordNotFound
214 214 render_404
215 215 rescue InvalidRevisionParam
216 216 show_error_not_found
217 217 end
218 218
219 219 def show_error_not_found
220 220 render_error l(:error_scm_not_found)
221 221 end
222 222
223 223 # Handler for Redmine::Scm::Adapters::CommandFailed exception
224 224 def show_error_command_failed(exception)
225 225 render_error l(:error_scm_command_failed, exception.message)
226 226 end
227 227
228 228 def graph_commits_per_month(repository)
229 229 @date_to = Date.today
230 230 @date_from = @date_to << 11
231 231 @date_from = Date.civil(@date_from.year, @date_from.month, 1)
232 232 commits_by_day = repository.changesets.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
233 233 commits_by_month = [0] * 12
234 234 commits_by_day.each {|c| commits_by_month[c.first.to_date.months_ago] += c.last }
235 235
236 236 changes_by_day = repository.changes.count(:all, :group => :commit_date, :conditions => ["commit_date BETWEEN ? AND ?", @date_from, @date_to])
237 237 changes_by_month = [0] * 12
238 238 changes_by_day.each {|c| changes_by_month[c.first.to_date.months_ago] += c.last }
239 239
240 240 fields = []
241 241 12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)}
242 242
243 243 graph = SVG::Graph::Bar.new(
244 244 :height => 300,
245 245 :width => 800,
246 246 :fields => fields.reverse,
247 247 :stack => :side,
248 248 :scale_integers => true,
249 249 :step_x_labels => 2,
250 250 :show_data_values => false,
251 251 :graph_title => l(:label_commits_per_month),
252 252 :show_graph_title => true
253 253 )
254 254
255 255 graph.add_data(
256 256 :data => commits_by_month[0..11].reverse,
257 257 :title => l(:label_revision_plural)
258 258 )
259 259
260 260 graph.add_data(
261 261 :data => changes_by_month[0..11].reverse,
262 262 :title => l(:label_change_plural)
263 263 )
264 264
265 265 graph.burn
266 266 end
267 267
268 268 def graph_commits_per_author(repository)
269 269 commits_by_author = repository.changesets.count(:all, :group => :committer)
270 270 commits_by_author.sort! {|x, y| x.last <=> y.last}
271 271
272 272 changes_by_author = repository.changes.count(:all, :group => :committer)
273 273 h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
274 274
275 275 fields = commits_by_author.collect {|r| r.first}
276 276 commits_data = commits_by_author.collect {|r| r.last}
277 277 changes_data = commits_by_author.collect {|r| h[r.first] || 0}
278 278
279 279 fields = fields + [""]*(10 - fields.length) if fields.length<10
280 280 commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
281 281 changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10
282 282
283 283 # Remove email adress in usernames
284 284 fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
285 285
286 286 graph = SVG::Graph::BarHorizontal.new(
287 287 :height => 400,
288 288 :width => 800,
289 289 :fields => fields,
290 290 :stack => :side,
291 291 :scale_integers => true,
292 292 :show_data_values => false,
293 293 :rotate_y_labels => false,
294 294 :graph_title => l(:label_commits_per_author),
295 295 :show_graph_title => true
296 296 )
297 297
298 298 graph.add_data(
299 299 :data => commits_data,
300 300 :title => l(:label_revision_plural)
301 301 )
302 302
303 303 graph.add_data(
304 304 :data => changes_data,
305 305 :title => l(:label_change_plural)
306 306 )
307 307
308 308 graph.burn
309 309 end
310 310
311 311 end
312 312
313 313 class Date
314 314 def months_ago(date = Date.today)
315 315 (date.year - self.year)*12 + (date.month - self.month)
316 316 end
317 317
318 318 def weeks_ago(date = Date.today)
319 319 (date.year - self.year)*52 + (date.cweek - self.cweek)
320 320 end
321 321 end
322 322
323 323 class String
324 324 def with_leading_slash
325 325 starts_with?('/') ? self : "/#{self}"
326 326 end
327 327 end
@@ -1,181 +1,193
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.dirname(__FILE__) + '/../test_helper'
19 19 require 'repositories_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class RepositoriesController; def rescue_action(e) raise e end; end
23 23
24 24 class RepositoriesSubversionControllerTest < Test::Unit::TestCase
25 25 fixtures :projects, :users, :roles, :members, :enabled_modules,
26 26 :repositories, :issues, :issue_statuses, :changesets, :changes,
27 27 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
28 28
29 29 # No '..' in the repository path for svn
30 30 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository'
31 31
32 32 def setup
33 33 @controller = RepositoriesController.new
34 34 @request = ActionController::TestRequest.new
35 35 @response = ActionController::TestResponse.new
36 36 Setting.default_language = 'en'
37 37 User.current = nil
38 38 end
39 39
40 40 if File.directory?(REPOSITORY_PATH)
41 41 def test_show
42 42 get :show, :id => 1
43 43 assert_response :success
44 44 assert_template 'show'
45 45 assert_not_nil assigns(:entries)
46 46 assert_not_nil assigns(:changesets)
47 47 end
48 48
49 49 def test_browse_root
50 50 get :browse, :id => 1
51 51 assert_response :success
52 52 assert_template 'browse'
53 53 assert_not_nil assigns(:entries)
54 54 entry = assigns(:entries).detect {|e| e.name == 'subversion_test'}
55 55 assert_equal 'dir', entry.kind
56 56 end
57 57
58 58 def test_browse_directory
59 59 get :browse, :id => 1, :path => ['subversion_test']
60 60 assert_response :success
61 61 assert_template 'browse'
62 62 assert_not_nil assigns(:entries)
63 63 assert_equal ['folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).collect(&:name)
64 64 entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
65 65 assert_equal 'file', entry.kind
66 66 assert_equal 'subversion_test/helloworld.c', entry.path
67 67 end
68 68
69 69 def test_browse_at_given_revision
70 70 get :browse, :id => 1, :path => ['subversion_test'], :rev => 4
71 71 assert_response :success
72 72 assert_template 'browse'
73 73 assert_not_nil assigns(:entries)
74 74 assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], assigns(:entries).collect(&:name)
75 75 end
76 76
77 77 def test_changes
78 78 get :changes, :id => 1, :path => ['subversion_test', 'folder', 'helloworld.rb' ]
79 79 assert_response :success
80 80 assert_template 'changes'
81 81 # svn properties displayed with svn >= 1.5 only
82 82 if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0])
83 83 assert_not_nil assigns(:properties)
84 84 assert_equal 'native', assigns(:properties)['svn:eol-style']
85 85 assert_tag :ul,
86 86 :child => { :tag => 'li',
87 87 :child => { :tag => 'b', :content => 'svn:eol-style' },
88 88 :child => { :tag => 'span', :content => 'native' } }
89 89 end
90 90 end
91 91
92 92 def test_entry
93 93 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
94 94 assert_response :success
95 95 assert_template 'entry'
96 96 end
97
98 def test_entry_should_send_if_too_big
99 # no files in the test repo is larger than 1KB...
100 with_settings :file_max_size_displayed => 0 do
101 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c']
102 assert_response :success
103 assert_template ''
104 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
105 end
106 end
97 107
98 108 def test_entry_at_given_revision
99 109 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.rb'], :rev => 2
100 110 assert_response :success
101 111 assert_template 'entry'
102 112 # this line was removed in r3 and file was moved in r6
103 113 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
104 114 :content => /Here's the code/
105 115 end
106 116
107 117 def test_entry_not_found
108 118 get :entry, :id => 1, :path => ['subversion_test', 'zzz.c']
109 119 assert_tag :tag => 'div', :attributes => { :class => /error/ },
110 120 :content => /The entry or revision was not found in the repository/
111 121 end
112 122
113 123 def test_entry_download
114 124 get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw'
115 125 assert_response :success
126 assert_template ''
127 assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition']
116 128 end
117 129
118 130 def test_directory_entry
119 131 get :entry, :id => 1, :path => ['subversion_test', 'folder']
120 132 assert_response :success
121 133 assert_template 'browse'
122 134 assert_not_nil assigns(:entry)
123 135 assert_equal 'folder', assigns(:entry).name
124 136 end
125 137
126 138 def test_revision
127 139 get :revision, :id => 1, :rev => 2
128 140 assert_response :success
129 141 assert_template 'revision'
130 142 assert_tag :tag => 'ul',
131 143 :child => { :tag => 'li',
132 144 # link to the entry at rev 2
133 145 :child => { :tag => 'a',
134 146 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'},
135 147 :content => 'repo',
136 148 # link to partial diff
137 149 :sibling => { :tag => 'a',
138 150 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' }
139 151 }
140 152 }
141 153 }
142 154 end
143 155
144 156 def test_revision_with_repository_pointing_to_a_subdirectory
145 157 r = Project.find(1).repository
146 158 # Changes repository url to a subdirectory
147 159 r.update_attribute :url, (r.url + '/test/some')
148 160
149 161 get :revision, :id => 1, :rev => 2
150 162 assert_response :success
151 163 assert_template 'revision'
152 164 assert_tag :tag => 'ul',
153 165 :child => { :tag => 'li',
154 166 # link to the entry at rev 2
155 167 :child => { :tag => 'a',
156 168 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'},
157 169 :content => 'repo',
158 170 # link to partial diff
159 171 :sibling => { :tag => 'a',
160 172 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' }
161 173 }
162 174 }
163 175 }
164 176 end
165 177
166 178 def test_diff
167 179 get :diff, :id => 1, :rev => 3
168 180 assert_response :success
169 181 assert_template 'diff'
170 182 end
171 183
172 184 def test_annotate
173 185 get :annotate, :id => 1, :path => ['subversion_test', 'helloworld.c']
174 186 assert_response :success
175 187 assert_template 'annotate'
176 188 end
177 189 else
178 190 puts "Subversion test repository NOT FOUND. Skipping functional tests !!!"
179 191 def test_fake; assert true end
180 192 end
181 193 end
@@ -1,67 +1,74
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 ENV["RAILS_ENV"] ||= "test"
19 19 require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
20 20 require 'test_help'
21 21 require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
22 22 require File.join(RAILS_ROOT,'test', 'mocks', 'open_id_authentication_mock.rb')
23 23
24 24 class Test::Unit::TestCase
25 25 # Transactional fixtures accelerate your tests by wrapping each test method
26 26 # in a transaction that's rolled back on completion. This ensures that the
27 27 # test database remains unchanged so your fixtures don't have to be reloaded
28 28 # between every test method. Fewer database queries means faster tests.
29 29 #
30 30 # Read Mike Clark's excellent walkthrough at
31 31 # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
32 32 #
33 33 # Every Active Record database supports transactions except MyISAM tables
34 34 # in MySQL. Turn off transactional fixtures in this case; however, if you
35 35 # don't care one way or the other, switching from MyISAM to InnoDB tables
36 36 # is recommended.
37 37 self.use_transactional_fixtures = true
38 38
39 39 # Instantiated fixtures are slow, but give you @david where otherwise you
40 40 # would need people(:david). If you don't want to migrate your existing
41 41 # test cases which use the @david style and don't mind the speed hit (each
42 42 # instantiated fixtures translates to a database query per test method),
43 43 # then set this back to true.
44 44 self.use_instantiated_fixtures = false
45 45
46 46 # Add more helper methods to be used by all tests here...
47 47
48 48 def log_user(login, password)
49 49 get "/login"
50 50 assert_equal nil, session[:user_id]
51 51 assert_response :success
52 52 assert_template "account/login"
53 53 post "/login", :username => login, :password => password
54 54 assert_equal login, User.find(session[:user_id]).login
55 55 end
56 56
57 57 def test_uploaded_file(name, mime)
58 58 ActionController::TestUploadedFile.new(Test::Unit::TestCase.fixture_path + "/files/#{name}", mime)
59 59 end
60 60
61 61 # Use a temporary directory for attachment related tests
62 62 def set_tmp_attachments_directory
63 63 Dir.mkdir "#{RAILS_ROOT}/tmp/test" unless File.directory?("#{RAILS_ROOT}/tmp/test")
64 64 Dir.mkdir "#{RAILS_ROOT}/tmp/test/attachments" unless File.directory?("#{RAILS_ROOT}/tmp/test/attachments")
65 65 Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments"
66 66 end
67
68 def with_settings(options, &block)
69 saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].dup; h}
70 options.each {|k, v| Setting[k] = v}
71 yield
72 saved_settings.each {|k, v| Setting[k] = v}
73 end
67 74 end
General Comments 0
You need to be logged in to leave comments. Login now