Merge branch 'dev' into dev-angular

pull/1282/head
Alex Coles 11 years ago
commit 51808c5ffd
  1. 1
      app/controllers/my_controller.rb
  2. 1
      app/controllers/users_controller.rb
  3. 13
      app/helpers/watchers_helper.rb
  4. 5
      app/models/work_package.rb
  5. 3
      app/views/my/blocks/_issuesreportedbyme.html.erb
  6. 2
      app/views/users/show.html.erb
  7. 11
      doc/CHANGELOG.md
  8. 9
      spec/controllers/my_controller_spec.rb
  9. 7
      spec/controllers/users_controller_spec.rb
  10. 26
      spec/models/work_package_spec.rb
  11. 78
      test/unit/helpers/watchers_helper_test.rb

@ -60,6 +60,7 @@ class MyController < ApplicationController
def index def index
@user = User.current @user = User.current
@blocks = get_current_layout @blocks = get_current_layout
@reported_count = WorkPackage.on_active_project.with_author(@user).visible.count
render :action => 'page', :layout => 'base' render :action => 'page', :layout => 'base'
end end
alias :page :index alias :page :index

@ -90,6 +90,7 @@ class UsersController < ApplicationController
def show def show
# show projects based on current user visibility # show projects based on current user visibility
@reported_count = WorkPackage.on_active_project.with_author(@user).visible.count
@memberships = @user.memberships.all(:conditions => Project.visible_by(User.current)) @memberships = @user.memberships.all(:conditions => Project.visible_by(User.current))
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10) events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)

@ -29,19 +29,6 @@
module WatchersHelper module WatchersHelper
# Deprecated method. Use watcher_link instead
#
# This method will be removed in ChiliProject 3.0 or later
def watcher_tag(object, user, options={:replace => 'watcher'})
ActiveSupport::Deprecation.warn "The WatchersHelper#watcher_tag is deprecated and will be removed in ChiliProject 3.0. Please use WatchersHelper#watcher_link instead. Please also note the differences between the APIs.", caller
options[:id] ||= options[:replace] if options[:replace].is_a? String
options[:replace] = Array(options[:replace]).map { |id| "##{id}" }
watcher_link(object, user, options)
end
# Create a link to watch/unwatch object # Create a link to watch/unwatch object
# #
# * :replace - a string or array of strings with css selectors that will be updated, whenever the watcher status is changed # * :replace - a string or array of strings with css selectors that will be updated, whenever the watcher status is changed

@ -102,6 +102,11 @@ class WorkPackage < ActiveRecord::Base
:conditions => ::Query.merge_conditions(query.statement) :conditions => ::Query.merge_conditions(query.statement)
} }
} }
scope :with_author, lambda { |author|
{:conditions => {:author_id => author.id}}
}
# <<< issues.rb <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # <<< issues.rb <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
after_initialize :set_default_values after_initialize :set_default_values

@ -30,9 +30,8 @@ See doc/COPYRIGHT.rdoc for more details.
:limit => 10, :limit => 10,
:include => [ :status, :project, :type ], :include => [ :status, :project, :type ],
:order => "#{WorkPackage.table_name}.updated_at DESC") %> :order => "#{WorkPackage.table_name}.updated_at DESC") %>
<% reported_count = WorkPackage.visible.count(:conditions => { :author_id => User.current.id }) %>
<h3><%=l(:label_reported_work_packages)%> (<%= reported_count %>)</h3> <h3><%=l(:label_reported_work_packages)%> (<%= @reported_count %>)</h3>
<% if defined? block_name %> <% if defined? block_name %>
<%= content_for "#{block_name}_remove_block" %> <%= content_for "#{block_name}_remove_block" %>

