redmine_crm 0.0.43 → 0.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +1 -1
  3. data/app/controllers/redmine_crm_controller.rb +26 -0
  4. data/app/views/redmine_crm/_money.html.erb +44 -0
  5. data/app/views/redmine_crm/settings.html.erb +10 -0
  6. data/bitbucket-pipelines.yml +1 -8
  7. data/config/currency_iso.json +1 -1
  8. data/config/locales/cs.yml +13 -0
  9. data/config/locales/de.yml +13 -0
  10. data/config/locales/en.yml +13 -0
  11. data/config/locales/es.yml +13 -0
  12. data/config/locales/ru.yml +13 -0
  13. data/config/routes.rb +5 -0
  14. data/doc/CHANGELOG +92 -1
  15. data/lib/redmine_crm/acts_as_draftable/draft.rb +1 -1
  16. data/lib/redmine_crm/acts_as_draftable/rcrm_acts_as_draftable.rb +4 -2
  17. data/lib/redmine_crm/acts_as_priceable/rcrm_acts_as_priceable.rb +33 -0
  18. data/lib/redmine_crm/acts_as_taggable/rcrm_acts_as_taggable.rb +10 -3
  19. data/lib/redmine_crm/acts_as_taggable/tag_list.rb +1 -1
  20. data/lib/redmine_crm/acts_as_viewed/rcrm_acts_as_viewed.rb +1 -1
  21. data/lib/redmine_crm/acts_as_votable/rcrm_acts_as_votable.rb +1 -1
  22. data/lib/redmine_crm/acts_as_votable/votable.rb +2 -2
  23. data/lib/redmine_crm/compatibility/routing_mapper_patch.rb +27 -0
  24. data/lib/redmine_crm/currency/formatting.rb +5 -5
  25. data/lib/redmine_crm/currency.rb +28 -17
  26. data/lib/redmine_crm/engine.rb +4 -0
  27. data/lib/redmine_crm/helpers/calendars_helper.rb +22 -0
  28. data/lib/redmine_crm/helpers/external_assets_helper.rb +1 -0
  29. data/lib/redmine_crm/helpers/form_tag_helper.rb +12 -0
  30. data/lib/redmine_crm/hooks/views_layouts_hook.rb +12 -0
  31. data/lib/redmine_crm/liquid/drops/attachment_drop.rb +47 -0
  32. data/lib/redmine_crm/liquid/drops/issue_relations_drop.rb +41 -0
  33. data/lib/redmine_crm/liquid/drops/issues_drop.rb +54 -28
  34. data/lib/redmine_crm/liquid/drops/time_entries_drop.rb +1 -1
  35. data/lib/redmine_crm/liquid/filters/arrays.rb +1 -1
  36. data/lib/redmine_crm/liquid/filters/base.rb +36 -4
  37. data/lib/redmine_crm/money_helper.rb +15 -14
  38. data/lib/redmine_crm/patches/liquid_patch.rb +33 -0
  39. data/lib/redmine_crm/settings/money.rb +46 -0
  40. data/lib/redmine_crm/settings.rb +53 -0
  41. data/lib/redmine_crm/version.rb +1 -1
  42. data/lib/redmine_crm.rb +15 -2
  43. data/redmine_crm.gemspec +4 -2
  44. data/test/acts_as_draftable/rcrm_acts_as_draftable_test.rb +0 -1
  45. data/test/acts_as_taggable/rcrm_acts_as_taggable_test.rb +97 -92
  46. data/test/fixtures/attachments.yml +14 -0
  47. data/test/liquid/drops/attachment_drop_test.rb +15 -0
  48. data/test/liquid/drops/issue_relations_drop_test.rb +24 -0
  49. data/test/liquid/drops/issues_drop_test.rb +4 -0
  50. data/test/liquid/filters/base_filter_test.rb +5 -1
  51. data/test/models/attachment.rb +3 -0
  52. data/test/models/issue.rb +7 -0
  53. data/test/models/issue_relation.rb +10 -0
  54. data/test/money_helper_test.rb +1 -1
  55. data/test/schema.rb +22 -1
  56. data/test/tags_helper_test.rb +4 -4
  57. data/vendor/assets/images/money.png +0 -0
  58. data/vendor/assets/javascripts/select2.js +2 -3
  59. data/vendor/assets/javascripts/select2_helpers.js +8 -2
  60. data/vendor/assets/javascripts/timepicker_addon.js +5 -0
  61. data/vendor/assets/stylesheets/calendars.css +15 -0
  62. data/vendor/assets/stylesheets/money.css +3 -0
  63. data/vendor/assets/stylesheets/select2.css +28 -18
  64. data/vendor/assets/stylesheets/timepicker_addon.css +5 -0
  65. metadata +57 -10
@@ -3,76 +3,81 @@ require File.dirname(__FILE__) + '/../test_helper'
3
3
  class RcrmActsAsTaggableTest < ActiveSupport::TestCase
