redmine_crm 0.0.36 → 0.0.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +160 -33
- data/Rakefile +3 -12
- data/bitbucket-pipelines.yml +20 -6
- data/doc/CHANGELOG +5 -0
- data/lib/redmine_crm.rb +5 -0
- data/lib/redmine_crm/acts_as_draftable/draft.rb +40 -0
- data/lib/redmine_crm/acts_as_draftable/rcrm_acts_as_draftable.rb +154 -0
- data/lib/redmine_crm/acts_as_taggable/rcrm_acts_as_taggable.rb +1 -1
- data/lib/redmine_crm/acts_as_viewed/rcrm_acts_as_viewed.rb +0 -1
- data/lib/redmine_crm/acts_as_votable/votable.rb +6 -10
- data/lib/redmine_crm/helpers/form_tag_helper.rb +31 -0
- data/lib/redmine_crm/money_helper.rb +0 -2
- data/lib/redmine_crm/version.rb +1 -1
- data/redmine_crm.gemspec +6 -1
- data/test/acts_as_draftable/draft_test.rb +29 -0
- data/test/acts_as_draftable/rcrm_acts_as_draftable_test.rb +185 -0
- data/test/acts_as_taggable/rcrm_acts_as_taggable_test.rb +9 -11
- data/test/acts_as_taggable/tag_list_test.rb +25 -29
- data/test/acts_as_taggable/tag_test.rb +58 -51
- data/test/acts_as_votable/rcrm_acts_as_votable_test.rb +6 -4
- data/test/acts_as_votable/rcrm_acts_as_voter_test.rb +7 -5
- data/test/acts_as_votable/votable_test.rb +1 -1
- data/test/database.yml +14 -18
- data/test/models/issue.rb +14 -0
- data/test/{fixtures → models}/news.rb +0 -0
- data/test/{fixtures → models}/project.rb +0 -0
- data/test/{fixtures → models}/user.rb +0 -0
- data/test/{fixtures → models}/vote_classes.rb +0 -20
- data/test/schema.rb +9 -1
- data/test/test_helper.rb +5 -57
- data/vendor/assets/javascripts/select2_helpers.js +39 -0
- metadata +75 -14
- data/test/fixtures/issue.rb +0 -22
- data/test/liquid/drops/liquid_test.rb +0 -52
@@ -85,21 +85,17 @@ module RedmineCrm
|
|
85
85
|
vote = votes_for.last
|
86
86
|
end
|
87
87
|
|
88
|
-
last_update = vote.updated_at
|
89
|
-
|
90
88
|
vote.vote_flag = votable_words.meaning_of(options[:vote])
|
91
89
|
|
92
90
|
# Allowing for a vote_weight to be associated with every vote. Could change with every voter object
|
93
91
|
vote.vote_weight = (options[:vote_weight].to_i if options[:vote_weight].present?) || 1
|
94
92
|
|
95
|
-
if vote.
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
return false
|
102
|
-
end
|
93
|
+
return false if vote.invalid?
|
94
|
+
|
95
|
+
self.vote_registered = vote.changed?
|
96
|
+
vote.save!(validate: false)
|
97
|
+
update_cached_votes(options[:vote_scope])
|
98
|
+
vote
|
103
99
|
end
|
104
100
|
|
105
101
|
def unvote(args = {})
|
@@ -49,6 +49,37 @@ module RedmineCrm
|
|
49
49
|
|
50
50
|
alias select2 select2_tag
|
51
51
|
|
52
|
+
# Transforms select filter field into select2
|
53
|
+
#
|
54
|
+
# ==== Examples
|
55
|
+
# transform_to_select2 'issue_tags', url: auto_complete_tags_url
|
56
|
+
# transform_to_select2 'manager_id', format_state: 'formatStateWithAvatar', min_input_length: 1, url: '/managers'
|
57
|
+
#
|
58
|
+
# ==== Options
|
59
|
+
# * <tt>:url</tt> Defines URL to search remote data using the ajax.
|
60
|
+
# * <tt>:format_state</tt> Defines template of search results in the drop-down.
|
61
|
+
# * <tt>:min_input_length</tt> Minimum number of characters required to start a search. Default value 0.
|
62
|
+
# * <tt>:width</tt> Sets the width of the control. Default value '60%'.
|
63
|
+
#
|
64
|
+
def transform_to_select2(field, options = {})
|
65
|
+
return if field.empty?
|
66
|
+
|
67
|
+
result = ''.html_safe
|
68
|
+
unless @transform_to_select2_included
|
69
|
+
result << javascript_include_tag('select2_helpers', plugin: 'redmine_crm')
|
70
|
+
@transform_to_select2_included = true
|
71
|
+
end
|
72
|
+
|
73
|
+
result << javascript_tag(<<-JS)
|
74
|
+
select2Filters['#{field}'] = {
|
75
|
+
url: '#{options[:url].to_s}',
|
76
|
+
formatState: #{options.fetch(:format_state, 'undefined')},
|
77
|
+
minimumInputLength: #{options.fetch(:min_input_length, 0)},
|
78
|
+
width: '#{options.fetch(:with, '60%')}'
|
79
|
+
};
|
80
|
+
JS
|
81
|
+
end
|
82
|
+
|
52
83
|
private
|
53
84
|
|
54
85
|
def select2_data_source_options(options = {})
|
data/lib/redmine_crm/version.rb
CHANGED
data/redmine_crm.gemspec
CHANGED
@@ -18,5 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency '
|
21
|
+
spec.add_runtime_dependency 'rails'
|
22
|
+
spec.add_runtime_dependency 'liquid', '< 2.6.4'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'sqlite3'
|
25
|
+
spec.add_development_dependency 'mysql2', '~> 0.4.0'
|
26
|
+
spec.add_development_dependency 'pg'
|
22
27
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
class DraftTest < ActiveSupport::TestCase
|
4
|
+
def test_restore
|
5
|
+
issue = Issue.new(subject: 'some subject', description: 'some description')
|
6
|
+
|
7
|
+
issue.save_draft(current_user)
|
8
|
+
restored_issue = RedmineCrm::ActsAsDraftable::Draft.find(issue.draft_id).restore
|
9
|
+
|
10
|
+
assert_equal issue.subject, restored_issue.subject
|
11
|
+
assert_equal issue.description, restored_issue.description
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_restore_all
|
15
|
+
first_issue = Issue.new(subject: 'first subject')
|
16
|
+
first_issue.save_draft(current_user)
|
17
|
+
second_issue = Issue.new(subject: 'second subject')
|
18
|
+
second_issue.save_draft(current_user)
|
19
|
+
|
20
|
+
restored_issues = RedmineCrm::ActsAsDraftable::Draft.restore_all
|
21
|
+
assert_equal [first_issue.subject, second_issue.subject], restored_issues.map(&:subject).sort
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def current_user
|
27
|
+
users(:sam)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
class RcrmActsAsDraftableTest < ActiveSupport::TestCase
|
4
|
+
def test_rcrm_acts_as_draftable_without_arguments
|
5
|
+
assert_nothing_raised do
|
6
|
+
Project.rcrm_acts_as_draftable
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class SomeClass < ActiveRecord::Base; end
|
11
|
+
def test_rcrm_acts_as_draftable_with_parent
|
12
|
+
assert_nothing_raised do
|
13
|
+
News.rcrm_acts_as_draftable(parent: :author)
|
14
|
+
end
|
15
|
+
assert User.new.respond_to?(:drafts)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_rcrm_acts_as_draftable_with_non_existing_parent
|
19
|
+
assert_raises do
|
20
|
+
Issue.rcrm_acts_as_draftable(parent: :foo)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_rcrm_acts_as_draftable_with_non_hash_argument
|
25
|
+
assert_raises do
|
26
|
+
Issue.rcrm_acts_as_draftable('bar')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_rcrm_acts_as_draftable_with_invalid_hash_key
|
31
|
+
assert_raises do
|
32
|
+
Issue.rcrm_acts_as_draftable(baz: 'qux')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_drafts
|
37
|
+
issue = Issue.new
|
38
|
+
issue.save_draft(current_user)
|
39
|
+
|
40
|
+
assert_equal 1, Issue.drafts(current_user).count
|
41
|
+
assert_equal RedmineCrm::ActsAsDraftable::Draft, Issue.drafts(current_user).first.class
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_from_draft
|
45
|
+
issue = Issue.new(subject: 'subject')
|
46
|
+
issue.save_draft(current_user)
|
47
|
+
|
48
|
+
issue_from_draft = Issue.from_draft(issue.draft_id)
|
49
|
+
|
50
|
+
assert_equal Issue, issue_from_draft.class
|
51
|
+
assert_equal true, issue_from_draft.new_record?
|
52
|
+
assert_equal issue.draft_id, issue_from_draft.draft_id
|
53
|
+
|
54
|
+
assert_equal issue.subject, issue_from_draft.subject
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_draft_deleted_after_save
|
58
|
+
issue = Issue.new(subject: 'subject')
|
59
|
+
issue.save_draft(current_user)
|
60
|
+
|
61
|
+
issue_from_draft = Issue.from_draft(issue.draft_id)
|
62
|
+
|
63
|
+
assert_difference 'Issue.count', 1 do
|
64
|
+
assert_difference 'RedmineCrm::ActsAsDraftable::Draft.count', -1 do
|
65
|
+
issue_from_draft.save!
|
66
|
+
end
|
67
|
+
end
|
68
|
+
assert_nil issue_from_draft.draft_id
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_from_draft_with_non_existing_draft_id
|
72
|
+
assert_raises do
|
73
|
+
Issue.from_draft(999)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_from_draft_with_wrong_type
|
78
|
+
Project.rcrm_acts_as_draftable
|
79
|
+
|
80
|
+
project = Project.new
|
81
|
+
project.save_draft(current_user)
|
82
|
+
|
83
|
+
assert_raises do
|
84
|
+
Issue.from_draft(project.draft_id)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_dump_to_draft
|
89
|
+
assert_equal String, Issue.new.dump_to_draft.class
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_load_to_draft
|
93
|
+
attributes = {subject: 'subject', description: 'description'}
|
94
|
+
draft = Issue.new(attributes).dump_to_draft
|
95
|
+
|
96
|
+
issue = Issue.new
|
97
|
+
issue.load_from_draft(draft)
|
98
|
+
|
99
|
+
assert_equal attributes[:subject], issue.subject
|
100
|
+
assert_equal attributes[:description], issue.description
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_save_draft
|
104
|
+
attributes = {subject: 'subject'}
|
105
|
+
issue = Issue.new(attributes)
|
106
|
+
|
107
|
+
assert_difference 'Issue.count', 0 do
|
108
|
+
assert_difference 'RedmineCrm::ActsAsDraftable::Draft.count', 1 do
|
109
|
+
result = issue.save_draft(current_user)
|
110
|
+
assert_equal true, result
|
111
|
+
end
|
112
|
+
end
|
113
|
+
assert_equal Fixnum, issue.draft_id.class
|
114
|
+
|
115
|
+
|
116
|
+
draft = RedmineCrm::ActsAsDraftable::Draft.find(issue.draft_id)
|
117
|
+
assert_equal 'Issue', draft.target_type
|
118
|
+
assert_equal current_user.id, draft.user_id
|
119
|
+
assert_equal attributes[:subject], draft.restore.subject
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_save_draft_without_user
|
123
|
+
issue = Issue.new
|
124
|
+
|
125
|
+
assert_difference 'Issue.count', 0 do
|
126
|
+
assert_difference 'RedmineCrm::ActsAsDraftable::Draft.count', 1 do
|
127
|
+
result = issue.save_draft
|
128
|
+
assert_equal true, result
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
draft = RedmineCrm::ActsAsDraftable::Draft.find(issue.draft_id)
|
133
|
+
assert_nil draft.user_id
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_save_draft_with_associations
|
137
|
+
issue = Issue.new(project: projects(:second_project))
|
138
|
+
issue.save_draft(current_user)
|
139
|
+
|
140
|
+
draft = RedmineCrm::ActsAsDraftable::Draft.find(issue.draft_id)
|
141
|
+
assert_equal issue.project.name, draft.restore.project.name
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_save_draft_updates_existing_draft
|
145
|
+
issue = Issue.new
|
146
|
+
issue.save_draft(current_user)
|
147
|
+
|
148
|
+
issue.subject = 'changed subject'
|
149
|
+
assert_difference 'Issue.count', 0 do
|
150
|
+
assert_difference 'RedmineCrm::ActsAsDraftable::Draft.count', 0 do
|
151
|
+
issue.save_draft(current_user)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
draft = RedmineCrm::ActsAsDraftable::Draft.find(issue.draft_id)
|
156
|
+
assert_equal issue.subject, draft.restore.subject
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_save_draft_does_not_save_persisted_model
|
160
|
+
issue = Issue.new
|
161
|
+
issue.save_draft(current_user)
|
162
|
+
issue.save!
|
163
|
+
assert_equal false, issue.save_draft(current_user)
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_update_draft
|
167
|
+
issue = Issue.new(subject: 'subject')
|
168
|
+
issue.save_draft(current_user)
|
169
|
+
|
170
|
+
assert_difference 'Issue.count', 0 do
|
171
|
+
assert_difference 'RedmineCrm::ActsAsDraftable::Draft.count', 0 do
|
172
|
+
issue.update_draft(current_user, subject: 'updated_subject')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
draft = RedmineCrm::ActsAsDraftable::Draft.find(issue.draft_id)
|
177
|
+
assert_equal issue.subject, draft.restore.subject
|
178
|
+
end
|
179
|
+
|
180
|
+
private
|
181
|
+
|
182
|
+
def current_user
|
183
|
+
users(:sam)
|
184
|
+
end
|
185
|
+
end
|
@@ -221,9 +221,13 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
|
|
221
221
|
end
|
222
222
|
|
223
223
|
def test_tags_not_saved_if_validation_fails
|
224
|
-
|
225
|
-
|
226
|
-
|
224
|
+
issue = issues(:first_issue)
|
225
|
+
assert_equivalent ["error", "question"], issue.tag_list
|
226
|
+
|
227
|
+
issue.stub(:valid?, false) do
|
228
|
+
assert !issue.update_attributes(tag_list: "One, Two")
|
229
|
+
end
|
230
|
+
assert_equivalent ["error", "question"], Issue.find(issue.id).tag_list
|
227
231
|
end
|
228
232
|
|
229
233
|
def test_tag_list_accessors_on_new_record
|
@@ -291,10 +295,8 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
|
|
291
295
|
end
|
292
296
|
|
293
297
|
def test_find_tagged_with_using_sti
|
294
|
-
|
295
|
-
|
296
|
-
assert_equal [special_issue], SpecialIssue.find_tagged_with('Random')
|
297
|
-
assert SpecialIssue.find_tagged_with('Random').include?(special_issue)
|
298
|
+
issue = Issue.create!(description: 'Test', tag_list: 'Random')
|
299
|
+
assert_equal [issue], Issue.find_tagged_with('Random')
|
298
300
|
end
|
299
301
|
|
300
302
|
def test_case_insensitivity
|
@@ -329,10 +331,6 @@ class RcrmActsAsTaggableTest < ActiveSupport::TestCase
|
|
329
331
|
RedmineCrm::ActsAsTaggable::Tag.destroy_unused = false
|
330
332
|
end
|
331
333
|
|
332
|
-
def test_quote_value
|
333
|
-
assert_equal "'RedmineCrm::ActsAsTaggable::Tag'", Issue.send(:quote_value, RedmineCrm::ActsAsTaggable::Tag)
|
334
|
-
end
|
335
|
-
|
336
334
|
def test_tags_condition
|
337
335
|
assert_equal "(tags_TABLE.name LIKE #{tags(:feature).id} OR tags_TABLE.name LIKE #{tags(:bug).id})",
|
338
336
|
Issue.send(:tags_condition, [tags(:feature), tags(:bug)], 'tags_TABLE')
|
@@ -1,38 +1,34 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@tag_list = TagList.new(%w(error bug))
|
8
|
-
end
|
3
|
+
class TagListTest < ActiveSupport::TestCase
|
4
|
+
def setup
|
5
|
+
@tag_list = RedmineCrm::ActsAsTaggable::TagList.new(%w(error bug))
|
6
|
+
end
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
def test_from
|
9
|
+
assert_equal %w(one two three), RedmineCrm::ActsAsTaggable::TagList.from('one, two, two, three, three, three')
|
10
|
+
end
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
def test_add
|
13
|
+
@tag_list.add(['new_tag'])
|
14
|
+
assert_equal %w(error bug new_tag), @tag_list
|
15
|
+
end
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
def test_remove
|
18
|
+
@tag_list.remove(['old_tag'])
|
19
|
+
assert_equal %w(error bug), @tag_list
|
20
|
+
@tag_list.remove(['error'])
|
21
|
+
assert_equal %w(bug), @tag_list
|
22
|
+
end
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
24
|
+
def test_toggle
|
25
|
+
@tag_list.toggle(['new_tag'])
|
26
|
+
assert_equal %w(error bug new_tag), @tag_list
|
27
|
+
@tag_list.toggle(['error'])
|
28
|
+
assert_equal %w(bug new_tag), @tag_list
|
29
|
+
end
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
31
|
+
def test_to_s
|
32
|
+
assert_equal 'error, bug', @tag_list.to_s
|
37
33
|
end
|
38
34
|
end
|
@@ -1,65 +1,72 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Tag.find_or_create_with_like_by_name('error')
|
9
|
-
end
|
10
|
-
|
11
|
-
assert_difference 'RedmineCrm::ActsAsTaggable::Tag.count', 1 do
|
12
|
-
Tag.find_or_create_with_like_by_name('new_tag')
|
13
|
-
end
|
14
|
-
end
|
3
|
+
class TagTest < ActiveSupport::TestCase
|
4
|
+
def test_find_or_create_with_like_by_name
|
5
|
+
assert_no_difference 'RedmineCrm::ActsAsTaggable::Tag.count' do
|
6
|
+
RedmineCrm::ActsAsTaggable::Tag.find_or_create_with_like_by_name('error')
|
7
|
+
end
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
assert_difference 'RedmineCrm::ActsAsTaggable::Tag.count', 1 do
|
10
|
+
RedmineCrm::ActsAsTaggable::Tag.find_or_create_with_like_by_name('new_tag')
|
11
|
+
end
|
12
|
+
end
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
14
|
+
def test_name_required
|
15
|
+
tag = RedmineCrm::ActsAsTaggable::Tag.new
|
16
|
+
tag.valid?
|
17
|
+
assert_match /blank/, tag.errors[:name].to_s
|
18
|
+
end
|
27
19
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
def test_name_unique
|
21
|
+
tag = RedmineCrm::ActsAsTaggable::Tag.create!(name: 'My tag')
|
22
|
+
tag_with_same_name = tag.dup
|
23
|
+
assert !tag_with_same_name.valid?
|
24
|
+
assert_match /not uniq/, tag_with_same_name.errors[:name].to_s
|
25
|
+
end
|
32
26
|
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
def test_taggings
|
28
|
+
assert_equivalent [taggings(:tag_for_error), taggings(:tag_for_error1), taggings(:tag_for_error2)], tags(:error).taggings
|
29
|
+
assert_equivalent [taggings(:tag_for_question1), taggings(:tag_for_question2), taggings(:tag_for_question3)], tags(:question).taggings
|
30
|
+
end
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
assert_equal Tag.new(:name => 'A'), Tag.new(:name => 'A')
|
41
|
-
assert_not_equal Tag.new(:name => 'A'), Tag.new(:name => 'B')
|
42
|
-
end
|
32
|
+
def test_to_s
|
33
|
+
assert_equal tags(:error).name, tags(:error).to_s
|
34
|
+
end
|
43
35
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
36
|
+
def test_tag_is_equal_to_itself
|
37
|
+
tag = tags(:error)
|
38
|
+
assert_equal tag, tag
|
39
|
+
end
|
49
40
|
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
def test_tag_is_equal_to_tag_with_same_name
|
42
|
+
tag = tags(:error)
|
43
|
+
assert_equal tag, tag.dup
|
44
|
+
end
|
53
45
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
46
|
+
def test_tag_is_not_equal_to_tag_with_other_name
|
47
|
+
tag = tags(:error)
|
48
|
+
other_tag = tag.dup
|
49
|
+
other_tag.name = 'not error'
|
50
|
+
assert_not_equal tag, other_tag
|
51
|
+
end
|
58
52
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
53
|
+
def test_taggings_removed_when_tag_destroyed
|
54
|
+
assert_difference("RedmineCrm::ActsAsTaggable::Tagging.count", -RedmineCrm::ActsAsTaggable::Tagging.where(tag_id: tags(:error).id).count) do
|
55
|
+
assert tags(:error).destroy
|
63
56
|
end
|
64
57
|
end
|
58
|
+
|
59
|
+
def test_all_counts
|
60
|
+
assert_tag_counts RedmineCrm::ActsAsTaggable::Tag.counts, error: 3, feature: 1, bug: 1, question: 3
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_all_counts_with_string_conditions
|
64
|
+
assert_tag_counts RedmineCrm::ActsAsTaggable::Tag.counts(conditions: 'taggings.created_at >= \'2015-01-01\''),
|
65
|
+
question: 3, error: 2, feature: 1, bug: 1
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_all_counts_with_array_conditions
|
69
|
+
assert_tag_counts RedmineCrm::ActsAsTaggable::Tag.counts(conditions: ['taggings.created_at >= ?', '2015-01-01']),
|
70
|
+
question: 3, error: 2, feature: 1, bug: 1
|
71
|
+
end
|
65
72
|
end
|