@ -80,7 +80,7 @@ See doc/COPYRIGHT.rdoc for more details.
<%= link_to l(:label_activity), :controller => '/activities', :action => 'index', :id => nil, :user_id => @user, :from => @events_by_day.keys.first %> <%= link_to l(:label_activity), :controller => '/activities', :action => 'index', :id => nil, :user_id => @user, :from => @events_by_day.keys.first %>
</h3> </h3>
<p> <p>
<%=l(:label_reported_work_packages)%>: <%= WorkPackage.count(:conditions => ["author_id=?", @user.id]) %> <%=l(:label_reported_work_packages)%>: <%= @reported_count %>
</p> </p>
<div id="activity"> <div id="activity">
<% @events_by_day.keys.sort.reverse.each do |day| %> <% @events_by_day.keys.sort.reverse.each do |day| %>

@ -54,13 +54,13 @@ See doc/COPYRIGHT.rdoc for more details.
* `#4118` Fix: Add missing labels * `#4118` Fix: Add missing labels
* `#4701` Fix: Wiki change notification mail contains invalid diff link * `#4701` Fix: Wiki change notification mail contains invalid diff link
* `#4928` Fix: Journal note hits not shown * `#4928` Fix: Journal note hits not shown
* `#5002` Fix: Number of reported work packages in personal activity differs from number in My page
* `#5057` Fix: Whitelisted more params for planning elements controller * `#5057` Fix: Whitelisted more params for planning elements controller
* `#5214` Allow setting watchers and time entries for work packages via API` * `#5214` Allow setting watchers and time entries for work packages via API`
* `#5311` Encapsulate ActiveSupport::Notifications * `#5311` Encapsulate ActiveSupport::Notifications
* `#5553` Integrate OmniAuth * `#5553` Integrate OmniAuth
* `#5632` Check whether cookies are not shared between sub-uris * `#5632` Check whether cookies are not shared between sub-uris
* `#6309` Remove API v1 & add level_list to API v2 * `#6309` Remove API v1 & add level_list to API v2
* `#6310` API v1 is now deprecated and will be removed in the next major release of OpenProject
* `#6310` API v2 is now deprecated and will be removed in a future version of OpenProject * `#6310` API v2 is now deprecated and will be removed in a future version of OpenProject
* `#7050` Fix: Cannot change the login when login is already taken during creation of account * `#7050` Fix: Cannot change the login when login is already taken during creation of account
* `#7051` Wrong success message when user is not allowed to register himself * `#7051` Wrong success message when user is not allowed to register himself
@ -70,6 +70,7 @@ See doc/COPYRIGHT.rdoc for more details.
* Allow adding attachments to created work packages via planning elements controller * Allow adding attachments to created work packages via planning elements controller
* Remove unused rmagick dependency * Remove unused rmagick dependency
* Add settings callback * Add settings callback
* Use Lato 2.0 font
* Fix: Work package short URI * Fix: Work package short URI
* Fix: work package due date not validated when start date is not present * Fix: work package due date not validated when start date is not present
* Fix: Use correct questions for deletion of documents/files in rake tasks * Fix: Use correct questions for deletion of documents/files in rake tasks
@ -78,6 +79,14 @@ See doc/COPYRIGHT.rdoc for more details.
* Fix: Asset require for plug-ins * Fix: Asset require for plug-ins
* Fix: at.who styling * Fix: at.who styling
## 3.0.2
* `#1725` Content-sniffing-based XSS for attachments
* `#6310` API v1 is now deprecated and will be removed in the next major release of OpenProject
* `#7056` Enable Active Record Session Store
* `#7177` Fix: Journal not created in connection with deleted note
* `#7295` Fix: Regression in Ruby 2.1.1
## 3.0.1 ## 3.0.1
* `#5265` Fix: Error adding Work Package * `#5265` Fix: Error adding Work Package

@ -27,6 +27,7 @@
#++ #++
require 'spec_helper' require 'spec_helper'
require 'work_package'
describe MyController, :type => :controller do describe MyController, :type => :controller do
let(:user) { FactoryGirl.create(:user) } let(:user) { FactoryGirl.create(:user) }
@ -126,4 +127,12 @@ describe MyController, :type => :controller do
end end
end end
end end
describe "index" do
it "uses the correct scopes for number of reported work packages(just like users_controller)" do
WorkPackage.should_receive(:on_active_project).and_return(WorkPackage.where :id => 0)
WorkPackage.should_receive(:with_author).and_return(WorkPackage.where :id => 0)
get :index
end
end
end end