4
4
  def test_available_tags
5
5
  assert_equivalent [tags(:feature), tags(:bug), tags(:error), tags(:question)], Issue.available_tags(Project.first)
6
- assert_equivalent [tags(:error), tags(:question)], Issue.available_tags(:project => Project.first, :limit => 2)
6
+ assert_equivalent [tags(:error), tags(:question)], Issue.available_tags(project: Project.first, limit: 2)
7
7
  end
8
8
 
9
9
  def test_find_related_tags_with
10
- assert_equivalent [tags(:feature), tags(:bug), tags(:question)], Issue.find_related_tags("error")
10
+ assert_equivalent [tags(:feature), tags(:bug), tags(:question)], Issue.find_related_tags('error')
11
11
  assert_equivalent [tags(:feature), tags(:error), tags(:question)], Issue.find_related_tags(tags(:bug))
12
- assert_equivalent [tags(:error), tags(:question)], Issue.find_related_tags(["New feature", "bug"])
12
+ assert_equivalent [tags(:error), tags(:question)], Issue.find_related_tags(['New feature', 'bug'])
13
13
  assert_equivalent [tags(:feature), tags(:bug)], Issue.find_related_tags([tags(:error), tags(:question)])
14
14
  end
15
15
 
16
16
  def test_find_tagged_with_include_and_order
17
- assert_equal issues(:third_issue, :first_issue, :second_issue), Issue.find_tagged_with("question", :order => "issues.description DESC", :include => :user).to_a
17
+ assert_equal issues(:third_issue, :first_issue, :second_issue),
18
+ Issue.find_tagged_with('question', order: 'issues.description DESC', include: :user).to_a
18
19
  end
19
20
 
20
21
  def test_find_related_tags_with_non_existent_tags
21
- assert_equal [], Issue.find_related_tags("ABCDEFG")
22
+ assert_equal [], Issue.find_related_tags('ABCDEFG')
22
23
  assert_equal [], Issue.find_related_tags(['HIJKLM'])
23
24
  end
24
25
 
25
26
  def test_find_related_tags_with_nothing
26
- assert_equal [], Issue.find_related_tags("")
27
+ assert_equal [], Issue.find_related_tags('')
27
28
  assert_equal [], Issue.find_related_tags([])
28
29
  end
29
30
 
30
31
  def test_find_tagged_with
31
- assert_equivalent [issues(:first_issue), issues(:second_issue), issues(:third_issue)], Issue.find_tagged_with('"error"')
32
+ assert_equivalent [issues(:first_issue), issues(:second_issue), issues(:third_issue)],
33
+ Issue.find_tagged_with('"error"')
32
34
  assert_equal Issue.find_tagged_with('"error"'), Issue.find_tagged_with(['error'])
33
35
  assert_equal Issue.find_tagged_with('"error"'), Issue.find_tagged_with([tags(:error)])
34
36
 
35
- assert_equivalent [issues(:second_issue),], Issue.find_tagged_with('New feature')
37
+ assert_equivalent [issues(:second_issue)], Issue.find_tagged_with('New feature')
36
38
  assert_equal Issue.find_tagged_with('New feature'), Issue.find_tagged_with(['New feature'])
37
39
  assert_equal Issue.find_tagged_with('New feature'), Issue.find_tagged_with([tags(:feature)])
38
40
  end
39
41
 
40
42
  def test_find_tagged_with_nothing
41
- assert_equal [], Issue.find_tagged_with("")
43
+ assert_equal [], Issue.find_tagged_with('')
42
44
  assert_equal [], Issue.find_tagged_with([])
43
45
  end
44
46
 
45
47
  def test_find_tagged_with_nonexistant_tags
46
48
  assert_equal [], Issue.find_tagged_with('ABCDEFG')
47
49
  assert_equal [], Issue.find_tagged_with(['HIJKLM'])
48
- assert_equal [], Issue.find_tagged_with([RedmineCrm::ActsAsTaggable::Tag.new(:name => 'unsaved tag')])
50
+ assert_equal [], Issue.find_tagged_with([RedmineCrm::ActsAsTaggable::Tag.new(name: 'unsaved tag')])
49
51
  end
50
52
 
51
53
  def test_find_tagged_with_match_all
52
- assert_equivalent [issues(:second_issue)], Issue.find_tagged_with('error, "bug", "New feature", "question"', :match_all => true)
54
+ assert_equivalent [issues(:second_issue)],
55
+ Issue.find_tagged_with('error, "bug", "New feature", "question"', match_all: true)
53
56
  end
54
57
 
55
58
  def test_find_tagged_with_match_all_and_include
