Merge branch 'dev' into feature/ui-component-table-widgets-merged

pull/1057/head
Alex Coles 11 years ago
commit b1f29335d6
  1. 10
      app/controllers/boards_controller.rb
  2. 4
      app/models/board.rb
  3. 10
      app/models/message.rb
  4. 2
      app/views/messages/show.html.erb
  5. 2
      app/views/news/index.html.erb
  6. 4
      app/views/news/show.html.erb
  7. 38
      db/migrate/20130813062523_fix_customizable_journal_value_column.rb
  8. 34
      db/migrate/20140311120609_add_sticked_on_field_to_messages.rb
  9. 2
      doc/CHANGELOG.md
  10. 15
      features/messages/message.feature
  11. 3
      features/step_definitions/common_steps.rb
  12. 59
      spec/controllers/boards_controller_spec.rb
  13. 22
      spec/models/work_package/work_package_custom_fields_spec.rb

@ -51,23 +51,25 @@ class BoardsController < ApplicationController
end
def show
respond_to do |format|
format.html {
sort_init 'updated_on', 'desc'
sort_update 'created_on' => "#{Message.table_name}.created_on",
'replies' => "#{Message.table_name}.replies_count",
'updated_on' => "#{Message.table_name}.updated_on"
@topics = @board.topics.order(["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '))
respond_to do |format|
format.html {
@topics = @board.topics.order(["#{Message.table_name}.sticked_on ASC", sort_clause].compact.join(', '))
.includes(:author, { :last_reply => :author })
.page(params[:page])
.per_page(per_page_param)
@message = Message.new
render :action => 'show', :layout => !request.xhr?
}
format.atom {
@messages = @board.messages.order('created_on DESC')
@messages = @board.messages.order(["#{Message.table_name}.sticked_on ASC", sort_clause].compact.join(', '))
.includes(:author, :board)
.limit(Setting.feeds_limit.to_i)

@ -31,8 +31,8 @@ class Board < ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
belongs_to :project
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL" , :order => "#{Message.table_name}.sticky DESC"
has_many :messages, :dependent => :destroy , :order => "#{Message.table_name}.sticky DESC"
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
acts_as_list :scope => :project_id
acts_as_watchable

@ -85,11 +85,21 @@ class Message < ActiveRecord::Base
validate :validate_unlocked_root, :on => :create
before_save :set_sticked_on_date
# Can not reply to a locked topic
def validate_unlocked_root
errors.add :base, 'Topic is locked' if root.locked? && self != root
end
def set_sticked_on_date
if sticky?
self.sticked_on = sticked_on.nil? ? Time.now : sticked_on
else
self.sticked_on = nil
end
end
def update_last_reply_in_parent
if parent
parent.reload.update_attribute(:last_reply_id, self.id)

@ -56,7 +56,7 @@ See doc/COPYRIGHT.rdoc for more details.
<div class="message">
<p><span class="author"><%= authoring @topic.created_on, @topic.author %></span></p>
<div class="wiki">
<%= textilizable(@topic.content, :attachments => @topic.attachments) %>
<%= textilizable(@topic.content, :object => @topic, :attachments => @topic.attachments) %>
</div>
<%= link_to_attachments @topic, :author => false %>
</div>

@ -38,7 +38,7 @@ See doc/COPYRIGHT.rdoc for more details.
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %></h3>
<p class="author"><%= authoring news.created_on, news.author %></p>
<div class="wiki">
<%= textilizable(news.summary.present? ? news.summary : truncate(news.description)) %>
<%= textilizable(news.summary.present? ? news.summary : truncate(news.description), :object => news) %>
</div>
<% end %>
<% end %>

@ -64,7 +64,7 @@ See doc/COPYRIGHT.rdoc for more details.
<p><% unless @news.summary.blank? %><em><%=h @news.summary %></em><br /><% end %>
<span class="author"><%= authoring @news.created_on, @news.author %></span></p>
<div class="wiki">
<%= textilizable(@news.description) %>
<%= textilizable(@news.description, :object => @news) %>
</div>
<br />
@ -82,7 +82,7 @@ See doc/COPYRIGHT.rdoc for more details.
:alt => l(:button_delete) %>
</div>
<h4 class="comment"><%= avatar(comment.author, :size => "24") %><%= authoring comment.created_on, comment.author %></h4>
<%= textilizable(comment.comments) %>
<%= textilizable(comment.comments, :object => comment) %>
<% end %>
</div>

@ -0,0 +1,38 @@
#-- 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.
#++
class FixCustomizableJournalValueColumn < ActiveRecord::Migration
def up
change_column :customizable_journals, :value, :text
end
def down
change_column :customizable_journals, :value, :string
end
end

@ -0,0 +1,34 @@
#-- 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.
#++
class AddStickedOnFieldToMessages < ActiveRecord::Migration
def change
add_column :messages, :sticked_on, :datetime, default: nil, null: true
end
end

@ -29,11 +29,13 @@ See doc/COPYRIGHT.rdoc for more details.
# Changelog
* `#284` Fix: Sticky does not apply to forum
* `#2393` Fix: No warning when leaving site without saving
* `#2401` Fix: New target version cannot be created from work package view
* `#3267` Fix: Link in Breadcrumbs links to global work packages
* `#3395` Fix: After error message values are gone during creation of message
* `#3531` Fix: Type 'None' cannot be configured via admin settings
* `#4040` Fix: Referencing work packages with ### in news, forums and meetings does not work
* `#4087` Ignore type list flash when activating flash messages
* `#4097` Fix accesskeys
* `#4118` Fix: Add missing labels

@ -27,6 +27,7 @@
#++
Feature: Issue textile quickinfo links
Background:
Given there is 1 project with the following:
| name | parent |
@ -86,3 +87,17 @@ Feature: Issue textile quickinfo links
When I click on the first button matching "Create"
Then there should be an error message
Then the "message_content" field should contain "Here you find the most frequently asked questions"
Scenario: Sticky message on top of messages list
Given the board "development discussion" has the following messages:
| message #1 |
| message #2 |
| message #3 |
When I go to the boards page of the project called "parent"
And I follow "New message"
And I fill in "How to?" for "message_subject"
And I fill in "How to st-up project on local mashine." for "message_content"
And I check "Sticky"
When I click on the first button matching "Create"
And I go to the boards page of the project called "parent"
Then "How to?" should be the first row in table

@ -75,3 +75,6 @@ Then(/^I should see the following fields:$/) do |table|
end
end
Then(/^"([^"]*)" should be the first row in table$/) do |name|
should have_selector("table.list tbody tr td", :text => Regexp.new("#{name}"))
end

@ -175,4 +175,63 @@ describe BoardsController do
end
end
describe :sticky do
let!(:message1) { FactoryGirl.create(:message, board: board) }
let!(:message2) { FactoryGirl.create(:message, board: board) }
let!(:sticked_message1) { FactoryGirl.create(:message, board_id: board.id, subject: "How to",
content: "How to install this cool app", sticky: "1", sticked_on: Time.now - 2.minute) }
let!(:sticked_message2) { FactoryGirl.create(:message, board_id: board.id, subject: "FAQ",
content: "Frequestly asked question", sticky: "1", sticked_on: Time.now - 1.minute) }
describe "all sticky messages" do
before do
@controller.should_receive(:authorize)
get :show, project_id: project.id, id: board.id
end
it { expect(response).to render_template 'show' }
it "should be displayed on top" do
expect(assigns[:topics][0].id).to eq(sticked_message1.id)
end
end
describe "edit a sticky message" do
before(:each) do
sticked_message1.sticky = 0
sticked_message1.save!
end
describe "when sticky is unset from message" do
before do
@controller.should_receive(:authorize)
get :show, project_id: project.id, id: board.id
end
it "it should not be displayed as sticky message" do
expect(sticked_message1.sticked_on).to be_nil
expect(assigns[:topics][0].id).to_not eq(sticked_message1.id)
end
end
describe "when sticky is set back to message" do
before do
sticked_message1.sticky = 1
sticked_message1.save!
@controller.should_receive(:authorize)
get :show, project_id: project.id, id: board.id
end
it "it should not be displayed on first position" do
expect(assigns[:topics][0].id).to eq(sticked_message2.id)
end
end
end
end
end

@ -229,5 +229,27 @@ describe WorkPackage do
it { should eq('true') }
end
end
describe "custom field type 'text'" do
let(:value) { "text" * 1024 }
let(:custom_field) { FactoryGirl.create(:work_package_custom_field,
name: 'Test Text',
field_format: 'text',
is_required: true) }
include_context "project with required custom field"
it_behaves_like "work package with required custom field"
describe 'value' do
before do
change_custom_field_value(work_package, value)
end
subject { work_package.journals.first.customizable_journals.first.value }
it { expect(subject).to eq(value) }
end
end
end
end

Loading…
Cancel
Save