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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/README.md +160 -33
  4. data/Rakefile +3 -12
  5. data/bitbucket-pipelines.yml +20 -6
  6. data/doc/CHANGELOG +5 -0
  7. data/lib/redmine_crm.rb +5 -0
  8. data/lib/redmine_crm/acts_as_draftable/draft.rb +40 -0
  9. data/lib/redmine_crm/acts_as_draftable/rcrm_acts_as_draftable.rb +154 -0
  10. data/lib/redmine_crm/acts_as_taggable/rcrm_acts_as_taggable.rb +1 -1
  11. data/lib/redmine_crm/acts_as_viewed/rcrm_acts_as_viewed.rb +0 -1
  12. data/lib/redmine_crm/acts_as_votable/votable.rb +6 -10
  13. data/lib/redmine_crm/helpers/form_tag_helper.rb +31 -0
  14. data/lib/redmine_crm/money_helper.rb +0 -2
  15. data/lib/redmine_crm/version.rb +1 -1
  16. data/redmine_crm.gemspec +6 -1
  17. data/test/acts_as_draftable/draft_test.rb +29 -0
  18. data/test/acts_as_draftable/rcrm_acts_as_draftable_test.rb +185 -0
  19. data/test/acts_as_taggable/rcrm_acts_as_taggable_test.rb +9 -11
  20. data/test/acts_as_taggable/tag_list_test.rb +25 -29
  21. data/test/acts_as_taggable/tag_test.rb +58 -51
  22. data/test/acts_as_votable/rcrm_acts_as_votable_test.rb +6 -4
  23. data/test/acts_as_votable/rcrm_acts_as_voter_test.rb +7 -5
  24. data/test/acts_as_votable/votable_test.rb +1 -1
  25. data/test/database.yml +14 -18
  26. data/test/models/issue.rb +14 -0
  27. data/test/{fixtures → models}/news.rb +0 -0
  28. data/test/{fixtures → models}/project.rb +0 -0
  29. data/test/{fixtures → models}/user.rb +0 -0
  30. data/test/{fixtures → models}/vote_classes.rb +0 -20
  31. data/test/schema.rb +9 -1
  32. data/test/test_helper.rb +5 -57
  33. data/vendor/assets/javascripts/select2_helpers.js +39 -0
  34. metadata +75 -14
  35. data/test/fixtures/issue.rb +0 -22
  36. data/test/liquid/drops/liquid_test.rb +0 -52
@@ -1,12 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
3
  class RcrmActsAsVotableTest < ActiveSupport::TestCase
4
- def test_not_be_votable
5
- assert !NotVotable.votable?, false
4
+
5
+ class NotVotable < ActiveRecord::Base; end
6
+ def test_that_votable_returns_false_unless_included
7
+ assert_equal NotVotable.votable?, false
6
8
  end
7
9
 
8
- def test_be_votable
9
- assert Votable.votable?, true
10
+ def test_that_votable_returns_true_if_included
11
+ assert_equal Votable.votable?, true
10
12
  end
11
13
 
12
14
  def test_behaves_like_votable_model
@@ -1,12 +1,14 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
 
3
3
  class RcrmActsAsVoterTest < ActiveSupport::TestCase
4
- def test_not_be_votable
5
- assert !NotVoter.voter?, false
4
+
5
+ class NotVoter < ActiveRecord::Base; end
6
+ def test_that_voter_returns_false_unless_included
7
+ assert_equal NotVoter.voter?, false
6
8
  end
7
9
 
8
- def test_be_voter
9
- assert Voter.voter?, true
10
- assert VotableVoter.voter?, true
10
+ def test_that_voter_returns_true_if_included
11
+ assert_equal Voter.voter?, true
12
+ assert_equal VotableVoter.voter?, true
11
13
  end
12
14
  end
@@ -111,7 +111,7 @@ class VotableTest < ActiveSupport::TestCase
111
111
  assert votable.vote_registered?
112
112
  end
113
113
 
114
- def test_not_count_the_vote_as_being_registered_if_that_voter_has_alredy_voted_and_voted_has_not_chanded
114
+ def test_not_count_the_vote_as_being_registered_if_that_voter_has_already_voted_and_voted_has_not_changed
115
115
  votable.vote_by(:voter => voters(:voter), :vote => true)
116
116
  votable.vote_by(:voter => voters(:voter), :vote => 'yes')
117
117
  assert !votable.vote_registered?
data/test/database.yml CHANGED
@@ -1,21 +1,17 @@
1
- mysql:
2
- :adapter: mysql2
3
- :host: localhost
4
- :username: root
5
- :password: 1
6
- :database: rails_plugin_test
1
+ sqlite:
2
+ adapter: sqlite3
3
+ database: ':memory:'
7
4
 