@ -27,6 +27,7 @@
#++ #++
require 'spec_helper' require 'spec_helper'
require 'work_package'
describe UsersController do describe UsersController do
before do before do
@ -505,5 +506,11 @@ describe UsersController do
it { get :show, id: user.id } it { get :show, id: user.id }
end end
it "uses the correct scopes for number of reported work packages(just like my_controller)" do
WorkPackage.should_receive(:on_active_project).and_return(WorkPackage.where :id => 0)
WorkPackage.should_receive(:with_author).and_return(WorkPackage.where :id => 0)
get :show, id: user.id
end
end end
end end

@ -803,11 +803,10 @@ describe WorkPackage do
describe :on_active_project do describe :on_active_project do
let(:project_archived) { FactoryGirl.create(:project, let(:project_archived) { FactoryGirl.create(:project,
status: Project::STATUS_ARCHIVED) } status: Project::STATUS_ARCHIVED) }
let(:work_package) { FactoryGirl.create(:work_package) } let!(:work_package) { FactoryGirl.create(:work_package) }
let(:work_package_in_archived_project) { FactoryGirl.create(:work_package, let(:work_package_in_archived_project) { FactoryGirl.create(:work_package,
project: project_archived) } project: project_archived) }
before { work_package }
subject { WorkPackage.on_active_project.length } subject { WorkPackage.on_active_project.length }
@ -822,6 +821,29 @@ describe WorkPackage do
end end
end end
describe :with_author do
let(:user) { FactoryGirl.create(:user) }
let(:project_archived) { FactoryGirl.create(:project,
status: Project::STATUS_ARCHIVED) }
let!(:work_package) { FactoryGirl.create(:work_package, :author => user) }
let(:work_package_in_archived_project) { FactoryGirl.create(:work_package,
:project => project_archived,
:author => user) }
subject { WorkPackage.with_author(user).length }
context "one work package in active projects" do
it { should eq(1) }
context "and one work package in archived projects" do
before { work_package_in_archived_project }
it { should eq(2) }
end
end
end
describe :recipients do describe :recipients do
let(:project) { FactoryGirl.create(:project) } let(:project) { FactoryGirl.create(:project) }
let(:member) { FactoryGirl.create(:user) } let(:member) { FactoryGirl.create(:user) }

@ -1,78 +0,0 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
require File.expand_path('../../../test_helper', __FILE__)
class WatchersHelperTest < HelperTestCase
include WatchersHelper
# tested for backwards compatibility
context '#watcher_tag' do
setup do
# mocking watcher_link to make sure, that new API is properly called from
# the old one.
def self.watcher_link(*args)
@watcher_link_args = args
nil
end
# silencing deprecation warnings while testing the deprecated behavior
def self.watcher_tag(*args)
ActiveSupport::Deprecation.silence { super }
end
end
context 'without options' do
should "call watcher_link with object, user and {:id => 'watcher', :replace => '#watcher'}" do
watcher_tag(:object, :user)
assert_equal :object, @watcher_link_args.first
assert_equal :user, @watcher_link_args.second
assert_equal({:id => 'watcher', :replace => ['#watcher']}, @watcher_link_args.third)
end
end
context 'with replace, without id option' do
should "set id to replace value and prefix replace with a # to make it a valid css selectors" do
watcher_tag(:object, :user, :replace => 'abc')
assert_equal :object, @watcher_link_args.first
assert_equal :user, @watcher_link_args.second
assert_equal({:id => 'abc', :replace => ['#abc']}, @watcher_link_args.third)
end
end
context 'with all options' do
should "prefix all elements in replace with a # to make them valid css selectors" do
watcher_tag(:object, :user, :id => 'abc', :replace => ['abc', 'def'])
assert_equal :object, @watcher_link_args.first
assert_equal :user, @watcher_link_args.second
assert_equal({:id => 'abc', :replace => ['#abc', '#def']}, @watcher_link_args.third)
end
end
end
end
Loading…
Cancel
Save