Merge branch 'feature/rails3' of github.com:opf/openproject into feature/rails3

pull/1186/head
Philipp Tessenow 12 years ago
commit 51ed9dd781
  1. 1
      app/controllers/my_controller.rb
  2. 3
      app/controllers/watchers_controller.rb
  3. 4
      app/controllers/welcome_controller.rb
  4. 4
      app/controllers/wikis_controller.rb
  5. 15
      app/helpers/attachments_helper.rb
  6. 8
      app/models/watcher.rb
  7. 2
      app/views/common/_diff.html.erb
  8. 5
      app/views/layouts/base.html.erb
  9. 14
      app/views/welcome/robots.text.erb
  10. 5
      config/routes.rb
  11. 2
      lib/redmine.rb
  12. 2
      lib/redmine/hook.rb
  13. 4
      lib/redmine/syntax_highlighting.rb
  14. 12
      lib/redmine/themes/theme.rb
  15. 2
      test/functional/my_controller_test.rb
  16. 16
      test/functional/project_enumerations_controller_test.rb
  17. 2
      test/functional/projects_controller_test.rb
  18. 4
      test/functional/repositories_subversion_controller_test.rb
  19. 5
      test/functional/watchers_controller_test.rb
  20. 2
      test/functional/welcome_controller_test.rb
  21. 4
      test/functional/wiki_controller_test.rb
  22. 2
      test/integration/admin_test.rb
  23. 2
      test/integration/api_test/disabled_rest_api_test.rb
  24. 2
      test/integration/api_test/http_basic_login_test.rb
  25. 2
      test/integration/api_test/http_basic_login_with_api_token_test.rb
  26. 2
      test/integration/api_test/issues_test.rb
  27. 2
      test/integration/api_test/projects_test.rb
  28. 2
      test/integration/api_test/time_entries_test.rb
  29. 2
      test/integration/api_test/token_authentication_test.rb
  30. 2
      test/integration/api_test/users_test.rb
  31. 2
      test/integration/application_test.rb
  32. 2
      test/integration/issues_test.rb
  33. 11
      test/integration/layout_test.rb
  34. 2
      test/integration/lib/redmine/menu_manager_test.rb
  35. 62
      test/integration/lib/redmine/themes_test.rb
  36. 2
      test/integration/projects_test.rb
  37. 2
      test/integration/routing_test.rb
  38. 9
      test/unit/watcher_test.rb

@ -58,7 +58,6 @@ class MyController < ApplicationController
set_language_if_valid @user.language
flash[:notice] = l(:notice_account_updated)
redirect_to :action => 'account'
return
end
end
end

@ -32,8 +32,7 @@ class WatchersController < ApplicationController
end
def new
@watcher = Watcher.new
@watcher.safe_attributes = params[:watcher]
@watcher = Watcher.new(params[:watcher])
@watcher.watchable = @watched
@watcher.save if request.post?
respond_to do |format|

@ -20,10 +20,6 @@ class WelcomeController < ApplicationController
def robots
@projects = Project.active.public
respond_to do |format|
format.text # { render :layout => false }
end
end
caches_action :robots
end

@ -21,7 +21,9 @@ class WikisController < ApplicationController
@wiki = @project.wiki || Wiki.new(:project => @project)
@wiki.safe_attributes = params[:wiki]
@wiki.save if request.post?
render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'}
# there's is no wiki anymore, see: opf/openproject/master#e375875
# render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'}
render :nothing => true
end
# Delete a project's wiki

@ -26,17 +26,10 @@ module AttachmentsHelper
end
def to_utf8_for_attachments(str)
if str.respond_to?(:force_encoding)
str.force_encoding('UTF-8')
return str if str.valid_encoding?
else
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
end
forced_str = str.dup
forced_str.force_encoding('UTF-8')
return forced_str if forced_str.valid_encoding?
begin
(str + ' ').encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "?")[0..-3]
rescue Encoding::InvalidByteSequenceError, Encoding::UndefinedConversionError
str
end
str.encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => '') # better :replace => '?'
end
end

@ -18,12 +18,13 @@ class Watcher < ActiveRecord::Base
belongs_to :watchable, :polymorphic => true
belongs_to :user
attr_accessible :watchable, :user
attr_accessible :watchable, :user, :user_id
validates_presence_of :watchable, :user
validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
validate :validate_active_user
validate :validate_user_allowed_to_watch
# Unwatch things that users are no longer allowed to view
def self.prune(options={})
@ -45,6 +46,11 @@ class Watcher < ActiveRecord::Base
errors.add :user_id, :invalid unless user.active?
end
def validate_user_allowed_to_watch
return if user.blank? || watchable.blank?
errors.add :user_id, :invalid unless user.in?(watchable.addable_watcher_users)
end
private
def self.prune_single_user(user, options={})