56
- assert_equivalent [issues(:first_issue), issues(:second_issue), issues(:third_issue)], Issue.find_tagged_with(['error', 'question'], :match_all => true, :include => :tags)
59
+ assert_equivalent [issues(:first_issue), issues(:second_issue), issues(:third_issue)],
60
+ Issue.find_tagged_with(%w[error question], match_all: true, include: :tags)
57
61
  end
58
62
 
59
63
  def test_find_tagged_with_conditions
60
- assert_equal [], Issue.find_tagged_with('"error", bug', :conditions => '1=0')
64
+ assert_equal [], Issue.find_tagged_with('"error", bug', conditions: '1=0')
61
65
  end
62
66
 
63
67
  def test_find_tagged_with_duplicates_options_hash
64
- options = { :conditions => '1=1' }.freeze
65
- assert_nothing_raised { Issue.find_tagged_with("error", options) }
68
+ options = { conditions: '1=1' }.freeze
69
+ assert_nothing_raised { Issue.find_tagged_with('error', options) }
66
70
  end
67
71
 
68
72
  def test_find_tagged_with_exclusions
69
- assert_equivalent [issues(:first_issue), issues(:third_issue)], Issue.find_tagged_with("bug", :exclude => true)
70
- assert_equivalent [issues(:first_issue), issues(:third_issue)], Issue.find_tagged_with("'bug', feature", :exclude => true)
73
+ assert_equivalent [issues(:first_issue), issues(:third_issue)], Issue.find_tagged_with('bug', exclude: true)
74
+ assert_equivalent [issues(:first_issue), issues(:third_issue)],
75
+ Issue.find_tagged_with("'bug', feature", exclude: true)
71
76
  end
72
77
 
73
78
  def test_find_options_for_find_tagged_with_no_tags_returns_empty_hash
74
- assert_equal Hash.new, Issue.find_options_for_find_tagged_with("")
75
- assert_equal Hash.new, Issue.find_options_for_find_tagged_with([nil])
79
+ assert_equal({}, Issue.find_options_for_find_tagged_with(''))
80
+ assert_equal({}, Issue.find_options_for_find_tagged_with([nil]))
76
81
  end
77
82
 
78
83
  def test_find_options_for_find_tagged_with_leaves_arguments_unchanged
@@ -82,10 +87,10 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
82
87
  end
83
88
 
84
89
  def test_find_options_for_find_tagged_with_respects_custom_table_name
85
- RedmineCrm::ActsAsTaggable::Tagging.table_name = "categorisations"
86
- RedmineCrm::ActsAsTaggable::Tag.table_name = "categories"
90
+ RedmineCrm::ActsAsTaggable::Tagging.table_name = 'categorisations'
91
+ RedmineCrm::ActsAsTaggable::Tag.table_name = 'categories'
87
92
 
88
- options = Issue.find_options_for_find_tagged_with("Hello")
93
+ options = Issue.find_options_for_find_tagged_with('Hello')
89
94
 
90
95
  assert_no_match(/ taggings /, options[:joins])
91
96
  assert_no_match(/ tags /, options[:joins])
@@ -93,156 +98,156 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
93
98
  assert_match(/ categorisations /, options[:joins])
94
99
  assert_match(/ categories /, options[:joins])
95
100
  ensure
96
- RedmineCrm::ActsAsTaggable::Tagging.table_name = "taggings"
97
- RedmineCrm::ActsAsTaggable::Tag.table_name = "tags"
101
+ RedmineCrm::ActsAsTaggable::Tagging.table_name = 'taggings'
102
+ RedmineCrm::ActsAsTaggable::Tag.table_name = 'tags'
98
103
  end
99
104
 
100
105
  def test_include_tags_on_find_tagged_with
101
106
  assert_nothing_raised do
102
- Issue.find_tagged_with('error', :include => :tags)
103
- Issue.find_tagged_with("error", :include => { :taggings => :tag })
107
+ Issue.find_tagged_with('error', include: :tags)
108
+ Issue.find_tagged_with('error', include: { taggings: :tag })
104
109
  end
105
110
  end
106
111
 
107
112
  def test_basic_tag_counts_on_class
108
- assert_tag_counts Issue.tag_counts, :error => 3, :feature => 1, :question => 3, :bug => 1
113
+ assert_tag_counts Issue.tag_counts, error: 3, feature: 1, question: 3, bug: 1
109
114
  end
110
115
 
111
116
  def test_tag_counts_on_class_with_date_conditions
112
- assert_tag_counts Issue.tag_counts(:start_at => Date.new(2015, 1, 1)), :error => 2, :feature => 1, :question => 3, :bug => 1
113
- assert_tag_counts Issue.tag_counts(:end_at => Date.new(2014, 12, 31)), :error => 1
114
- assert_tag_counts Issue.tag_counts(:start_at => Date.new(2015, 1, 31), :end_at => Date.new(2015, 3, 1)), :question => 1
117
+ assert_tag_counts Issue.tag_counts(start_at: Date.new(2015, 1, 1)), error: 2, feature: 1, question: 3, bug: 1
118
+ assert_tag_counts Issue.tag_counts(end_at: Date.new(2014, 12, 31)), error: 1
119
+ assert_tag_counts Issue.tag_counts(start_at: Date.new(2015, 1, 31), end_at: Date.new(2015, 3, 1)), question: 1
115
120
  end
