upmin-admin 0.1.01 → 0.1.3

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -18
  3. data/Rakefile +18 -18
  4. data/app/assets/javascripts/upmin/attributes/datetime.js +37 -11
  5. data/app/assets/stylesheets/upmin/application.css +0 -1
  6. data/app/assets/stylesheets/upmin/base.css.scss +8 -1
  7. data/app/assets/stylesheets/upmin/dashboard.css +16 -0
  8. data/app/assets/stylesheets/upmin/instances.css.scss +7 -0
  9. data/app/controllers/upmin/dashboard_controller.rb +11 -0
  10. data/app/controllers/upmin/models_controller.rb +28 -9
  11. data/app/views/layouts/upmin/application.html.haml +6 -2
  12. data/app/views/upmin/dashboard/_chart.html.haml +9 -0
  13. data/app/views/upmin/dashboard/index.html.haml +14 -0
  14. data/app/views/upmin/models/search.html.haml +20 -4
  15. data/app/views/upmin/partials/attributes/_boolean.html.haml +1 -6
  16. data/app/views/upmin/partials/attributes/_date.html.haml +26 -0
  17. data/app/views/upmin/partials/attributes/_enum.html.haml +9 -0
  18. data/app/views/upmin/partials/attributes/_money_cents.html.haml +10 -0
  19. data/app/views/upmin/partials/models/_model.html.haml +5 -6
  20. data/app/views/upmin/partials/models/_new_model.html.haml +1 -1
  21. data/app/views/upmin/partials/search_boxes/_ransack_search_box.html.haml +6 -1
  22. data/config/routes.rb +3 -5
  23. data/lib/generators/upmin/install_generator.rb +24 -0
  24. data/lib/generators/upmin/templates/initializer.rb +13 -0
  25. data/lib/upmin/active_record/model.rb +15 -1
  26. data/lib/upmin/admin.rb +2 -1
  27. data/lib/upmin/attribute.rb +4 -1
  28. data/lib/upmin/configuration.rb +1 -0
  29. data/lib/upmin/data_mapper/model.rb +10 -0
  30. data/lib/upmin/engine.rb +4 -3
  31. data/lib/upmin/model.rb +37 -5
  32. data/lib/upmin/railtie.rb +1 -0
  33. data/lib/upmin/railties/dashboard.rb +88 -0
  34. data/lib/upmin/railties/render_helpers.rb +2 -0
  35. data/lib/upmin/version.rb +1 -1
  36. data/spec/features/delete_model_spec.rb +38 -0
  37. data/spec/features/edit_model_spec.rb +1 -1
  38. data/spec/features/enum_attributes_spec.rb +24 -0
  39. data/spec/features/navbar_spec.rb +4 -4
  40. data/spec/features/new_model_spec.rb +1 -1
  41. data/spec/features/search_spec.rb +17 -27
  42. data/spec/lib/attribute_spec.rb +15 -0
  43. data/spec/lib/upmin/active_record/model_spec.rb +15 -0
  44. data/spec/spec_helper.rb +8 -0
  45. metadata +49 -4
  46. data/app/views/upmin/models/dashboard.html.haml +0 -9
@@ -42,6 +42,7 @@ module Upmin::Railties
42
42
  partials << build_attribute_path(options[:as]) if options[:as]
43
43
  partials << build_attribute_path("#{model_name}_#{attribute.name}")
44
44
  partials << build_attribute_path("#{model_name}_#{attr_type}")
45
+ partials << build_attribute_path(attribute.name)
45
46
  partials << build_attribute_path(attr_type)
46
47
  partials << build_attribute_path(:unknown)
47
48
  return partials
@@ -74,6 +75,7 @@ module Upmin::Railties
74
75
  partials << build_association_path(options[:as]) if options[:as]
75
76
  partials << build_association_path("#{model_name}_#{association.name}")
76
77
  partials << build_association_path("#{model_name}_#{assoc_type}")
78
+ partials << build_association_path(association.name)
77
79
  partials << build_association_path(assoc_type)
78
80
  partials << build_association_path(:associations)
79
81
  return partials
@@ -1,3 +1,3 @@
1
1
  module Upmin
