Revision 1297:0a574315af3e .svn/pristine/9c
| .svn/pristine/9c/9c322aaf3563cbf741cdd45baeec485ffa01e7d7.svn-base | ||
|---|---|---|
| 1 |
<h2><%= l(:label_repository_new) %></h2> |
|
| 2 |
|
|
| 3 |
<%= labelled_form_for :repository, @repository, :url => project_repositories_path(@project), :html => {:id => 'repository-form'} do |f| %>
|
|
| 4 |
<%= render :partial => 'form', :locals => {:f => f} %>
|
|
| 5 |
<% end %> |
|
| .svn/pristine/9c/9c740b65a5a98aaea5af38782a7512f63e961ef5.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 14 |
# You should have received a copy of the GNU General Public License |
|
| 15 |
# along with this program; if not, write to the Free Software |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
class JournalsController < ApplicationController |
|
| 19 |
before_filter :find_journal, :only => [:edit, :diff] |
|
| 20 |
before_filter :find_issue, :only => [:new] |
|
| 21 |
before_filter :find_optional_project, :only => [:index] |
|
| 22 |
before_filter :authorize, :only => [:new, :edit, :diff] |
|
| 23 |
accept_rss_auth :index |
|
| 24 |
menu_item :issues |
|
| 25 |
|
|
| 26 |
helper :issues |
|
| 27 |
helper :custom_fields |
|
| 28 |
helper :queries |
|
| 29 |
include QueriesHelper |
|
| 30 |
helper :sort |
|
| 31 |
include SortHelper |
|
| 32 |
|
|
| 33 |
def index |
|
| 34 |
retrieve_query |
|
| 35 |
sort_init 'id', 'desc' |
|
| 36 |
sort_update(@query.sortable_columns) |
|
| 37 |
|
|
| 38 |
if @query.valid? |
|
| 39 |
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
|
|
| 40 |
:limit => 25) |
|
| 41 |
end |
|
| 42 |
@title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name) |
|
| 43 |
render :layout => false, :content_type => 'application/atom+xml' |
|
| 44 |
rescue ActiveRecord::RecordNotFound |
|
| 45 |
render_404 |
|
| 46 |
end |
|
| 47 |
|
|
| 48 |
def diff |
|
| 49 |
@issue = @journal.issue |
|
| 50 |
if params[:detail_id].present? |
|
| 51 |
@detail = @journal.details.find_by_id(params[:detail_id]) |
|
| 52 |
else |
|
| 53 |
@detail = @journal.details.detect {|d| d.prop_key == 'description'}
|
|
| 54 |
end |
|
| 55 |
(render_404; return false) unless @issue && @detail |
|
| 56 |
@diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value) |
|
| 57 |
end |
|
| 58 |
|
|
| 59 |
def new |
|
| 60 |
@journal = Journal.visible.find(params[:journal_id]) if params[:journal_id] |
|
| 61 |
if @journal |
|
| 62 |
user = @journal.user |
|
| 63 |
text = @journal.notes |
|
| 64 |
else |
|
| 65 |
user = @issue.author |
|
| 66 |
text = @issue.description |
|
| 67 |
end |
|
| 68 |
# Replaces pre blocks with [...] |
|
| 69 |
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
|
| 70 |
@content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
|
| 71 |
@content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" |
|
| 72 |
rescue ActiveRecord::RecordNotFound |
|
| 73 |
render_404 |
|
| 74 |
end |
|
| 75 |
|
|
| 76 |
def edit |
|
| 77 |
(render_403; return false) unless @journal.editable_by?(User.current) |
|
| 78 |
if request.post? |
|
| 79 |
@journal.update_attributes(:notes => params[:notes]) if params[:notes] |
|
| 80 |
@journal.destroy if @journal.details.empty? && @journal.notes.blank? |
|
| 81 |
call_hook(:controller_journals_edit_post, { :journal => @journal, :params => params})
|
|
| 82 |
respond_to do |format| |
|
| 83 |
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @journal.journalized_id }
|
|
| 84 |
format.js { render :action => 'update' }
|
|
| 85 |
end |
|
| 86 |
else |
|
| 87 |
respond_to do |format| |
|
| 88 |
format.html {
|
|
| 89 |
# TODO: implement non-JS journal update |
|
| 90 |
render :nothing => true |
|
| 91 |
} |
|
| 92 |
format.js |
|
| 93 |
end |
|
| 94 |
end |
|
| 95 |
end |
|
| 96 |
|
|
| 97 |
private |
|
| 98 |
|
|
| 99 |
def find_journal |
|
| 100 |
@journal = Journal.visible.find(params[:id]) |
|
| 101 |
@project = @journal.journalized.project |
|
| 102 |
rescue ActiveRecord::RecordNotFound |
|
| 103 |
render_404 |
|
| 104 |
end |
|
| 105 |
end |
|
| .svn/pristine/9c/9ca9c6dfffd7638ae7eea68c1bdadff3a8c99ad5.svn-base | ||
|---|---|---|
| 1 |
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html |
|
| 2 |
comments_001: |
|
| 3 |
commented_type: News |
|
| 4 |
commented_id: 1 |
|
| 5 |
id: 1 |
|
| 6 |
author_id: 1 |
|
| 7 |
comments: my first comment |
|
| 8 |
created_on: 2006-12-10 18:10:10 +01:00 |
|
| 9 |
updated_on: 2006-12-10 18:10:10 +01:00 |
|
| 10 |
comments_002: |
|
| 11 |
commented_type: News |
|
| 12 |
commented_id: 1 |
|
| 13 |
id: 2 |
|
| 14 |
author_id: 2 |
|
| 15 |
comments: This is an other comment |
|
| 16 |
created_on: 2006-12-10 18:12:10 +01:00 |
|
| 17 |
updated_on: 2006-12-10 18:12:10 +01:00 |
|
| .svn/pristine/9c/9cdef37026e7690fbb0734bd3941ca2f668d8868.svn-base | ||
|---|---|---|
| 1 |
Content-Type: application/ms-tnef; name="winmail.dat" |
|
| 2 |
Content-Transfer-Encoding: binary |
|
| 3 |
From: John Smith <JSmith@somenet.foo> |
|
| 4 |
To: "redmine@somenet.foo" <redmine@somenet.foo> |
|
| 5 |
Date: Fri, 1 Jun 2012 14:39:38 +0200 |
|
| 6 |
Message-ID: <87C31D42249DD0489D1A1444E3232DD7019D6183@foo.bar> |
|
| 7 |
Accept-Language: de-CH, en-US |
|
| 8 |
Content-Language: de-CH |
|
| 9 |
|
|
| 10 |
Fixture |
|
| .svn/pristine/9c/9ce85bb5b6f77397b24b7cc4903f349b0d8e5364.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 14 |
# You should have received a copy of the GNU General Public License |
|
| 15 |
# along with this program; if not, write to the Free Software |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
require File.expand_path('../../test_helper', __FILE__)
|
|
| 19 |
require 'news_controller' |
|
| 20 |
|
|
| 21 |
# Re-raise errors caught by the controller. |
|
| 22 |
class NewsController; def rescue_action(e) raise e end; end |
|
| 23 |
|
|
| 24 |
class NewsControllerTest < ActionController::TestCase |
|
| 25 |
fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :news, :comments |
|
| 26 |
|
|
| 27 |
def setup |
|
| 28 |
@controller = NewsController.new |
|
| 29 |
@request = ActionController::TestRequest.new |
|
| 30 |
@response = ActionController::TestResponse.new |
|
| 31 |
User.current = nil |
|
| 32 |
end |
|
| 33 |
|
|
| 34 |
def test_index |
|
| 35 |
get :index |
|
| 36 |
assert_response :success |
|
| 37 |
assert_template 'index' |
|
| 38 |
assert_not_nil assigns(:newss) |
|
| 39 |
assert_nil assigns(:project) |
|
| 40 |
end |
|
| 41 |
|
|
| 42 |
def test_index_with_project |
|
| 43 |
get :index, :project_id => 1 |
|
| 44 |
assert_response :success |
|
| 45 |
assert_template 'index' |
|
| 46 |
assert_not_nil assigns(:newss) |
|
| 47 |
end |
|
| 48 |
|
|
| 49 |
def test_index_with_invalid_project_should_respond_with_404 |
|
| 50 |
get :index, :project_id => 999 |
|
| 51 |
assert_response 404 |
|
| 52 |
end |
|
| 53 |
|
|
| 54 |
def test_show |
|
| 55 |
get :show, :id => 1 |
|
| 56 |
assert_response :success |
|
| 57 |
assert_template 'show' |
|
| 58 |
assert_tag :tag => 'h2', :content => /eCookbook first release/ |
|
| 59 |
end |
|
| 60 |
|
|
| 61 |
def test_show_should_show_attachments |
|
| 62 |
attachment = Attachment.first |
|
| 63 |
attachment.container = News.find(1) |
|
| 64 |
attachment.save! |
|
| 65 |
|
|
| 66 |
get :show, :id => 1 |
|
| 67 |
assert_response :success |
|
| 68 |
assert_tag 'a', :content => attachment.filename |
|
| 69 |
end |
|
| 70 |
|
|
| 71 |
def test_show_not_found |
|
| 72 |
get :show, :id => 999 |
|
| 73 |
assert_response 404 |
|
| 74 |
end |
|
| 75 |
|
|
| 76 |
def test_get_new |
|
| 77 |
@request.session[:user_id] = 2 |
|
| 78 |
get :new, :project_id => 1 |
|
| 79 |
assert_response :success |
|
| 80 |
assert_template 'new' |
|
| 81 |
end |
|
| 82 |
|
|
| 83 |
def test_post_create |
|
| 84 |
ActionMailer::Base.deliveries.clear |
|
| 85 |
@request.session[:user_id] = 2 |
|
| 86 |
|
|
| 87 |
with_settings :notified_events => %w(news_added) do |
|
| 88 |
post :create, :project_id => 1, :news => { :title => 'NewsControllerTest',
|
|
| 89 |
:description => 'This is the description', |
|
| 90 |
:summary => '' } |
|
| 91 |
end |
|
| 92 |
assert_redirected_to '/projects/ecookbook/news' |
|
| 93 |
|
|
| 94 |
news = News.find_by_title('NewsControllerTest')
|
|
| 95 |
assert_not_nil news |
|
| 96 |
assert_equal 'This is the description', news.description |
|
| 97 |
assert_equal User.find(2), news.author |
|
| 98 |
assert_equal Project.find(1), news.project |
|
| 99 |
assert_equal 1, ActionMailer::Base.deliveries.size |
|
| 100 |
end |
|
| 101 |
|
|
| 102 |
def test_post_create_with_attachment |
|
| 103 |
set_tmp_attachments_directory |
|
| 104 |
@request.session[:user_id] = 2 |
|
| 105 |
assert_difference 'News.count' do |
|
| 106 |
assert_difference 'Attachment.count' do |
|
| 107 |
post :create, :project_id => 1, |
|
| 108 |
:news => { :title => 'Test', :description => 'This is the description' },
|
|
| 109 |
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
|
| 110 |
end |
|
| 111 |
end |
|
| 112 |
attachment = Attachment.first(:order => 'id DESC') |
|
| 113 |
news = News.first(:order => 'id DESC') |
|
| 114 |
assert_equal news, attachment.container |
|
| 115 |
end |
|
| 116 |
|
|
| 117 |
def test_post_create_with_validation_failure |
|
| 118 |
@request.session[:user_id] = 2 |
|
| 119 |
post :create, :project_id => 1, :news => { :title => '',
|
|
| 120 |
:description => 'This is the description', |
|
| 121 |
:summary => '' } |
|
| 122 |
assert_response :success |
|
| 123 |
assert_template 'new' |
|
| 124 |
assert_not_nil assigns(:news) |
|
| 125 |
assert assigns(:news).new_record? |
|
| 126 |
assert_error_tag :content => /title can't be blank/i |
|
| 127 |
end |
|
| 128 |
|
|
| 129 |
def test_get_edit |
|
| 130 |
@request.session[:user_id] = 2 |
|
| 131 |
get :edit, :id => 1 |
|
| 132 |
assert_response :success |
|
| 133 |
assert_template 'edit' |
|
| 134 |
end |
|
| 135 |
|
|
| 136 |
def test_put_update |
|
| 137 |
@request.session[:user_id] = 2 |
|
| 138 |
put :update, :id => 1, :news => { :description => 'Description changed by test_post_edit' }
|
|
| 139 |
assert_redirected_to '/news/1' |
|
| 140 |
news = News.find(1) |
|
| 141 |
assert_equal 'Description changed by test_post_edit', news.description |
|
| 142 |
end |
|
| 143 |
|
|
| 144 |
def test_put_update_with_attachment |
|
| 145 |
set_tmp_attachments_directory |
|
| 146 |
@request.session[:user_id] = 2 |
|
| 147 |
assert_no_difference 'News.count' do |
|
| 148 |
assert_difference 'Attachment.count' do |
|
| 149 |
put :update, :id => 1, |
|
| 150 |
:news => { :description => 'This is the description' },
|
|
| 151 |
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
|
|
| 152 |
end |
|
| 153 |
end |
|
| 154 |
attachment = Attachment.first(:order => 'id DESC') |
|
| 155 |
assert_equal News.find(1), attachment.container |
|
| 156 |
end |
|
| 157 |
|
|
| 158 |
def test_update_with_failure |
|
| 159 |
@request.session[:user_id] = 2 |
|
| 160 |
put :update, :id => 1, :news => { :description => '' }
|
|
| 161 |
assert_response :success |
|
| 162 |
assert_template 'edit' |
|
| 163 |
assert_error_tag :content => /description can't be blank/i |
|
| 164 |
end |
|
| 165 |
|
|
| 166 |
def test_destroy |
|
| 167 |
@request.session[:user_id] = 2 |
|
| 168 |
delete :destroy, :id => 1 |
|
| 169 |
assert_redirected_to '/projects/ecookbook/news' |
|
| 170 |
assert_nil News.find_by_id(1) |
|
| 171 |
end |
|
| 172 |
end |
|
| .svn/pristine/9c/9cf686fc2a47c572e6d1fe8e9ebae6d200ed1f80.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 14 |
# You should have received a copy of the GNU General Public License |
|
| 15 |
# along with this program; if not, write to the Free Software |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
class SysController < ActionController::Base |
|
| 19 |
before_filter :check_enabled |
|
| 20 |
|
|
| 21 |
def projects |
|
| 22 |
p = Project.active.has_module(:repository).find( |
|
| 23 |
:all, |
|
| 24 |
:include => :repository, |
|
| 25 |
:order => "#{Project.table_name}.identifier"
|
|
| 26 |
) |
|
| 27 |
# extra_info attribute from repository breaks activeresource client |
|
| 28 |
render :xml => p.to_xml( |
|
| 29 |
:only => [:id, :identifier, :name, :is_public, :status], |
|
| 30 |
:include => {:repository => {:only => [:id, :url]}}
|
|
| 31 |
) |
|
| 32 |
end |
|
| 33 |
|
|
| 34 |
def create_project_repository |
|
| 35 |
project = Project.find(params[:id]) |
|
| 36 |
if project.repository |
|
| 37 |
render :nothing => true, :status => 409 |
|
| 38 |
else |
|
| 39 |
logger.info "Repository for #{project.name} was reported to be created by #{request.remote_ip}."
|
|
| 40 |
repository = Repository.factory(params[:vendor], params[:repository]) |
|
| 41 |
repository.project = project |
|
| 42 |
if repository.save |
|
| 43 |
render :xml => {repository.class.name.underscore.gsub('/', '-') => {:id => repository.id, :url => repository.url}}, :status => 201
|
|
| 44 |
else |
|
| 45 |
render :nothing => true, :status => 422 |
|
| 46 |
end |
|
| 47 |
end |
|
| 48 |
end |
|
| 49 |
|
|
| 50 |
def fetch_changesets |
|
| 51 |
projects = [] |
|
| 52 |
scope = Project.active.has_module(:repository) |
|
| 53 |
if params[:id] |
|
| 54 |
project = nil |
|
| 55 |
if params[:id].to_s =~ /^\d*$/ |
|
| 56 |
project = scope.find(params[:id]) |
|
| 57 |
else |
|
| 58 |
project = scope.find_by_identifier(params[:id]) |
|
| 59 |
end |
|
| 60 |
raise ActiveRecord::RecordNotFound unless project |
|
| 61 |
projects << project |
|
| 62 |
else |
|
| 63 |
projects = scope.all |
|
| 64 |
end |
|
| 65 |
projects.each do |project| |
|
| 66 |
project.repositories.each do |repository| |
|
| 67 |
repository.fetch_changesets |
|
| 68 |
end |
|
| 69 |
end |
|
| 70 |
render :nothing => true, :status => 200 |
|
| 71 |
rescue ActiveRecord::RecordNotFound |
|
| 72 |
render :nothing => true, :status => 404 |
|
| 73 |
end |
|
| 74 |
|
|
| 75 |
protected |
|
| 76 |
|
|
| 77 |
def check_enabled |
|
| 78 |
User.current = nil |
|
| 79 |
unless Setting.sys_api_enabled? && params[:key].to_s == Setting.sys_api_key |
|
| 80 |
render :text => 'Access denied. Repository management WS is disabled or key is invalid.', :status => 403 |
|
| 81 |
return false |
|
| 82 |
end |
|
| 83 |
end |
|
| 84 |
end |
|
Also available in: Unified diff