116
121
 
117
122
  def test_tag_counts_on_class_with_frequencies
118
- assert_tag_counts Issue.tag_counts(:at_least => 2), :question => 3, :error => 3
119
- assert_tag_counts Issue.tag_counts(:at_most => 2), :bug => 1, :feature => 1
123
+ assert_tag_counts Issue.tag_counts(at_least: 2), question: 3, error: 3
124
+ assert_tag_counts Issue.tag_counts(at_most: 2), bug: 1, feature: 1
120
125
  end
121
126
 
122
127
  def test_tag_counts_on_class_with_frequencies_and_conditions
123
- assert_tag_counts Issue.tag_counts(:at_least => 2, :conditions => '1=1'), :question => 3, :error => 3
128
+ assert_tag_counts Issue.tag_counts(at_least: 2, conditions: '1=1'), question: 3, error: 3
124
129
  end
125
130
 
126
131
  def test_tag_counts_duplicates_options_hash
127
- options = { :at_least => 2, :conditions => '1=1' }.freeze
132
+ options = { at_least: 2, conditions: '1=1' }.freeze
128
133
  assert_nothing_raised { Issue.tag_counts(options) }
129
134
  end
130
135
 
131
136
  def test_tag_counts_with_limit
132
- assert_equal 2, Issue.tag_counts(:limit => 2).to_a.size
133
- assert_equal 2, Issue.tag_counts(:at_least => 3, :limit => 2).to_a.size
137
+ assert_equal 2, Issue.tag_counts(limit: 2).to_a.size
138
+ assert_equal 2, Issue.tag_counts(at_least: 3, limit: 2).to_a.size
134
139
  end
135
140
 
136
141
  def test_tag_counts_with_limit_and_order
137
- assert_equivalent RedmineCrm::ActsAsTaggable::Tag.where(:id => [tags(:error), tags(:question)]), Issue.tag_counts(:order => 'count desc', :limit => 2)
142
+ assert_equivalent RedmineCrm::ActsAsTaggable::Tag.where(id: [tags(:error), tags(:question)]),
143
+ Issue.tag_counts(order: 'count desc', limit: 2)
138
144
  end
139
145
 
140
146
  def test_tag_counts_on_association
141
- assert_tag_counts users(:jonathan).issues.tag_counts, :error => 2, :bug => 1, :question => 2, :feature => 1
142
- assert_tag_counts users(:sam).issues.tag_counts, :error => 1, :question => 1
147
+ assert_tag_counts users(:jonathan).issues.tag_counts, error: 2, bug: 1, question: 2, feature: 1
148
+ assert_tag_counts users(:sam).issues.tag_counts, error: 1, question: 1
143
149
  end
144
150
 
145
151
  def test_tag_counts_on_association_with_options
146
- assert_equal [], users(:jonathan).issues.tag_counts(:conditions => '1=0')
147
- assert_tag_counts users(:jonathan).issues.tag_counts(:at_most => 2), :bug => 1,
148
- :feature => 1, :error => 2, :question => 2
152
+ assert_equal [], users(:jonathan).issues.tag_counts(conditions: '1=0')
153
+ assert_tag_counts users(:jonathan).issues.tag_counts(at_most: 2), bug: 1, feature: 1, error: 2, question: 2
149
154
  end
150
155
 
151
156
  def test_tag_counts_on_model_instance
152
- assert_tag_counts issues(:third_issue).tag_counts, :error => 3, :question => 3
157
+ assert_tag_counts issues(:third_issue).tag_counts, error: 3, question: 3
153
158
  end
154
159
 
155
160
  def test_tag_counts_on_model_instance_merges_conditions
156
- assert_tag_counts issues(:first_issue).tag_counts(:conditions => "tags.name = 'error'"), :error => 3
161
+ assert_tag_counts issues(:first_issue).tag_counts(conditions: "tags.name = 'error'"), error: 3
157
162
  end
158
163
 
159
164
  def test_tag_counts_on_model_instance_with_no_tags
160
- issue = Issue.create!(:description => "desc")
165
+ issue = Issue.create!(description: 'desc')
161
166
 
162
167
  assert_tag_counts issue.tag_counts, {}
163
168
  end
164
169
 
165
170
  def test_tag_counts_should_sanitize_scope_conditions
166
- Issue.send :where, { "tags.id = ?" => tags(:error).id } do
167
- assert_tag_counts Issue.tag_counts, :error => 3
171
+ Issue.send :where, { 'tags.id = ?' => tags(:error).id } do
172
+ assert_tag_counts Issue.tag_counts, error: 3
168
173
  end