2
- VERSION = "0.1.01"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -0,0 +1,38 @@
1
+ # encoding: UTF-8
2
+ require "spec_helper"
3
+
4
+ feature("Delete an existing model") do
5
+ background do
6
+ # Setup BG Stuff
7
+ end
8
+
9
+ scenario("should see delete button with confirmation") do
10
+ user = User.first
11
+ updated_user = build(:user)
12
+
13
+ visit("/upmin/m/User/i/#{user.id}")
14
+
15
+ expect(page).to(have_selector("a[data-method='delete']"))
16
+ expect(page).to(have_selector("a[data-confirm='Are you sure?']"))
17
+
18
+ end
19
+
20
+ scenario("should delete if confirmed") do
21
+ user = User.first
22
+ # updated_user = build(:user)
23
+
24
+ visit("/upmin/m/User/i/#{user.id}")
25
+
26
+ first('a.delete').click
27
+
28
+ #expect(page.driver.alert_messages.last).to eq 'Are you sure?'
29
+
30
+ if defined?(DataMapper)
31
+ expect(User.get(user.id)).to be_nil
32
+ else
33
+ expect(User.where(id: user.id)).not_to exist
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -41,7 +41,7 @@ feature("Update an existing model") do
41
41
  click_button("Save")
42
42
 
43
43
  within(".alert.alert-danger") do
44
- expect(page).to(have_content("User was NOT updated."))
44
+ expect(page).to(have_content("Customer was NOT updated."))
45
45
  expect(page).to(have_selector("li", text: /email/i))
46
46
  end
47
47
 
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'Enum Attributes' do
4
+
5
+ if ActiveRecord::Base.respond_to? :enum
6
+ scenario 'Creating a new model' do
7
+ visit '/upmin/m/UserWithRoleEnum/new'
8
+ choose 'Admin'
9
+ expect { click_button("Create") }.to(change(UserWithRoleEnum, :count))
10
+ expect(page).to(have_selector("input#user_with_role_enum_role_admin[checked='checked']"))
11
+ end
12
+
13
+ scenario 'Updating a model' do
14
+ user = UserWithRoleEnum.create!
15
+ visit "/upmin/m/UserWithRoleEnum/i/#{user.id}"
16
+ choose 'Admin'
17
+ click_button("Save")
18
+ expect(page).to(have_selector("input#user_with_role_enum_role_admin[checked='checked']"))
19
+ user.reload
20
+ expect(user.role).to eq 'admin'
21
+ end
22
+ end
23
+
24
+ end
@@ -10,13 +10,13 @@ feature("Navbar") do
10
10
  visit ("/upmin")
11
11
 
12
12
  within(".navbar ul.nav") do
13
- expect(page).to(have_selector("li", text: "Users"))
13
+ expect(page).to(have_selector("li", text: "Customers"))
14
14
  expect(page).to(have_selector("li", text: "Products"))
15
15
  expect(page).to(have_selector("li", text: "Orders"))
16
16
  expect(page).to(have_selector("li", text: "Product Orders"))
17
17
  expect(page).to(have_selector("li", text: "Shipments"))
18
18
 
19
- click_link("Users")
19
+ click_link("Customers")
20
20
  end
21
21
 
22
22
  expect(page).to(have_selector(".upmin-model", minimum: 10))
@@ -30,13 +30,13 @@ feature("Navbar") do
30
30
  visit ("/upmin")
31
31
 
32
32
  within(".navbar ul.nav") do
33
- expect(page).to(have_selector("li", text: "Users"))
33
+ expect(page).to(have_selector("li", text: "Customers"))
34
34
  expect(page).to(have_selector("li", text: "Products"))
35
35
  expect(page).not_to(have_selector("li", text: "Orders"))
36
36
  expect(page).not_to(have_selector("li", text: "Product Orders"))
37
37
  expect(page).not_to(have_selector("li", text: "Shipments"))
38
38
 
39
- click_link("Users")
39
+ click_link("Customers")
40
40
  end
41
41
 
42
42
  expect(page).to(have_selector(".upmin-model", minimum: 10))
@@ -34,7 +34,7 @@ feature("Create a new model") do
34
34
  expect { click_button("Create") }.not_to(change(User, :count))
35
35
 
36
36
  within(".alert.alert-danger") do
37
- expect(page).to(have_content("User was NOT created."))
37
+ expect(page).to(have_content("Customer was NOT created."))
38
38
  end
39
39
 
40
40
  within(".field_with_errors") do
@@ -10,10 +10,24 @@ feature("Search Views") do
10
10
  # it("TODO(jon): Write this test")
11
11
  end
12
12
 
13
+ scenario("Page Entries Info") do
14
+ visit("/upmin/m/User")
15
+
16
+ # Make sure some basic page entries info exists
17
+ within(".page-entries-info") do
18
+ within("b:first-of-type") do
19
+ expect(page).to(have_content("1 - 30"))
20
+ end
21
+
22
+ expect(page).to(have_content("of"))
23
+ expect(page).to(have_content("in total"))
24
+ end
25
+ end
26
+
13
27
  scenario("Pagination") do
14
28
  visit("/upmin/m/User")
15
29
 