8
- sqlite3:
9
- :adapter: sqlite3
10
- :database: ':memory:'
5
+ mysql:
6
+ adapter: mysql2
7
+ database: redmine_crm_test
8
+ username: root
9
+ password: password
10
+ host: 127.0.0.1
11
11
 
12
12
  postgresql:
13
- :adapter: postgresql
14
- :database: rails_plugin_test
15
- :user: container
16
- :password: 1
17
- :host: localhost
18
-
19
- default_env:
20
- adapter: sqlite3
21
- database: ':memory:'
13
+ adapter: postgresql
14
+ database: redmine_crm_test
15
+ user: postgres
16
+ password: password
17
+ host: 127.0.0.1
@@ -0,0 +1,14 @@
1
+ require_relative 'project'
2
+ require_relative 'user'
3
+
4
+ class Issue < ActiveRecord::Base
5
+ belongs_to :project
6
+ belongs_to :user
7
+ belongs_to :author, class_name: 'User'
8
+
9
+ rcrm_acts_as_draftable
10
+ rcrm_acts_as_taggable
11
+ rcrm_acts_as_viewed
12
+
13
+ scope :visible, lambda { where('1=1') }
14
+ end
File without changes
File without changes
File without changes
@@ -2,10 +2,6 @@ class Voter < ActiveRecord::Base
2
2
  rcrm_acts_as_voter
3
3
  end
4
4
 
5
- class NotVoter < ActiveRecord::Base
6
-
7
- end
8
-
9
5
  class Votable < ActiveRecord::Base
10
6
  rcrm_acts_as_votable
11
7
  validates_presence_of :name
@@ -31,23 +27,7 @@ class VotableChildOfStiNotVotable < StiNotVotable
31
27
  rcrm_acts_as_votable
32
28
  end
33
29
 
34
- class NotVotable < ActiveRecord::Base
35
- end
36
-
37
30
  class VotableCache < ActiveRecord::Base
38
31
  rcrm_acts_as_votable
39
32
  validates_presence_of :name
40
33
  end
41
-
42
- class ABoringClass
43
- def self.hw
44
- 'hello world'
45
- end
46
- end
47
-
48
- # def clean_database
49
- # models = [ActsAsVotable::Vote, Voter, NotVoter, Votable, NotVotable, VotableCache]
50
- # models.each do |model|
51
- # ActiveRecord::Base.connection.execute "DELETE FROM #{model.table_name}"
52
- # end
53
- # end
data/test/schema.rb CHANGED
@@ -1,4 +1,12 @@
1
- ActiveRecord::Schema.define :version => 0 do
1
+ ActiveRecord::Schema.define version: 0 do
2
+
3
+ create_table :drafts, force: true do |t|
4
+ t.string :target_type
5
+ t.references :user
6
+ t.references :parent, polymorphic: true
7
+ t.binary :data
8
+ t.datetime :updated_at
9
+ end
2
10
 
3
11
  create_table "tags", :force => true do |t|
4
12
  t.column "name", :string
data/test/test_helper.rb CHANGED
@@ -1,40 +1,13 @@
1
+ require 'rails/all'
2
+ require 'redmine_crm'
1
3
  require 'minitest/autorun'
2
- require 'byebug'
3
- # require 'test/unit'
4
-
5
- begin
6
- require File.dirname(__FILE__) + '/../../../../config/environment'
7
- rescue LoadError
8
- require 'rubygems'
9
- gem 'activerecord'
10
- gem 'actionpack'
11
- require 'active_record'
12
- end
13
- require "redmine_crm"
14
- require "active_record/fixtures"
15
-
16
- require File.dirname(__FILE__) + '/../lib/redmine_crm/acts_as_taggable/tag'
17
- require File.dirname(__FILE__) + '/../lib/redmine_crm/acts_as_taggable/tag_list'
18
- require File.dirname(__FILE__) + '/../lib/redmine_crm/acts_as_taggable/tagging'
19
- require File.dirname(__FILE__) + '/../lib/redmine_crm/acts_as_taggable/rcrm_acts_as_taggable'
20
- require File.dirname(__FILE__) + '/../lib/redmine_crm/helpers/tags_helper'
21
- require File.dirname(__FILE__) + '/../lib/redmine_crm/acts_as_votable/rcrm_acts_as_votable'
22
- require File.dirname(__FILE__) + '/../lib/redmine_crm/acts_as_votable/rcrm_acts_as_voter'
23
-
24
- # require_dependency File.dirname(__FILE__) + '/../lib/redmine_crm/tags_helper'
25
4
 
26
5
  ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/debug.log')
27
- ActiveRecord::Base.configurations = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
28
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ENV['DB'] || 'sqlite3'])
6
+ ActiveRecord::Base.configurations = YAML.load_file(File.dirname(__FILE__) + '/database.yml')
7
+ ActiveRecord::Base.establish_connection(ENV['DB'].try(:to_sym) || :sqlite)
29
8
 