169
174
  end
170
175
 
171
176
  def test_tag_counts_respects_custom_table_names
172
- RedmineCrm::ActsAsTaggable::Tagging.table_name = "categorisations"
173
- RedmineCrm::ActsAsTaggable::Tag.table_name = "categories"
177
+ RedmineCrm::ActsAsTaggable::Tagging.table_name = 'categorisations'
178
+ RedmineCrm::ActsAsTaggable::Tag.table_name = 'categories'
174
179
 
175
- options = Issue.find_options_for_tag_counts(:start_at => 2.weeks.ago, :end_at => Date.today)
180
+ options = Issue.find_options_for_tag_counts(start_at: 2.weeks.ago, end_at: Date.today)
176
181
  sql = options.values.join(' ')
177
182
 
178
- assert_no_match %r{taggings}, sql
179
- assert_no_match %r{tags}, sql
183
+ assert_no_match(/taggings/, sql)
184
+ assert_no_match(/tags/, sql)
180
185
 
181
- assert_match /categorisations/, sql
182
- assert_match /categories/, sql
186
+ assert_match(/categorisations/, sql)
187
+ assert_match(/categories/, sql)
183
188
  ensure
184
- RedmineCrm::ActsAsTaggable::Tagging.table_name = "taggings"
185
- RedmineCrm::ActsAsTaggable::Tag.table_name = "tags"
189
+ RedmineCrm::ActsAsTaggable::Tagging.table_name = 'taggings'
190
+ RedmineCrm::ActsAsTaggable::Tag.table_name = 'tags'
186
191
  end
187
192
 
188
193
  def test_tag_list_reader
189
- assert_equivalent ["error", "question"], issues(:first_issue).tag_list
190
- assert_equivalent ["error", "New feature", "bug", "question"], issues(:second_issue).tag_list
194
+ assert_equivalent %w[error question], issues(:first_issue).tag_list
195
+ assert_equivalent ['error', 'New feature', 'bug', 'question'], issues(:second_issue).tag_list
191
196
  end
192
197
 
193
198
  def test_reassign_tag_list
194
- assert_equivalent ["error", "question"], issues(:first_issue).tag_list
199
+ assert_equivalent %w[error question], issues(:first_issue).tag_list
195
200
  issues(:first_issue).taggings.reload
196
201
 
197
202
  # Only an update of the issues table should be executed, the other two queries are for savepoints
198
203
  # assert_queries 3 do
199
- # issues(:first_issue).update_attributes!(:description => "new name", :tag_list => issues(:first_issue).tag_list.to_s)
204
+ # issues(:first_issue).update!(:description => "new name", :tag_list => issues(:first_issue).tag_list.to_s)
200
205
  # end
201
206
 
202
- assert_equivalent ["error", "question"], issues(:first_issue).tag_list
207
+ assert_equivalent %w[error question], issues(:first_issue).tag_list
203
208
  end
204
209
 
205
210
  def test_new_tags
206
- assert_equivalent ["error", "question"], issues(:first_issue).tag_list
207
- issues(:first_issue).update_attributes!(:tag_list => "#{issues(:first_issue).tag_list}, One, Two")
208
- assert_equivalent ["error", "question", "One", "Two"], issues(:first_issue).tag_list
211
+ assert_equivalent %w[error question], issues(:first_issue).tag_list
212
+ issues(:first_issue).update!(tag_list: "#{issues(:first_issue).tag_list}, One, Two")
213
+ assert_equivalent %w[error question One Two], issues(:first_issue).tag_list
209
214
  end
210
215
 
211
216
  def test_remove_tag
212
- assert_equivalent ["error", "question"], issues(:first_issue).tag_list
213
- issues(:first_issue).update_attributes!(:tag_list => "error")
214
- assert_equivalent ["error"], issues(:first_issue).tag_list
217
+ assert_equivalent %w[error question], issues(:first_issue).tag_list
218
+ issues(:first_issue).update!(tag_list: 'error')
219
+ assert_equivalent ['error'], issues(:first_issue).tag_list
215
220
  end
216
221
 
217
222
  def test_remove_and_add_tag
218
- assert_equivalent ["error", "question"], issues(:first_issue).tag_list
219
- issues(:first_issue).update_attributes!(:tag_list => "question, Beautiful")
220
- assert_equivalent ["question", "Beautiful"], issues(:first_issue).tag_list
223
+ assert_equivalent %w[error question], issues(:first_issue).tag_list
224
+ issues(:first_issue).update!(tag_list: 'question, Beautiful')
225
+ assert_equivalent %w[question Beautiful], issues(:first_issue).tag_list
221
226
  end
222
227
 
223
228
  def test_tags_not_saved_if_validation_fails
224
229
  issue = issues(:first_issue)