@ -31,7 +31,7 @@
<% else -%>
<table class="filecontent">
<thead>
<tr><th colspan="3" class="filename"><%= h(to_utf8_for_attachments(table_file.file_name)) %></th></tr>
<tr><th colspan="3" class="filename"><%= to_utf8_for_attachments(table_file.file_name) %></th></tr>
</thead>
<tbody>
<% table_file.each_line do |spacing, line| %>

@ -9,8 +9,11 @@
<%= favicon_link_tag 'favicon.ico' %>
<%= stylesheet_link_tag current_theme.stylesheet_manifest %>
<%= javascript_include_tag 'application' %>
<!-- user specific tags -->
<%= user_specific_javascript_includes %>
<!-- aditional headers -->
<!-- project specific tags -->
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= content_for(:header_tags) if content_for?(:header_tags) %>
</head>
<noscript><%=l(:description_noscript)%></noscript>

@ -1,9 +1,9 @@
User-agent: *
<% @projects.each do |project| -%>
Disallow: <%= project_repository_path(project) %>
Disallow: <%= project_issues_path(project) %>
Disallow: <%= project_activity_path(project) %>
<% @projects.each do |p| -%>
Disallow: /projects/<%= p.to_param %>/repository
Disallow: /projects/<%= p.to_param %>/issues
Disallow: /projects/<%= p.to_param %>/activity
<% end -%>
Disallow: <%= issues_gantt_path %>
Disallow: <%= issues_calendar_path %>
Disallow: <%= activity_path %>
Disallow: /issues/gantt
Disallow: /issues/calendar
Disallow: /activity

@ -292,8 +292,7 @@ OpenProject::Application.routes.draw do
match '/projects/:id/repository/revisions', :action => :revisions
match '/projects/:id/repository/revisions.:format', :action => :revisions
match '/projects/:id/repository/revisions/:rev', :action => :revision
match '/projects/:id/repository/revisions/:rev/diff', :action => :diff
match '/projects/:id/repository/revisions/:rev/diff.:format', :action => :diff
match '/projects/:id/repository/revisions/:rev/diff/*path(.:format)', :action => :diff
match '/projects/:id/repository/revisions/:rev/raw/*path', :action => :entry, :format => 'raw', :rev => /[a-z0-9\.\-_]+/
match '/projects/:id/repository/revisions/:rev/:action/*path', :rev => /[a-z0-9\.\-_]+/
match '/projects/:id/repository/raw/*path', :action => :entry, :format => 'raw'
@ -342,7 +341,7 @@ OpenProject::Application.routes.draw do
# Install the default route as the lowest priority.
match '/:controller(/:action(/:id))'
match '/robots.txt' => 'welcome#robots'
match '/robots' => 'welcome#robots', :defaults => { :format => :txt }
# Used for OpenID
root :to => 'account#login'
end

@ -64,7 +64,7 @@ Redmine::AccessControl.map do |map|
map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin
map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
map.permission :select_project_modules, {:projects => :modules}, :require => :member
map.permission :manage_members, {:projects => :settings, :members => [:create, :update, :destroy, :autocomplete]}, :require => :member
map.permission :manage_members, {:projects => :settings, :members => [:create, :update, :destroy, :autocomplete_for_member]}, :require => :member
map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member
map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member

@ -86,7 +86,7 @@ module Redmine
include ActionView::Helpers::JavaScriptHelper
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::AssetTagHelper
include Sprockets::Helpers::RailsHelper
include ActionView::Helpers::TextHelper
include Rails.application.routes.url_helpers
include ApplicationHelper

@ -35,9 +35,11 @@ module Redmine
class << self
# Highlights +text+ as the content of +filename+
# Should not return line numbers nor outer pre tag
# use CodeRay to scan normal text, since it's smart enough to find
# the correct source encoding before passing it to ERB::Util.html_escape
def highlight_by_filename(text, filename)
language = ::CodeRay::FileType[filename]
language ? ::CodeRay.scan(text, language).html : ERB::Util.h(text)
language ? ::CodeRay.scan(text, language).html.html_safe : ERB::Util.h(::CodeRay.scan(text, :text).text)
end
# Highlights +text+ using +language+ syntax

