populate-me 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/config.ru +1 -0
- data/lib/populate_me/admin/views/page.erb +11 -1
- data/lib/populate_me/document_mixins/admin_adapter.rb +2 -1
- data/lib/populate_me/document_mixins/persistence.rb +3 -0
- data/lib/populate_me/document_mixins/schema.rb +1 -1
- data/lib/populate_me/mongo.rb +3 -0
- data/lib/populate_me/version.rb +1 -1
- data/test/test_document_persistence.rb +27 -0
- data/test/test_mongo.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5c79dfa650ecfc5df94c3ab28ddbed5f9d491a7
|
4
|
+
data.tar.gz: acfd309da2a2ac7f738f4fee4fe60085dc79961c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4343d3b53dfa62f0624adcb7e268813192224fc33fc323a2192d2d36efa8ad7092f81baa32743d561469b1db7ee1e2412da210a45cc12937ed8f40f15a197535
|
7
|
+
data.tar.gz: 3e14be4dc566b04247fdf25a0ee6866a99adf29688d6e830090d0863ecd4bd7a226ef93e200a52fc47fd793a7ddd4ee4994886e70017534ba3f7c4e60894f5e9
|
data/example/config.ru
CHANGED
@@ -7,6 +7,9 @@
|
|
7
7
|
<link rel="stylesheet" href="<%= request.script_name %>/__assets__/css/jquery-ui.min.css" type="text/css" media='screen' />
|
8
8
|
<link rel="stylesheet" href="<%= request.script_name %>/__assets__/css/asmselect.css" type="text/css" media='screen' />
|
9
9
|
<link rel="stylesheet" href="<%= request.script_name %>/__assets__/css/main.css" type="text/css" media='screen' />
|
10
|
+
<% if settings.respond_to? :custom_css_url %>
|
11
|
+
<link rel="stylesheet" href="<%= settings.custom_css_url %>" type="text/css" media='screen' />
|
12
|
+
<% end %>
|
10
13
|
</head>
|
11
14
|
<body>
|
12
15
|
|
@@ -54,7 +57,7 @@
|
|
54
57
|
</a>
|
55
58
|
<ol class='local-menu'>
|
56
59
|
{{#local_menu}}
|
57
|
-
<li>→ <a href="{{href}}" class='column-push' title='Open'>{{title}}</a></li>
|
60
|
+
<li>→ <a href="{{href}}" {{#new_page}}target='_blank'{{/new_page}}{{^new_page}}class='column-push'{{/new_page}} title='Open'>{{title}}</a></li>
|
58
61
|
{{/local_menu}}
|
59
62
|
</ol>
|
60
63
|
</li>
|
@@ -150,6 +153,10 @@
|
|
150
153
|
</fieldset>
|
151
154
|
</script>
|
152
155
|
|
156
|
+
<% if settings.respond_to? :custom_templates_view %>
|
157
|
+
<%= erb settings.custom_templates_view, layout: false %>
|
158
|
+
<% end %>
|
159
|
+
|
153
160
|
<!-- JS -->
|
154
161
|
<script src="//code.jquery.com/jquery-1.10.2.min.js" type="text/javascript" charset="utf-8"></script>
|
155
162
|
<script src="<%= request.script_name %>/__assets__/js/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
|
@@ -162,6 +169,9 @@
|
|
162
169
|
window.index_path = "<%= settings.index_path %>";
|
163
170
|
</script>
|
164
171
|
<script src="<%= request.script_name %>/__assets__/js/main.js" type="text/javascript" charset="utf-8"></script>
|
172
|
+
<% if settings.respond_to? :custom_js_url %>
|
173
|
+
<script src="<%= settings.custom_js_url %>" type="text/javascript" charset="utf-8"></script>
|
174
|
+
<% end %>
|
165
175
|
</body>
|
166
176
|
</html>
|
167
177
|
|
@@ -23,7 +23,8 @@ module PopulateMe
|
|
23
23
|
unless v[:hidden]
|
24
24
|
out << {
|
25
25
|
title: "#{v[:label]}",
|
26
|
-
href: "#{o[:request].script_name}/list/#{WebUtils.dasherize_class_name(v[:class_name])}?filter[#{v[:foreign_key]}]=#{self.id}"
|
26
|
+
href: "#{o[:request].script_name}/list/#{WebUtils.dasherize_class_name(v[:class_name])}?filter[#{v[:foreign_key]}]=#{self.id}",
|
27
|
+
new_page: false
|
27
28
|
}
|
28
29
|
out
|
29
30
|
end
|
data/lib/populate_me/mongo.rb
CHANGED
data/lib/populate_me/version.rb
CHANGED
@@ -3,6 +3,8 @@ require 'populate_me/document'
|
|
3
3
|
|
4
4
|
class Stuborn < PopulateMe::Document
|
5
5
|
attr_accessor :age
|
6
|
+
field :position
|
7
|
+
field :reversed, direction: :desc
|
6
8
|
end
|
7
9
|
|
8
10
|
describe PopulateMe::Document, 'Persistence' do
|
@@ -52,5 +54,30 @@ describe PopulateMe::Document, 'Persistence' do
|
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
57
|
+
describe '::set_indexes' do
|
58
|
+
|
59
|
+
before do
|
60
|
+
Stuborn.documents = []
|
61
|
+
Stuborn.new('id' => 'a').save
|
62
|
+
Stuborn.new('id' => 'b').save
|
63
|
+
Stuborn.new('id' => 'c').save
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'Sets the indexes on the provided field' do
|
67
|
+
Stuborn.set_indexes(:position,['b','a','c'])
|
68
|
+
assert_equal 1, Stuborn.admin_get('a').position
|
69
|
+
assert_equal 0, Stuborn.admin_get('b').position
|
70
|
+
assert_equal 2, Stuborn.admin_get('c').position
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'Sets the indexes taking direction into account' do
|
74
|
+
Stuborn.set_indexes(:reversed,['b','a','c'])
|
75
|
+
assert_equal 1, Stuborn.admin_get('a').reversed
|
76
|
+
assert_equal 2, Stuborn.admin_get('b').reversed
|
77
|
+
assert_equal 0, Stuborn.admin_get('c').reversed
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
55
82
|
end
|
56
83
|
|
data/test/test_mongo.rb
CHANGED
@@ -222,6 +222,7 @@ describe 'PopulateMe::Mongo' do
|
|
222
222
|
|
223
223
|
class MongoChampion < PopulateMe::Mongo
|
224
224
|
field :position
|
225
|
+
field :reversed, direction: :desc
|
225
226
|
end
|
226
227
|
|
227
228
|
before do
|
@@ -238,6 +239,12 @@ describe 'PopulateMe::Mongo' do
|
|
238
239
|
assert_equal 2, MongoChampion.admin_get('c').position
|
239
240
|
end
|
240
241
|
|
242
|
+
it 'Sets the indexes taking direction into account' do
|
243
|
+
MongoChampion.set_indexes(:reversed,['b','a','c'])
|
244
|
+
assert_equal 1, MongoChampion.admin_get('a').reversed
|
245
|
+
assert_equal 2, MongoChampion.admin_get('b').reversed
|
246
|
+
assert_equal 0, MongoChampion.admin_get('c').reversed
|
247
|
+
end
|
241
248
|
end
|
242
249
|
|
243
250
|
describe '::admin_distinct' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: populate-me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickael Riga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: web-utils
|