225
- assert_equivalent ["error", "question"], issue.tag_list
230
+ assert_equivalent %w[error question], issue.tag_list
226
231
 
227
232
  issue.stub(:valid?, false) do
228
- assert !issue.update_attributes(tag_list: "One, Two")
233
+ assert !issue.update(tag_list: 'One, Two')
229
234
  end
230
- assert_equivalent ["error", "question"], Issue.find(issue.id).tag_list
235
+ assert_equivalent %w[error question], Issue.find(issue.id).tag_list
231
236
  end
232
237
 
233
238
  def test_tag_list_accessors_on_new_record
234
- p = Issue.new(:description => 'Test')
239
+ p = Issue.new(description: 'Test')
235
240
 
236
241
  assert p.tag_list.blank?
237
- p.tag_list = "One, Two"
238
- assert_equal "One, Two", p.tag_list.to_s
242
+ p.tag_list = 'One, Two'
243
+ assert_equal 'One, Two', p.tag_list.to_s
239
244
  end
240
245
 
241
246
  def test_clear_tag_list_with_nil
242
247
  p = issues(:second_issue)
243
248
 
244
249
  assert !p.tag_list.blank?
245
- assert p.update_attributes(:tag_list => nil)
250
+ assert p.update(tag_list: nil)
246
251
  assert p.tag_list.blank?
247
252
 
248
253
  assert p.reload.tag_list.blank?
@@ -252,7 +257,7 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
252
257
  p = issues(:second_issue)
253
258
 
254
259
  assert !p.tag_list.blank?
255
- assert p.update_attributes(:tag_list => ' ')
260
+ assert p.update(tag_list: ' ')
256
261
  assert p.tag_list.blank?
257
262
 
258
263
  assert p.reload.tag_list.blank?
@@ -267,7 +272,7 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
267
272
  end
268
273
 
269
274
  def test_instance_tag_counts
270
- assert_tag_counts issues(:first_issue).tag_counts, :error => 3, :question => 3
275
+ assert_tag_counts issues(:first_issue).tag_counts, error: 3, question: 3
271
276
  end
272
277
 
273
278
  def test_tag_list_populated_when_cache_nil
@@ -279,8 +284,8 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
279
284
  def test_cached_tag_list_updated
280
285
  assert_nil issues(:first_issue).cached_tag_list
281
286
  issues(:first_issue).save!
282
- assert_equivalent ["question", "error"], RedmineCrm::ActsAsTaggable::TagList.from(issues(:first_issue).cached_tag_list)
283
- issues(:first_issue).update_attributes!(:tag_list => "None")
287
+ assert_equivalent %w[question error], RedmineCrm::ActsAsTaggable::TagList.from(issues(:first_issue).cached_tag_list)
288
+ issues(:first_issue).update!(tag_list: 'None')
284
289
 
285
290
  assert_equal 'None', issues(:first_issue).cached_tag_list
286
291
  assert_equal 'None', issues(:first_issue).reload.cached_tag_list
@@ -290,8 +295,8 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
290
295
  # Generate the cached tag list
291
296
  issues(:first_issue).save!
292
297
 
293
- issues(:first_issue).update_attributes!(:tag_list => "")
294
- assert_equal "", issues(:first_issue).cached_tag_list
298
+ issues(:first_issue).update!(tag_list: '')
299
+ assert_equal '', issues(:first_issue).cached_tag_list
295
300
  end
296
301
 
297
302
  def test_find_tagged_with_using_sti
@@ -300,19 +305,19 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
300
305
  end
301
306
 
302
307
  def test_case_insensitivity
303
- assert_difference "RedmineCrm::ActsAsTaggable::Tag.count", 1 do
304
- Issue.create!(:description => "Test", :tag_list => "one")
305
- Issue.create!(:description => "Test", :tag_list => "One")
308
+ assert_difference 'RedmineCrm::ActsAsTaggable::Tag.count', 1 do
309
+ Issue.create!(description: 'Test', tag_list: 'one')
310
+ Issue.create!(description: 'Test', tag_list: 'One')
306
311
  end
307
- assert_equal Issue.find_tagged_with("question"), Issue.find_tagged_with("question")
312
+ assert_equal Issue.find_tagged_with('question'), Issue.find_tagged_with('question')
308
313
  end
309
314
 
310
315
  def test_tag_not_destroyed_when_unused
311
- issues(:first_issue).tag_list.add("Random")
316
+ issues(:first_issue).tag_list.add('Random')
312
317
  issues(:first_issue).save!
313
318
 
314
319
  assert_no_difference 'RedmineCrm::ActsAsTaggable::Tag.count' do
315
- issues(:first_issue).tag_list.remove("Random")
320
+ issues(:first_issue).tag_list.remove('Random')
316
321
  issues(:first_issue).save!
317
322
  end
318
323
  end
@@ -320,11 +325,11 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
320
325
  def test_tag_destroyed_when_unused