30
9
  load(File.dirname(__FILE__) + '/schema.rb')
31
- load(File.dirname(__FILE__) + '/fixtures/user.rb')
32
- load(File.dirname(__FILE__) + '/fixtures/issue.rb')
33
- load(File.dirname(__FILE__) + '/fixtures/vote_classes.rb')
34
- load(File.dirname(__FILE__) + '/fixtures/news.rb')
35
- load(File.dirname(__FILE__) + '/fixtures/project.rb')
36
-
37
- # Dir["/fixtures/*.rb"].each{|file| load file}
10
+ Dir.glob(File.expand_path('../models/*.rb', __FILE__)).each { |f| require f }
38
11
 
39
12
  class ActiveSupport::TestCase #:nodoc:
40
13
  include ActiveRecord::TestFixtures
@@ -76,31 +49,6 @@ class ActiveSupport::TestCase #:nodoc:
76
49
  end
77
50
  end
78
51
 
79
- # def assert_queries(num = 1)
80
- # $query_count = 0
81
- # yield
82
- # ensure
83
- # assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed."
84
- # end
85
-
86
- # def assert_queries(num = 1, options = {})
87
- # ignore_none = options.fetch(:ignore_none) { num == :any }
88
- # SQLCounter.clear_log
89
- # yield
90
- # ensure
91
- # the_log = ignore_none ? SQLCounter.log_all : SQLCounter.log
92
- # if num == :any
93
- # assert_operator the_log.size, :>=, 1, "1 or more queries expected, but none were executed."
94
- # else
95
- # mesg = "#{the_log.size} instead of #{num} queries were executed.#{the_log.size == 0 ? '' : "\nQueries:\n#{the_log.join("\n")}"}"
96
- # assert_equal num, the_log.size, mesg
97
- # end
98
- # end
99
-
100
- def assert_no_queries(&block)
101
- assert_queries(0, &block)
102
- end
103
-
104
52
  # From Rails trunk
105
53
  def assert_difference(expressions, difference = 1, message = nil, &block)
106
54
  expression_evaluations = [expressions].flatten.collect{ |expression| lambda { eval(expression, block.binding) } }
@@ -0,0 +1,39 @@
1
+ var oldToggleFilter = window.toggleFilter;
2
+
3
+ window.toggleFilter = function (field) {
4
+ oldToggleFilter(field);
5
+ return transform_to_select2(field);
6
+ };
7
+
8
+ function formatStateWithAvatar(opt) {
9
+ return $('<span>' + opt.avatar + '&nbsp;' + opt.text + '</span>');
10
+ };
11
+
12
+ var select2Filters = {};
13
+
14
+ function transform_to_select2(field) {
15
+ field = field.replace('.', '_');
16
+ var filter = select2Filters[field];
17
+ if (filter !== undefined && $('#tr_' + field + ' .values .select2').size() == 0) {
18
+ $('#tr_' + field + ' .toggle-multiselect').hide();
19
+ $('#tr_' + field + ' .values .value').attr('multiple', 'multiple');
20
+ $('#tr_' + field + ' .values .value').select2({
21
+ ajax: {
22
+ url: filter['url'],
23
+ dataType: 'json',
24
+ delay: 250,
25
+ data: function (params) {
26
+ return {q: params.term};
27
+ },
28
+ processResults: function (data, params) {
29
+ return {results: data};
30
+ },
31
+ cache: true
32
+ },
33
+ placeholder: ' ',
34
+ minimumInputLength: filter['minimumInputLength'],
35
+ width: filter['width'],
36
+ templateResult: filter['formatState']
37
+ });
38
+ }
39
+ };
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine_crm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.36
4
+ version: 0.0.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - RedmineUP
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-22 00:00:00.000000000 Z
11
+ date: 2018-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: liquid
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,48 @@ dependencies:
24
38
  - - "<"
25
39
  - !ruby/object:Gem::Version
26
40
  version: 2.6.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mysql2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: pg
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
27
83
  description: Common libraries for RedmineUP plugins (www.redmineup.com) for Redmine.
28
84
  Requered Redmine from http://redmine.org
29
85
  email:
@@ -41,6 +97,8 @@ files:
41
97
  - doc/CHANGELOG
42
98
  - doc/LICENSE.txt
43
99
  - lib/redmine_crm.rb
100
+ - lib/redmine_crm/acts_as_draftable/draft.rb
101
+ - lib/redmine_crm/acts_as_draftable/rcrm_acts_as_draftable.rb
44
102
  - lib/redmine_crm/acts_as_list/list.rb
45
103
  - lib/redmine_crm/acts_as_taggable/rcrm_acts_as_taggable.rb
46
104
  - lib/redmine_crm/acts_as_taggable/tag.rb
