Project

General

Profile

Patch #18059 » diff_all_in_one.diff

Marcin Świątkiewicz, 2014-10-10 14:15

View differences:

app/models/journal.rb
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
attr_accessor :indice
acts_as_event :title => Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}" },
acts_as_event :title => :event_title,
:description => :notes,
:author => :user,
:group => :issue,
......
acts_as_activity_provider :type => 'issues',
:author_key => :user_id,
:find_options => {:include => [{:issue => :project}, :details, :user],
:conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" +
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"}
:conditions => @conditions}
before_create :split_private_notes
after_create :send_notification
......
where("(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(user, :view_private_notes, *args)}))", false)
}
def event_title
data_for_assigned if new_status.blank? && !new_assigned.blank?
data_for_status if !new_status.blank? && new_assigned.blank?
data_for_assigned_and_status if !new_assigned.blank? && !new_assigned.blank?
@title = "" if @title.blank? # truncate
@title
end
def save(*args)
# Do not save an empty journal
(details.empty? && notes.blank?) ? false : super
......
s ? IssueStatus.find_by_id(s.to_i) : nil
end
def new_assigned
a = new_value_for('assigned_to_id')
a ? User.find(a.to_i) : nil
end
def new_value_for(prop)
detail_for_attribute(prop).try(:value)
end
......
Mailer.deliver_issue_edit(self)
end
end
def data_for_assigned
assigned = ((a = new_assigned) ? " #{a}" : nil)
query_for_assigned
@title = "##{issue.id} - now assigned to : (#{assigned})"
end
def data_for_status
status = ((s = new_status) ? " (#{s})" : nil)
query_for_status
@title = "#{issue.tracker} ##{issue.id}#{status}: #{issue.subject}"
end
def data_for_assigned_and_status
assigned = ((a = new_assigned) ? " #{a}" : nil)
status = ((s = new_status) ? " (#{s})" : nil)
query_for_assigned_and_status
@title = "#{issue.tracker} ##{issue.id}#{status}: #{issue.subject}. Now assigned to:(#{assigned})"
end
def query_for_assigned_and_status
@conditions = "#{Journal.table_name}.journalized_type = 'Issue' AND" +
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')" +
" (#{JournalDetail.table_name}.prop_key = 'assigned_to_id')"
end
def query_for_assigned
@conditions = "#{Journal.table_name}.journalized_type = 'Issue' AND" +
" (#{JournalDetail.table_name}.prop_key = 'assigned_to_id')"
end
def query_for_status
@conditions = "#{Journal.table_name}.journalized_type = 'Issue' AND" +
" (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"
end
end
config/database.yml.example
# Default setup is given for MySQL with ruby1.9. If you're running Redmine
# with MySQL and ruby1.8, replace the adapter name with `mysql`.
# Examples for PostgreSQL, SQLite3 and SQL Server can be found at the end.
# Line indentation must be 2 spaces (no tabs).
production:
adapter: mysql2
database: redmine
host: localhost
username: root
password: ""
encoding: utf8
development:
adapter: mysql2
database: redmine_development
host: localhost
username: root
password: ""
encoding: utf8
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
database: redmine_test
host: localhost
username: root
password: ""
encoding: utf8
# PostgreSQL configuration example
#production:
# adapter: postgresql
# database: redmine
# host: localhost
# username: postgres
# password: "postgres"
# SQLite3 configuration example
#production:
# adapter: sqlite3
# database: db/redmine.sqlite3
# SQL Server configuration example
#production:
# adapter: sqlserver
# database: redmine
# host: localhost
# username: jenkins
# password: jenkins
test/fixtures/journal_details.yml
value: 060719210727_picture.jpg
prop_key: 4
journal_id: 3
journal_details_007:
old_value: "1"
property: attr
id: 7
value: "4"
prop_key: "status_id"
journal_id: 6
journal_details_008:
old_value:
property: attr
id: 8
value: "2"
prop_key: "assigned_to_id"
journal_id: 6
test/fixtures/journals.yml
user_id: 2
journalized_type: Issue
journalized_id: 14
journals_006:
id: 6
created_on: <%= Date.today.to_date.to_s(:db) %>
notes: "Change Status And Assigned."
user_id: 2
journalized_type: Issue
journalized_id: 1
test/functional/activities_controller_test.rb
:journals, :journal_details
def test_edit_issue_with_new_assigned
issue = Project.find(1).issues.first
issue.status_id = 5
issue.save
get :index, :project_id => 1, :with_subprojects => 0
assert_not_nil assigns(:events_by_day)
assert_equal css_select('#activity dl dt a')[0].to_s[29..102], "Bug #1 (#{IssueStatus.find(4).name}): Can&#x27;t print recipes. Now assigned to:( #{User.find(2).name})"
end
def test_project_index
get :index, :id => 1, :with_subprojects => 0
assert_response :success
(5-5/6)