321
326
  RedmineCrm::ActsAsTaggable::Tag.destroy_unused = true
322
327
 
323
- issues(:first_issue).tag_list.add("Random")
328
+ issues(:first_issue).tag_list.add('Random')
324
329
  issues(:first_issue).save!
325
330
 
326
331
  assert_difference 'RedmineCrm::ActsAsTaggable::Tag.count', -1 do
327
- issues(:first_issue).tag_list.remove("Random")
332
+ issues(:first_issue).tag_list.remove('Random')
328
333
  issues(:first_issue).save!
329
334
  end
330
335
  ensure
@@ -340,6 +345,6 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
340
345
  issues(:first_issue).tag_list.remove('error')
341
346
  issues(:first_issue).tag_list.add('new')
342
347
  issues(:first_issue).save!
343
- assert_equal %w(question new), issues(:first_issue).reload.all_tags_list
348
+ assert_equal %w[question new], issues(:first_issue).reload.all_tags_list
344
349
  end
345
350
  end
@@ -0,0 +1,14 @@
1
+ attachment_001:
2
+ created_on: 2006-07-19 21:07:27 +02:00
3
+ downloads: 0
4
+ content_type: text/plain
5
+ disk_filename: 060719210727_error281.txt
6
+ disk_directory: "2006/07"
7
+ container_id: 3
8
+ digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
9
+ id: 1
10
+ container_type: Issue
11
+ filesize: 28
12
+ filename: error281.txt
13
+ author: jonathan
14
+ description: An attachment
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/../liquid_helper'
2
+
3
+ module RedmineCrm
4
+ class AttachmentDropTest < ActiveSupport::TestCase
5
+ def setup
6
+ @attachment = attachments(:attachment_001)
7
+ @user = @attachment.author
8
+ @liquid_render = LiquidRender.new('attachment' => Liquid::AttachmentDrop.new(@attachment))
9
+ end
10
+
11
+ def test_author
12
+ assert_equal @user.name, @liquid_render.render('{{ attachment.author.name }}')
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/../liquid_helper'
2
+ include LiquidHelperMethods
3
+
4
+ module RedmineCrm
5
+ class IssueRelationsDropTest < ActiveSupport::TestCase
6
+ def setup
7
+ @issue_from = Issue.find_by(subject: 'Issue 3 subject')
8
+ @issue_to = Issue.find_by(subject: 'Issue 4 subject')
9
+ @relation = IssueRelation.create!(issue_from: @issue_from, issue_to: @issue_to, relation_type: 'precedes', delay: 1)
10
+ @liquid_render = LiquidRender.new(
11
+ 'issue' => Liquid::IssueDrop.new(@issue_from)
12
+ )
13
+ end
14
+
15
+ def test_relation_from_render
16
+ issues_text = @liquid_render.render('{% for relation in issue.relations_from %} {{relation.issue_from.id}}|{{relation.issue_to.id}}|{{relation.relation_type}}|{{relation.delay}} {% endfor %}')
17
+ assert_match "#{@issue_from.id}|#{@issue_to.id}|precedes|#{@relation.delay}", issues_text
18
+ end
19
+
20
+ def test_relation_size
21
+ assert_equal '1', @liquid_render.render('{{ issue.relations_from.size }}')
22
+ end
23
+ end
24
+ end
@@ -29,6 +29,10 @@ module RedmineCrm
29
29
  def test_issue_delegated
30
30
  assert_equal [@issue.id, @issue.subject, @issue.description].join('|'),
31
31
  @liquid_render.render('{{ issue.id }}|{{ issue.subject }}|{{ issue.description }}')
32
+
33
+ assert_not_equal @issue.subject, @liquid_render.render('{% if issue.closed? %}{{issue.subject}}{% endif %}')
34
+ @issue.closed = true
35
+ assert_equal @issue.subject, @liquid_render.render('{% if issue.closed? %}{{issue.subject}}{% endif %}')
32
36
  end
33
37
  end
34
38
  end
@@ -52,12 +52,16 @@ module RedmineCrm
52
52
  assert_equal '25', @liquid_render.render("{{24.11 | ceil }}")
53
53
  end
54
54
 
55
+ def test_big_decimal_filter_patch
56
+ assert_equal '2.8571', @liquid_render.render("{{ 20 | divided_by: 7.0 | round: 4 }}")
57
+ end
58
+
55
59
  def test_floor_filter
56
60
  assert_equal '24', @liquid_render.render("{{24.99 | floor }}")
57
61
  end
58
62
 
59
63
  def test_currency_filter
60
- assert_equal '99,99 RUB', @liquid_render.render("{{99.99 | currency: 'RUB' }}")
64
+ assert_equal '99,99 ', @liquid_render.render("{{99.99 | currency: 'RUB' }}")
61
65
  end
62
66
  end
63
67
  end