@@ -70,6 +128,8 @@ files:
70
128
  - lib/redmine_crm/money_helper.rb
71
129
  - lib/redmine_crm/version.rb
72
130
  - redmine_crm.gemspec
131
+ - test/acts_as_draftable/draft_test.rb
132
+ - test/acts_as_draftable/rcrm_acts_as_draftable_test.rb
73
133
  - test/acts_as_taggable/rcrm_acts_as_taggable_test.rb
74
134
  - test/acts_as_taggable/tag_list_test.rb
75
135
  - test/acts_as_taggable/tag_test.rb
@@ -81,28 +141,27 @@ files:
81
141
  - test/acts_as_votable/voter_test.rb
82
142
  - test/currency_test.rb
83
143
  - test/database.yml
84
- - test/fixtures/issue.rb
85
144
  - test/fixtures/issues.yml
86
- - test/fixtures/news.rb
87
145
  - test/fixtures/news.yml
88
- - test/fixtures/project.rb
89
146
  - test/fixtures/projects.yml
90
147
  - test/fixtures/taggings.yml
91
148
  - test/fixtures/tags.yml
92
- - test/fixtures/user.rb
93
149
  - test/fixtures/users.yml
94
150
  - test/fixtures/votable_caches.yml
95
151
  - test/fixtures/votables.yml
96
- - test/fixtures/vote_classes.rb
97
152
  - test/fixtures/voters.yml
98
153
  - test/liquid/drops/issues_drop_test.rb
99
- - test/liquid/drops/liquid_test.rb
100
154
  - test/liquid/drops/news_drop_test.rb
101
155
  - test/liquid/drops/projects_drop_test.rb
102
156
  - test/liquid/drops/uses_drop_test.rb
103
157
  - test/liquid/filters/arrays_filter_test.rb
104
158
  - test/liquid/filters/base_filter_test.rb
105
159
  - test/liquid/liquid_helper.rb
160
+ - test/models/issue.rb
161
+ - test/models/news.rb
162
+ - test/models/project.rb
163
+ - test/models/user.rb
164
+ - test/models/vote_classes.rb
106
165
  - test/money_helper_test.rb
107
166
  - test/schema.rb
108
167
  - test/tags_helper_test.rb
@@ -111,6 +170,7 @@ files:
111
170
  - vendor/assets/images/vcard.png
112
171
  - vendor/assets/javascripts/Chart.bundle.min.js
113
172
  - vendor/assets/javascripts/select2.js
173
+ - vendor/assets/javascripts/select2_helpers.js
114
174
  - vendor/assets/stylesheets/select2.css
115
175
  homepage: ''
116
176
  licenses:
@@ -137,6 +197,8 @@ signing_key:
137
197
  specification_version: 4
138
198
  summary: Common libraries for RedmineUP plugins for Redmine
139
199
  test_files:
200
+ - test/acts_as_draftable/draft_test.rb
201
+ - test/acts_as_draftable/rcrm_acts_as_draftable_test.rb
140
202
  - test/acts_as_taggable/rcrm_acts_as_taggable_test.rb
141
203
  - test/acts_as_taggable/tag_list_test.rb
142
204
  - test/acts_as_taggable/tag_test.rb
@@ -148,28 +210,27 @@ test_files:
148
210
  - test/acts_as_votable/voter_test.rb
149
211
  - test/currency_test.rb
150
212
  - test/database.yml
151
- - test/fixtures/issue.rb
152
213
  - test/fixtures/issues.yml
153
- - test/fixtures/news.rb
154
214
  - test/fixtures/news.yml
155
- - test/fixtures/project.rb
156
215
  - test/fixtures/projects.yml
157
216
  - test/fixtures/taggings.yml
158
217
  - test/fixtures/tags.yml
159
- - test/fixtures/user.rb
160
218
  - test/fixtures/users.yml
161
219
  - test/fixtures/votable_caches.yml
162
220
  - test/fixtures/votables.yml
163
- - test/fixtures/vote_classes.rb
164
221
  - test/fixtures/voters.yml
165
222
  - test/liquid/drops/issues_drop_test.rb
166
- - test/liquid/drops/liquid_test.rb
167
223
  - test/liquid/drops/news_drop_test.rb
168
224
  - test/liquid/drops/projects_drop_test.rb
169
225
  - test/liquid/drops/uses_drop_test.rb
170
226
  - test/liquid/filters/arrays_filter_test.rb
171
227
  - test/liquid/filters/base_filter_test.rb
172
228
  - test/liquid/liquid_helper.rb
229
+ - test/models/issue.rb
230
+ - test/models/news.rb
231
+ - test/models/project.rb
232
+ - test/models/user.rb
233
+ - test/models/vote_classes.rb
173
234
  - test/money_helper_test.rb
174
235
  - test/schema.rb
175
236
  - test/tags_helper_test.rb