16
- # Make sure some basic pagination exits
30
+ # Make sure some basic pagination exists
17
31
  within(".pagination:first-of-type") do
18
32
  within(".active, .current") do
19
33
  expect(page).to(have_content("1"))
@@ -46,35 +60,11 @@ feature("Search Views") do
46
60
 
47
61
  expect(page).to(have_selector("a.search-result-link", count: 30))
48
62
 
49
- fill_in("q_id_gteq", with: 1)
63
+ fill_in("q_id_gteq", with: 2)
50
64
  fill_in("q_id_lteq", with: 5)
51
65
  click_button("Search")
52
66
 
53
- expect(page).to(have_selector("a.search-result-link", count: 5))
54
- end
55
-
56
- scenario("Search via string") do
57
- expected_user = User.first
58
-
59
- visit("/upmin/m/User")
60
-
61
- fill_in("q_name_cont", with: expected_user.name)
62
- click_button("Search")
63
-
64
- expect(page).to(have_selector("a.search-result-link", minimum: 1))
65
- expect(page).to(have_content(expected_user.name))
66
- end
67
-
68
- scenario("Search via string") do
69
- expected_user = User.first
70
-
71
- visit("/upmin/m/User")
72
-
73
- fill_in("q_name_cont", with: expected_user.name)
74
- click_button("Search")
75
-
76
- expect(page).to(have_selector("a.search-result-link", minimum: 1))
77
- expect(page).to(have_content(expected_user.name))
67
+ expect(page).to(have_selector("a.search-result-link", count: 4))
78
68
  end
79
69
 
80
70
  scenario("config.items_per_page") do
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Upmin::Attribute do
4
+
5
+ if ActiveRecord::Base.respond_to? :enum
6
+ describe '#enum_options' do
7
+ it 'returns options for an enum attribute' do
8
+ model = Upmin::Model.find_class(UserWithRoleEnum).new
9
+ attribute = Upmin::Attribute.new(model, :role)
10
+ expect(attribute.enum_options).to eq ['default', 'admin']
11
+ end
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Upmin::ActiveRecord::Model do
4
+
5
+ if ActiveRecord::Base.respond_to? :enum
6
+ describe ".attribute_type" do
7
+ it "correctly identifies an enum attribute" do
8
+ model = Upmin::Model.find_class(UserWithRoleEnum).new
9
+ attribute = Upmin::Attribute.new(model, :role)
10
+ expect(attribute.type).to eq(:enum)
11
+ end
12
+ end
13
+ end
14
+
15
+ end
@@ -27,6 +27,11 @@ RSpec.configure do |config|
27
27
  end
28
28
 
29
29
  config.before(:suite) do
30
+ if ActiveRecord::Base.respond_to? :enum
31
+ class UserWithRoleEnum < ActiveRecord::Base; enum role: [:default, :admin] end
32
+ ActiveRecord::Migration.create_table(:user_with_role_enums) {|t| t.integer :role, default: 0 }
33
+ end
34
+
30
35
  if defined?(DataMapper)
31
36
  # NOTE: eager_loading needs to be on in the app for testing.
32
37
  DataMapper.finalize
@@ -37,6 +42,9 @@ RSpec.configure do |config|
37
42
  end
38
43
 
39
44
  config.after(:suite) do
45
+ if ActiveRecord::Base.respond_to? :enum
46
+ ActiveRecord::Migration.drop_table :user_with_role_enums
47
+ end
40
48
  end
41
49
 
42
50
  config.before(:each) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upmin-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.01
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Calhoun
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-13 00:00:00.000000000 Z
12
+ date: 2015-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -95,6 +95,34 @@ dependencies:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: chartkick
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: sqlite3
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
98
126
  - !ruby/object:Gem::Dependency
99
127
  name: capybara
100
128
  requirement: !ruby/object:Gem::Requirement
@@ -186,11 +214,13 @@ files:
186
214
  - app/assets/stylesheets/upmin/base.css.scss
187
215
  - app/assets/stylesheets/upmin/button_mixins.scss
188
216
  - app/assets/stylesheets/upmin/colors.scss
217
+ - app/assets/stylesheets/upmin/dashboard.css
189
218
  - app/assets/stylesheets/upmin/instances.css.scss
190
219
  - app/assets/stylesheets/upmin/jquery-clockpicker.css
191
220
  - app/assets/stylesheets/upmin/models.css.scss
192
221
  - app/assets/stylesheets/upmin/pikaday.css
193
222
  - app/controllers/upmin/application_controller.rb
223
+ - app/controllers/upmin/dashboard_controller.rb
194
224
  - app/controllers/upmin/models_controller.rb
195
225
  - app/helpers/upmin/application_helper.rb