@@ -0,0 +1,3 @@
1
+ class Attachment < ActiveRecord::Base
2
+ belongs_to :author, :class_name => "User"
3
+ end
data/test/models/issue.rb CHANGED
@@ -6,9 +6,16 @@ class Issue < ActiveRecord::Base
6
6
  belongs_to :user
7
7
  belongs_to :author, class_name: 'User'
8
8
 
9
+ has_many :relations_from, class_name: 'IssueRelation', foreign_key: 'issue_from_id', dependent: :delete_all
10
+ has_many :relations_to, class_name: 'IssueRelation', foreign_key: 'issue_to_id', dependent: :delete_all
11
+
9
12
  rcrm_acts_as_draftable
10
13
  rcrm_acts_as_taggable
11
14
  rcrm_acts_as_viewed
12
15
 
13
16
  scope :visible, lambda { where('1=1') }
17
+
18
+ def visible?
19
+ true
20
+ end
14
21
  end
@@ -0,0 +1,10 @@
1
+ require_relative 'issue'
2
+
3
+ class IssueRelation < ActiveRecord::Base
4
+ belongs_to :issue_from, :class_name => 'Issue'
5
+ belongs_to :issue_to, :class_name => 'Issue'
6
+
7
+ def other_issue(issue)
8
+ (self.issue_from_id == issue.id) ? issue_to : issue_from
9
+ end
10
+ end
@@ -5,7 +5,7 @@ class MoneyHelperTest < ActiveSupport::TestCase
5
5
 
6
6
  def test_price_to_currency
7
7
  assert_equal '$3,265.65', price_to_currency(3265.65, 'USD')
8
- assert_equal '3.265,65 RUB', price_to_currency(3265.65, 'RUB')
8
+ assert_equal '3.265,65 ', price_to_currency(3265.65, 'RUB')
9
9
  assert_equal '3,200.0', price_to_currency(3200, '')
10
10
  assert_equal '3,200.0', price_to_currency(3200, 'Foo')
11
11
  end
data/test/schema.rb CHANGED
@@ -1,5 +1,20 @@
1
1
  ActiveRecord::Schema.define version: 0 do
2
2
 
3
+ create_table :attachments, force: true do |t|
4
+ t.integer :container_id
5
+ t.string :container_type, limit: 30
6
+ t.string :filename, default: "", null: false
7
+ t.string :disk_filename, default: "", null: false
8
+ t.bigint :filesize, default: 0, null: false
9
+ t.string :content_type, default: ""
10
+ t.string :digest, limit: 64, default: "", null: false
11
+ t.integer :downloads, default: 0, null: false
12
+ t.integer :author_id, default: 0, null: false
13
+ t.timestamp :created_on
14
+ t.string :description
15
+ t.string :disk_directory
16
+ end
17
+
3
18
  create_table :drafts, force: true do |t|
4
19
  t.string :target_type
5
20
  t.integer :target_id
@@ -21,12 +36,18 @@ ActiveRecord::Schema.define version: 0 do
21
36
  t.column "created_at", :datetime
22
37
  end
23
38
 
24
-
25
39
  create_table "users", :force => true do |t|
26
40
  t.column "name", :string
27
41
  t.column "language", :string
28
42
  end
29
43
 
44
+ create_table "issue_relations", :force => true do |t|
45
+ t.column "issue_from_id", :integer
46
+ t.column "issue_to_id", :integer
47
+ t.column "relation_type", :string
48
+ t.column "delay", :integer
49
+ end
50
+
30
51
  create_table "issues", :force => true do |t|
31
52
  t.integer "project_id"
32
53
  t.column "subject", :string
@@ -3,10 +3,10 @@ require File.dirname(__FILE__) + '/test_helper'
3
3
  # module RedmineCrm
4
4
  class TagsHelperTest < ActiveSupport::TestCase
5
5
  include RedmineCrm::TagsHelper
6
-
6
+
7
7
  def test_tag_cloud
8
8
  cloud_elements = []
9
-
9
+
10
10
  tag_cloud Issue.tag_counts, %w(css1 css2 css3 css4) do |tag, css_class|
11
11
  cloud_elements << [tag, css_class]
12
12
  end
@@ -16,7 +16,7 @@ require File.dirname(__FILE__) + '/test_helper'
16
16
  assert cloud_elements.include?([tags(:feature), "css2"])
17
17
  assert_equal 4, cloud_elements.size
18
18
  end
19
-
19
+
20
20
  # def test_tag_cloud_when_no_tags
21
21
  # cloud_elements = []
22
22
  # tag_cloud SpecialIssue.tag_counts, %w(css1) do |tag, css_class|
@@ -26,4 +26,4 @@ require File.dirname(__FILE__) + '/test_helper'
26
26
  # assert_equal 0, cloud_elements.size
27
27
  # end
28
28
  end
29
- # end
29
+ # end
Binary file