@ -39,7 +39,7 @@ module Redmine
def new_theme(identifier = nil)
theme = Class.new(self).instance
theme.identifier = identifier if identifier
theme.identifier = identifier
theme
end
@ -50,7 +50,7 @@ module Redmine
def registered_themes
@_registered_themes ||= \
each_with_object(Hash.new) do |theme, themes|
themes.each_with_object(Hash.new) do |theme, themes|
themes[theme.identifier] = theme
end
end
@ -68,7 +68,7 @@ module Redmine
Theme.abstract_themes << self
# undefine methods responsible for creating instances
singleton_class.send :remove_method, :new, :allocate, :instance
singleton_class.send :remove_method, *[:new, :allocate, :instance]
end
def abstract?
@ -114,13 +114,13 @@ module Redmine
@overridden_images ||= \
begin
Dir.chdir(overridden_images_path) { Dir.glob('**/*') }
rescue Errno::ENOENT # overridden_images_path not there
rescue Errno::ENOENT # overridden_images_path missing
[]
end.to_set
end
def image_overridden?(source)
overridden_images.include?(source)
source.in?(overridden_images)
end
URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}
@ -130,7 +130,7 @@ module Redmine
return source if source[0] == ?/
if image_overridden?(source)
"#{assets_prefix}/#{source}"
File.join(assets_prefix, source)
else
source
end