196
226
  - app/helpers/upmin/models_helper.rb
@@ -203,17 +233,21 @@ files:
203
233
  - app/views/kaminari/_prev_page.html.haml
204
234
  - app/views/layouts/upmin/_navbar.html.haml
205
235
  - app/views/layouts/upmin/application.html.haml
206
- - app/views/upmin/models/dashboard.html.haml
236
+ - app/views/upmin/dashboard/_chart.html.haml
237
+ - app/views/upmin/dashboard/index.html.haml
207
238
  - app/views/upmin/models/new.html.haml
208
239
  - app/views/upmin/models/search.html.haml
209
240
  - app/views/upmin/models/show.html.haml
210
241
  - app/views/upmin/partials/actions/_action.html.haml
211
242
  - app/views/upmin/partials/associations/_associations.html.haml
212
243
  - app/views/upmin/partials/attributes/_boolean.html.haml
244
+ - app/views/upmin/partials/attributes/_date.html.haml
213
245
  - app/views/upmin/partials/attributes/_datetime.html.haml
214
246
  - app/views/upmin/partials/attributes/_decimal.html.haml
247
+ - app/views/upmin/partials/attributes/_enum.html.haml
215
248
  - app/views/upmin/partials/attributes/_float.html.haml
216
249
  - app/views/upmin/partials/attributes/_integer.html.haml
250
+ - app/views/upmin/partials/attributes/_money_cents.html.haml
217
251
  - app/views/upmin/partials/attributes/_progress_bar.html.haml
218
252
  - app/views/upmin/partials/attributes/_string.html.haml
219
253
  - app/views/upmin/partials/attributes/_text.html.haml
@@ -226,6 +260,8 @@ files:
226
260
  - app/views/upmin/partials/search_boxes/_ransack_search_box.html.haml
227
261
  - app/views/upmin/partials/search_results/_results.html.haml
228
262
  - config/routes.rb
263
+ - lib/generators/upmin/install_generator.rb
264
+ - lib/generators/upmin/templates/initializer.rb
229
265
  - lib/tasks/upmin_tasks.rake
230
266
  - lib/upmin.rb
231
267
  - lib/upmin/action.rb
@@ -248,6 +284,7 @@ files:
248
284
  - lib/upmin/query.rb
249
285
  - lib/upmin/railtie.rb
250
286
  - lib/upmin/railties/active_record.rb
287
+ - lib/upmin/railties/dashboard.rb
251
288
  - lib/upmin/railties/data_mapper.rb
252
289
  - lib/upmin/railties/paginator.rb
253
290
  - lib/upmin/railties/render.rb
@@ -255,11 +292,15 @@ files:
255
292
  - lib/upmin/version.rb
256
293
  - spec/factories/factories.rb
257
294
  - spec/features/action_spec.rb
295
+ - spec/features/delete_model_spec.rb
258
296
  - spec/features/edit_model_spec.rb
297
+ - spec/features/enum_attributes_spec.rb
259
298
  - spec/features/navbar_spec.rb
260
299
  - spec/features/new_model_spec.rb
261
300
  - spec/features/search_spec.rb
301
+ - spec/lib/attribute_spec.rb
262
302
  - spec/lib/configuration_spec.rb
303
+ - spec/lib/upmin/active_record/model_spec.rb
263
304
  - spec/spec_helper.rb
264
305
  homepage: https://www.upmin.com/admin-rails
265
306
  licenses:
@@ -281,16 +322,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
322
  version: '0'
282
323
  requirements: []
283
324
  rubyforge_project:
284
- rubygems_version: 2.2.2
325
+ rubygems_version: 2.4.5
285
326
  signing_key:
286
327
  specification_version: 4
287
328
  summary: Quick and Easy Admin Dashboards
288
329
  test_files:
289
330
  - spec/factories/factories.rb
290
331
  - spec/features/action_spec.rb
332
+ - spec/features/delete_model_spec.rb
291
333
  - spec/features/edit_model_spec.rb
334
+ - spec/features/enum_attributes_spec.rb
292
335
  - spec/features/navbar_spec.rb
293
336
  - spec/features/new_model_spec.rb
294
337
  - spec/features/search_spec.rb
338
+ - spec/lib/attribute_spec.rb
295
339
  - spec/lib/configuration_spec.rb
340
+ - spec/lib/upmin/active_record/model_spec.rb
296
341
  - spec/spec_helper.rb
@@ -1,9 +0,0 @@
1
- .container
2
- .row
3
- .col-sm-12
4
- %h1
5
- Uh oh! The Dashboard isn't implemented yet.
6
- %small
7
- This is embarrassing. :(
8
- %h3
9
- ^ Click one of those links up top to use features that are working. ^