@ -60,7 +60,7 @@ class MyControllerTest < ActionController::TestCase
end
def test_update_account
post :account,
put :account,
:user => {
:firstname => "Joe",
:login => "root", # should not be allowed

@ -134,17 +134,17 @@ class ProjectEnumerationsControllerTest < ActionController::TestCase
# TODO: Need to cause an exception on create but these tests
# aren't setup for mocking. Just create a record now so the
# second one is a duplicate
parent = TimeEntryActivity.find(9)
# parent = TimeEntryActivity.find(9)
parent = TimeEntryActivity.new
parent.force_attribute = { :name => parent.name, :project_id => 1, :position => parent.position, :active => true }
parent.force_attributes = { :name => parent.name, :project_id => 1, :position => parent.position, :active => true }
parent.save(:validate => false)
TimeEntry.create!({ :project_id => 1,
:hours => 1.0,
:user => User.find(1),
:issue_id => 3,
:activity_id => 10,
:spent_on => '2009-01-01' })
project = Project.find(1)
project.time_entries.create!(:hours => 1.0,
:user => User.find(1),
:issue_id => 3,
:activity_id => 10,
:spent_on => '2009-01-01')
assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size
assert_equal 1, TimeEntry.find_all_by_activity_id_and_project_id(10, 1).size

@ -475,7 +475,7 @@ class ProjectsControllerTest < ActionController::TestCase
def test_hook_response
Redmine::Hook.add_listener(ProjectBasedTemplate)
get :show, :id => 1
assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
assert_tag :tag => 'link', :attributes => {:href => '/assets/ecookbook.css'},
:parent => {:tag => 'head'}
Redmine::Hook.clear_listeners

@ -193,7 +193,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
:child => { :tag => 'li',
# link to the entry at rev 2
:child => { :tag => 'a',
:attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'},
:attributes => {:href => '/projects/ecookbook/repository/revisions/2/raw/test/some/path/in/the/repo'},
:content => 'repo',
# link to partial diff
:sibling => { :tag => 'a',
@ -240,7 +240,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
:child => { :tag => 'li',
# link to the entry at rev 2
:child => { :tag => 'a',
:attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'},
:attributes => {:href => '/projects/ecookbook/repository/revisions/2/raw/path/in/the/repo'},
:content => 'repo',
# link to partial diff
:sibling => { :tag => 'a',

@ -105,13 +105,14 @@ class WatchersControllerTest < ActionController::TestCase
end
def test_new_watcher
Watcher.destroy_all
@request.session[:user_id] = 2
assert_difference('Watcher.count') do
xhr :post, :new, :object_type => 'issue', :object_id => '2', :watcher => {:user_id => '4'}
xhr :post, :new, :object_type => 'issue', :object_id => '2', :watcher => {:user_id => '3'}
assert_response :success
assert_select_rjs :replace_html, 'watchers'
end
assert Issue.find(2).watched_by?(User.find(4))
assert Issue.find(2).watched_by?(User.find(3))
end
def test_remove_watcher

@ -59,7 +59,7 @@ class WelcomeControllerTest < ActionController::TestCase
end
def test_robots
get :robots
get :robots, :format => :txt
assert_response :success
assert_equal 'text/plain', @response.content_type
assert @response.body.match(%r{^Disallow: /projects/ecookbook/issues\r?$})

@ -230,8 +230,8 @@ class WikiControllerTest < ActionController::TestCase
get :diff, :project_id => 1, :id => 'CookBook_documentation', :version => 2, :version_from => 1
assert_response :success
assert_template 'diff'
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'},
:content => /updated/
assert_tag :tag => 'ins', :attributes => { :class => 'diffins'},
:content => /updated/
end
def test_annotate

@ -13,7 +13,7 @@
#++
require File.expand_path('../../test_helper', __FILE__)
class AdminTest < ActionController::IntegrationTest
class AdminTest < ActionDispatch::IntegrationTest
fixtures :all
def test_add_user

@ -14,7 +14,7 @@
require File.expand_path('../../../test_helper', __FILE__)
class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
class ApiTest::DisabledRestApiTest < ActionDispatch::IntegrationTest
fixtures :all
def setup

@ -14,7 +14,7 @@
require File.expand_path('../../../test_helper', __FILE__)
class ApiTest::HttpBasicLoginTest < ActionController::IntegrationTest
class ApiTest::HttpBasicLoginTest < ActionDispatch::IntegrationTest
fixtures :all
def setup

@ -14,7 +14,7 @@
require File.expand_path('../../../test_helper', __FILE__)
class ApiTest::HttpBasicLoginWithApiTokenTest < ActionController::IntegrationTest
class ApiTest::HttpBasicLoginWithApiTokenTest < ActionDispatch::IntegrationTest
fixtures :all
def setup

@ -13,7 +13,7 @@
#++
require File.expand_path('../../../test_helper', __FILE__)
class ApiTest::IssuesTest < ActionController::IntegrationTest
class ApiTest::IssuesTest < ActionDispatch::IntegrationTest
fixtures :all
def setup

@ -13,7 +13,7 @@
#++
require File.expand_path('../../../test_helper', __FILE__)
class ApiTest::ProjectsTest < ActionController::IntegrationTest
class ApiTest::ProjectsTest < ActionDispatch::IntegrationTest
fixtures :all
def setup

@ -13,7 +13,7 @@
#++
require File.expand_path('../../../test_helper', __FILE__)
class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
class ApiTest::TimeEntriesTest < ActionDispatch::IntegrationTest
fixtures :all
def setup

@ -14,7 +14,7 @@
require File.expand_path('../../../test_helper', __FILE__)
class ApiTest::TokenAuthenticationTest < ActionController::IntegrationTest
class ApiTest::TokenAuthenticationTest < ActionDispatch::IntegrationTest
fixtures :all
def setup

@ -13,7 +13,7 @@
#++
require File.expand_path('../../../test_helper', __FILE__)
class ApiTest::UsersTest < ActionController::IntegrationTest
class ApiTest::UsersTest < ActionDispatch::IntegrationTest
fixtures :all
def setup

@ -13,7 +13,7 @@
#++
require File.expand_path('../../test_helper', __FILE__)
class ApplicationTest < ActionController::IntegrationTest
class ApplicationTest < ActionDispatch::IntegrationTest
include Redmine::I18n
fixtures :all

@ -13,7 +13,7 @@
#++
require File.expand_path('../../test_helper', __FILE__)
class IssuesTest < ActionController::IntegrationTest
class IssuesTest < ActionDispatch::IntegrationTest
fixtures :all
# create an issue

@ -14,7 +14,7 @@
require File.expand_path('../../test_helper', __FILE__)
class LayoutTest < ActionController::IntegrationTest
class LayoutTest < ActionDispatch::IntegrationTest
fixtures :all
test "browsing to a missing page should render the base layout" do
@ -50,15 +50,6 @@ class LayoutTest < ActionController::IntegrationTest
end
end
def test_wiki_formatter_header_tags
Role.anonymous.add_permission! :add_issues
get '/projects/ecookbook/issues/new'
assert_tag :script,
:attributes => {:src => %r{^/assets/jstoolbar/textile.js}},
:parent => {:tag => 'head'}
end
test "page titles should be properly escaped" do
project = Project.generate(:name => "C&A")

@ -13,7 +13,7 @@
#++
require File.expand_path('../../../../test_helper', __FILE__)
class MenuManagerTest < ActionController::IntegrationTest
class MenuManagerTest < ActionDispatch::IntegrationTest
include Redmine::I18n
fixtures :all

@ -13,16 +13,18 @@
#++
require File.expand_path('../../../../test_helper', __FILE__)
class ThemesTest < ActionController::IntegrationTest
class ThemesTest < ActionDispatch::IntegrationTest
include MiniTest::Assertions
fixtures :all
def setup
@theme = Redmine::Themes.last
Setting.ui_theme = @theme.id
@theme = Redmine::Themes.default_theme
Setting.ui_theme = @theme.identifier
end
def teardown
Setting.ui_theme = ''
Setting.ui_theme = nil
end
def test_application_css
@ -30,42 +32,44 @@ class ThemesTest < ActionController::IntegrationTest
assert_response :success
assert_tag :tag => 'link',
:attributes => {:href => %r{^/themes/#{@theme.dir}/stylesheets/application.css}}
:attributes => {:href => '/assets/default.css'}
end
def test_without_theme_js
should_eventually 'test_without_theme_js' do
get '/'
assert_response :success
assert_no_tag :tag => 'script',
:attributes => {:src => %r{^/themes/#{@theme.dir}/javascripts/theme.js}}
:attributes => {:src => '/assets/default.js'}
end
def test_with_theme_js
# Simulates a theme.js
@theme.javascripts << 'theme'
get '/'
assert_response :success
assert_tag :tag => 'script',
:attributes => {:src => %r{^/themes/#{@theme.dir}/javascripts/theme.js}}
should_eventually 'test_with_theme_js' do
begin
# Simulates a theme.js
@theme.javascripts << 'theme'
get '/'
ensure
@theme.javascripts.delete 'theme'
assert_response :success
assert_tag :tag => 'script',
:attributes => {:src => '/assets/default.js'}
ensure
@theme.javascripts.delete 'theme'
end
end
def test_with_sub_uri
Redmine::Utils.relative_url_root = '/foo'
@theme.javascripts << 'theme'
get '/'
assert_response :success
assert_tag :tag => 'link',
:attributes => {:href => %r{^/foo/themes/#{@theme.dir}/stylesheets/application.css}}
assert_tag :tag => 'script',
:attributes => {:src => %r{^/foo/themes/#{@theme.dir}/javascripts/theme.js}}
should_eventually 'test_with_sub_uri' do
begin
Redmine::Utils.relative_url_root = '/foo'
@theme.javascripts << 'theme'
get '/'
ensure
Redmine::Utils.relative_url_root = ''
assert_response :success
assert_tag :tag => 'link',
:attributes => {:src => '/foo/assets/default.js'}
assert_tag :tag => 'script',
:attributes => {:src => '/foo/assets/default.js'}
ensure
Redmine::Utils.relative_url_root = ''
end
end
end

@ -13,7 +13,7 @@
#++
require File.expand_path('../../test_helper', __FILE__)
class ProjectsTest < ActionController::IntegrationTest
class ProjectsTest < ActionDispatch::IntegrationTest
fixtures :all
def test_archive_project

@ -13,7 +13,7 @@
#++
require File.expand_path('../../test_helper', __FILE__)
class RoutingTest < ActionController::IntegrationTest
class RoutingTest < ActionDispatch::IntegrationTest
context "activities" do
should route(:get, "/activity").to( :controller => 'activities',
:action => 'index' )

@ -17,6 +17,8 @@ class WatcherTest < ActiveSupport::TestCase
def setup
@user = FactoryGirl.create :user
@issue = FactoryGirl.create :issue
@role = FactoryGirl.create :role, :permissions => [:view_issues]
@issue.project.add_member! @user, @role
end
def test_add_watcher
@ -65,17 +67,12 @@ class WatcherTest < ActiveSupport::TestCase
end
def test_addable_watcher_users
view_issues_role = FactoryGirl.create :role, :permissions => [:view_issues]
@issue.project.add_member! @user, view_issues_role
addable_watcher_users = @issue.addable_watcher_users
assert_kind_of Array, addable_watcher_users
assert_kind_of User, addable_watcher_users.first
end
def test_recipients
view_issues_role = FactoryGirl.create :role, :permissions => [:view_issues]
@issue.project.add_member! @user, view_issues_role
@user.update_attribute :mail_notification, 'all'
assert @issue.watcher_recipients.empty?
@ -93,8 +90,6 @@ class WatcherTest < ActiveSupport::TestCase
end
def test_prune_removes_watchers_that_dont_have_permission
view_issues_role = FactoryGirl.create :role, :permissions => [:view_issues]
@issue.project.add_member! @user, view_issues_role
@issue.add_watcher(@user)
assert_no_difference 'Watcher.count' do

Loading…
Cancel
Save