upmin-admin 0.0.39 → 0.1.0

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -14
  3. data/Rakefile +24 -15
  4. data/app/assets/javascripts/upmin/application.js +0 -1
  5. data/app/assets/stylesheets/upmin/base.css.scss +4 -0
  6. data/app/assets/stylesheets/upmin/instances.css.scss +11 -1
  7. data/app/controllers/upmin/models_controller.rb +52 -42
  8. data/app/views/layouts/upmin/_navbar.html.haml +3 -3
  9. data/app/views/layouts/upmin/application.html.haml +2 -1
  10. data/app/views/upmin/models/new.html.haml +3 -3
  11. data/app/views/upmin/models/search.html.haml +5 -4
  12. data/app/views/upmin/models/show.html.haml +3 -3
  13. data/app/views/upmin/partials/actions/_action.html.haml +6 -21
  14. data/app/views/upmin/partials/associations/_associations.html.haml +8 -10
  15. data/app/views/upmin/partials/attributes/_boolean.html.haml +8 -6
  16. data/app/views/upmin/partials/attributes/_datetime.html.haml +38 -36
  17. data/app/views/upmin/partials/attributes/_decimal.html.haml +10 -0
  18. data/app/views/upmin/partials/attributes/_float.html.haml +10 -6
  19. data/app/views/upmin/partials/attributes/_integer.html.haml +10 -6
  20. data/app/views/upmin/partials/attributes/_progress_bar.html.haml +1 -0
  21. data/app/views/upmin/partials/attributes/_string.html.haml +17 -6
  22. data/app/views/upmin/partials/attributes/_text.html.haml +8 -6
  23. data/app/views/upmin/partials/attributes/_unknown.html.haml +5 -3
  24. data/app/views/upmin/partials/models/_model.html.haml +18 -46
  25. data/app/views/upmin/partials/models/_new_model.html.haml +9 -31
  26. data/app/views/upmin/partials/parameters/_block_parameter.haml +0 -0
  27. data/app/views/upmin/partials/parameters/_opt_parameter.html.haml +14 -0
  28. data/app/views/upmin/partials/parameters/_req_parameter.html.haml +4 -0
  29. data/app/views/upmin/partials/search_boxes/_ransack_search_box.html.haml +2 -3
  30. data/app/views/upmin/partials/search_results/_results.html.haml +9 -2
  31. data/lib/upmin/action.rb +50 -0
  32. data/lib/upmin/active_record/association.rb +47 -0
  33. data/lib/upmin/active_record/model.rb +54 -0
  34. data/lib/upmin/active_record/query.rb +12 -0
  35. data/lib/upmin/admin.rb +24 -2
  36. data/lib/upmin/association.rb +73 -0
  37. data/lib/upmin/attribute.rb +87 -0
  38. data/lib/upmin/automatic_delegation.rb +76 -0
  39. data/lib/upmin/configuration.rb +103 -0
  40. data/lib/upmin/data_mapper/association.rb +57 -0
  41. data/lib/upmin/data_mapper/model.rb +62 -0
  42. data/lib/upmin/data_mapper/query.rb +57 -0
  43. data/lib/upmin/engine.rb +2 -0
  44. data/lib/upmin/errors.rb +43 -0
  45. data/lib/upmin/model.rb +267 -98
  46. data/lib/upmin/parameter.rb +43 -0
  47. data/lib/upmin/query.rb +51 -0
  48. data/lib/upmin/railtie.rb +11 -1
  49. data/lib/upmin/railties/active_record.rb +5 -50
  50. data/lib/upmin/railties/data_mapper.rb +18 -0
  51. data/lib/upmin/railties/render.rb +34 -98
  52. data/lib/upmin/railties/render_helpers.rb +119 -53
  53. data/lib/upmin/version.rb +1 -1
  54. data/spec/factories/factories.rb +6 -0
  55. data/spec/features/action_spec.rb +39 -46
  56. data/spec/features/edit_model_spec.rb +4 -2
  57. data/spec/features/navbar_spec.rb +48 -0
  58. data/spec/features/new_model_spec.rb +1 -0
  59. data/spec/features/search_spec.rb +7 -4
  60. data/spec/lib/configuration_spec.rb +60 -0
  61. data/spec/spec_helper.rb +14 -8
  62. metadata +25 -7
  63. data/app/assets/javascripts/upmin/moment.js +0 -2856
  64. data/app/helpers/upmin/instances_helper.rb +0 -13
  65. data/app/views/upmin/partials/attributes/_nilable.html.haml +0 -14
  66. data/app/views/upmin/partials/search_results/_result.html.haml +0 -8
  67. data/lib/upmin/klass.rb +0 -170
@@ -1,3 +1,3 @@
1
1
  module Upmin
2
- VERSION = "0.0.39"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -6,6 +6,12 @@ FactoryGirl.define do
6
6
  stripe_card_id "sc_123ab1123"
7
7
  end
8
8
 
9
+ factory(:user_dif, class: User) do
10
+ name "Not Jon Calhoun"
11
+ email "notjoncalhoun@gmail.com"
12
+ stripe_card_id "notsc_123ab1123"
13
+ end
14
+
9
15
  factory(:product) do
10
16
  name "Office Home & Student 2013 - Windows"
11
17
  short_desc "Create, communicate and learn using streamlined touch, pen or keyboard commands"
@@ -6,63 +6,56 @@ feature("Performing an action") do
6
6
  # Setup BG Stuff
7
7
  end
8
8
 
9
- scenario("with a valid user") do
10
- visit("/upmin/m/User/new")
11
-
12
- expected_user = build(:user)
13
-
14
- fill_in("user_name", with: expected_user.name)
15
- fill_in("user_email", with: expected_user.email)
16
- fill_in("user_stripe_card_id", with: expected_user.stripe_card_id)
17
-
18
- expect { click_button("Create") }.to(change(User, :count).by(1))
9
+ scenario("with an existing method") do
10
+ user = User.first
11
+ visit("/upmin/m/User/i/#{user.id}")
12
+
13
+ within(".actions") do
14
+ expect(page).to(have_selector("h4", text: "Issue coupon"))
15
+ within("form.issue_coupon") do
16
+ fill_in("issue_coupon_percent", with: "20")
17
+ click_button("Submit")
18
+ end
19
+ end
19
20
 
20
- expect(page).to(have_selector("input#user_name[value='#{expected_user.name}']"))
21
- expect(page).to(have_selector("input#user_email[value='#{expected_user.email}']"))
22
- expect(page).to(have_selector("input#user_stripe_card_id[value='#{expected_user.stripe_card_id}']"))
21
+ within(".alert.alert-info") do
22
+ expect(page).to(have_content("CPN_FJALDKF01Z1"))
23
+ end
23
24
  end
24
25
 
25
- scenario("with an invalid user") do
26
- visit("/upmin/m/User/new")
27
-
28
- invalid_user = build(:user, email: "invalid")
26
+ scenario("without an optional parameter") do
27
+ user = User.first
28
+ visit("/upmin/m/User/i/#{user.id}")
29
29
 
30
- fill_in("user_name", with: invalid_user.name)
31
- fill_in("user_email", with: invalid_user.email)
32
- fill_in("user_stripe_card_id", with: invalid_user.stripe_card_id)
33
-
34
- expect { click_button("Create") }.not_to(change(User, :count))
35
-
36
- within(".alert.alert-danger") do
37
- expect(page).to(have_content("User was NOT created."))
30
+ within(".actions") do
31
+ expect(page).to(have_selector("h4", text: "Issue coupon"))
32
+ within("form.issue_coupon") do
33
+ check("issue_coupon_percent_is_nil")
34
+ click_button("Submit")
35
+ end
38
36
  end
39
37
 
40
- within(".field_with_errors") do
41
- expect(page).to(have_selector("input#user_email"))
38
+ within(".alert.alert-info") do
39
+ expect(page).to(have_content("CPN_FJALDKF01Z1"))
42
40
  end
43
-
44
- # Make sure the inputs have the values typed in.
45
- expect(page).to(have_selector("input#user_name[value='#{invalid_user.name}']"))
46
- expect(page).to(have_selector("input#user_email[value='#{invalid_user.email}']"))
47
- expect(page).to(have_selector("input#user_stripe_card_id[value='#{invalid_user.stripe_card_id}']"))
48
41
  end
49
42
 
50
- scenario("with a nil attribute") do
51
- product = build(:product)
52
- visit("/upmin/m/Product/new")
43
+ scenario("with an admin only method") do
44
+ product = Product.first
45
+ visit("/upmin/m/Product/i/#{product.id}")
53
46
 
54
- check("product_name_is_nil")
55
- fill_in("product_short_desc", with: product.short_desc)
56
- fill_in("product_manufacturer", with: product.manufacturer)
47
+ new_price = "10.15"
57
48
 
58
- expect { click_button("Create") }.to(change(Product, :count).by(1))
59
-
60
- box = find("#product_name_is_nil")
61
- expect(box).to(be_checked)
49
+ within(".actions") do
50
+ expect(page).to(have_selector("h4", text: "Update price"))
51
+ within("form.update_price") do
52
+ fill_in("update_price_price", with: new_price)
53
+ click_button("Submit")
54
+ end
55
+ end
62
56
 
63
- created = Product.last
64
- expect(created.name).to(be_nil)
65
- expect(created.short_desc).to(eq(product.short_desc))
66
- expect(created.manufacturer).to(eq(product.manufacturer))
57
+ product.reload
58
+ expect(product.price.to_s[0..4]).to(eq(new_price))
67
59
  end
60
+
68
61
  end
@@ -28,8 +28,8 @@ feature("Update an existing model") do
28
28
  expect(user.stripe_card_id).to(eq(updated_user.stripe_card_id))
29
29
  end
30
30
 
31
- scenario("with invalid order info") do
32
- user = User.first
31
+ scenario("with invalid user info") do
32
+ user = create(:user_dif)
33
33
  invalid_user = build(:user, email: "invalid")
34
34
 
35
35
  visit("/upmin/m/User/i/#{user.id}")
@@ -42,6 +42,7 @@ feature("Update an existing model") do
42
42
 
43
43
  within(".alert.alert-danger") do
44
44
  expect(page).to(have_content("User was NOT updated."))
45
+ expect(page).to(have_selector("li", text: /email/i))
45
46
  end
46
47
 
47
48
  within(".field_with_errors") do
@@ -56,6 +57,7 @@ feature("Update an existing model") do
56
57
  expect(user.name).not_to(eq(invalid_user.name))
57
58
  expect(user.email).not_to(eq(invalid_user.email))
58
59
  expect(user.stripe_card_id).not_to(eq(invalid_user.stripe_card_id))
60
+
59
61
  end
60
62
 
61
63
  scenario("with a nil attribute") do
@@ -0,0 +1,48 @@
1
+ # encoding: UTF-8
2
+ require "spec_helper"
3
+
4
+ feature("Navbar") do
5
+ background do
6
+ # Setup BG Stuff
7
+ end
8
+
9
+ scenario("default models") do
10
+ visit ("/upmin")
11
+
12
+ within(".navbar ul.nav") do
13
+ expect(page).to(have_selector("li", text: "Users"))
14
+ expect(page).to(have_selector("li", text: "Products"))
15
+ expect(page).to(have_selector("li", text: "Orders"))
16
+ expect(page).to(have_selector("li", text: "Product Orders"))
17
+ expect(page).to(have_selector("li", text: "Shipments"))
18
+
19
+ click_link("Users")
20
+ end
21
+
22
+ expect(page).to(have_selector(".upmin-model", minimum: 10))
23
+ end
24
+
25
+ scenario("configged models") do
26
+ Upmin.configure do |config|
27
+ config.models = [:user, :product]
28
+ end
29
+
30
+ visit ("/upmin")
31
+
32
+ within(".navbar ul.nav") do
33
+ expect(page).to(have_selector("li", text: "Users"))
34
+ expect(page).to(have_selector("li", text: "Products"))
35
+ expect(page).not_to(have_selector("li", text: "Orders"))
36
+ expect(page).not_to(have_selector("li", text: "Product Orders"))
37
+ expect(page).not_to(have_selector("li", text: "Shipments"))
38
+
39
+ click_link("Users")
40
+ end
41
+
42
+ expect(page).to(have_selector(".upmin-model", minimum: 10))
43
+
44
+ # Reset this.
45
+ Upmin.configuration = Upmin::Configuration.new
46
+ end
47
+
48
+ end
@@ -53,6 +53,7 @@ feature("Create a new model") do
53
53
 
54
54
  check("product_name_is_nil")
55
55
  fill_in("product_short_desc", with: product.short_desc)
56
+ fill_in("product_price", with: product.price)
56
57
  fill_in("product_manufacturer", with: product.manufacturer)
57
58
 
58
59
  expect { click_button("Create") }.to(change(Product, :count).by(1))
@@ -6,11 +6,15 @@ feature("Search Views") do
6
6
  # Setup BG Stuff
7
7
  end
8
8
 
9
+ scenario("Nav Bar") do
10
+ # it("TODO(jon): Write this test")
11
+ end
12
+
9
13
  scenario("Pagination") do
10
14
  visit("/upmin/m/User")
11
15
 
12
16
  # Make sure some basic pagination exits
13
- within(".pagination") do
17
+ within(".pagination:first-of-type") do
14
18
  within(".current") do
15
19
  expect(page).to(have_content("1"))
16
20
  end
@@ -19,7 +23,7 @@ feature("Search Views") do
19
23
  click_link("Next")
20
24
  end
21
25
 
22
- within(".pagination") do
26
+ within(".pagination:nth-of-type(2)") do
23
27
  within(".current") do
24
28
  expect(page).to(have_content("2"))
25
29
  end
@@ -30,7 +34,7 @@ feature("Search Views") do
30
34
  click_link("3")
31
35
  end
32
36
 
33
- within(".pagination") do
37
+ within(".pagination:last-of-type") do
34
38
  within(".current") do
35
39
  expect(page).to(have_content("3"))
36
40
  end
@@ -73,5 +77,4 @@ feature("Search Views") do
73
77
  expect(page).to(have_content(expected_user.name))
74
78
  end
75
79
 
76
-
77
80
  end
@@ -0,0 +1,60 @@
1
+ # encoding: UTF-8
2
+ require "spec_helper"
3
+
4
+ describe Upmin::Configuration do
5
+ before(:each) do
6
+ @config = Upmin::Configuration.new
7
+ end
8
+
9
+ describe "#colors" do
10
+
11
+ context "default colors" do
12
+ it { expect(@config.colors).to(include(:red)) }
13
+ it { expect(@config.colors).to(include(:green)) }
14
+
15
+ describe "#length" do
16
+ it { expect(@config.colors.length).to(be >= 9) }
17
+ end
18
+ end
19
+
20
+ context "custom colors" do
21
+ before(:each) { @config.colors = [:red, :blue] }
22
+
23
+ it { expect(@config.colors).to(include(:red)) }
24
+ it { expect(@config.colors).to(include(:blue)) }
25
+ it { expect(@config.colors).not_to(include(:green)) }
26
+
27
+ describe "#length" do
28
+ it { expect(@config.colors.length).to(eq(2)) }
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ describe "#models" do
35
+
36
+ context "default models" do
37
+ it { expect(@config.models).to(include(:user)) }
38
+ it { expect(@config.models).to(include(:order)) }
39
+ it { expect(@config.models).to(include(:product)) }
40
+
41
+ describe "#length" do
42
+ it { expect(@config.models.length).to(be >= 4) }
43
+ end
44
+ end
45
+
46
+ context "custom models" do
47
+ before(:each) { @config.models = [:user, :order] }
48
+
49
+ it { expect(@config.models).to(include(:user)) }
50
+ it { expect(@config.models).to(include(:order)) }
51
+ it { expect(@config.models).not_to(include(:product)) }
52
+
53
+ describe "#length" do
54
+ it { expect(@config.models.length).to(eq(2)) }
55
+ end
56
+ end
57
+
58
+ end
59
+
60
+ end
@@ -7,9 +7,8 @@ require 'capybara/rails'
7
7
  require 'database_cleaner'
8
8
  require 'factory_girl_rails'
9
9
 
10
-
11
- if defined?(ActiveRecord)
12
- require File.expand_path('../../../../seed/seeder', __FILE__)
10
+ if defined?(ActiveRecord) || defined?(DataMapper)
11
+ require File.expand_path('../../../../test_seeders/seeder', __FILE__)
13
12
  end
14
13
 
15
14
 
@@ -28,6 +27,12 @@ RSpec.configure do |config|
28
27
  end
29
28
 
30
29
  config.before(:suite) do
30
+ if defined?(DataMapper)
31
+ # NOTE: eager_loading needs to be on in the app for testing.
32
+ DataMapper.finalize
33
+ DataMapper.auto_migrate!
34
+ end
35
+
31
36
  Seeder.seed
32
37
  end
33
38
 
@@ -41,11 +46,12 @@ RSpec.configure do |config|
41
46
  end
42
47
 
43
48
  # Uncomment this if you want to the page to be saved and opened after any test failure.
44
- # config.after do |example|
45
- # if example.metadata[:type] == :feature && example.exception.present?
46
- # save_and_open_page
47
- # end
48
- # end
49
+ config.after do |example|
50
+ if example.metadata[:type] == :feature && example.exception.present?
51
+ save_and_open_page
52
+ end
53
+ end
49
54
 
50
55
  config.include(FactoryGirl::Syntax::Methods)
56
+ config.include(ActionView::Helpers::NumberHelper, type: :view)
51
57
  end
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.0.39
4
+ version: 0.1.0
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-09-21 00:00:00.000000000 Z
12
+ date: 2014-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -181,7 +181,6 @@ files:
181
181
  - app/assets/javascripts/upmin/helpers.js
182
182
  - app/assets/javascripts/upmin/jquery-clockpicker.js
183
183
  - app/assets/javascripts/upmin/models.js
184
- - app/assets/javascripts/upmin/moment.js
185
184
  - app/assets/javascripts/upmin/pikaday.js
186
185
  - app/assets/stylesheets/upmin/actions.css.scss
187
186
  - app/assets/stylesheets/upmin/application.css
@@ -196,7 +195,6 @@ files:
196
195
  - app/controllers/upmin/application_controller.rb
197
196
  - app/controllers/upmin/models_controller.rb
198
197
  - app/helpers/upmin/application_helper.rb
199
- - app/helpers/upmin/instances_helper.rb
200
198
  - app/helpers/upmin/models_helper.rb
201
199
  - app/views/layouts/upmin/_navbar.html.haml
202
200
  - app/views/layouts/upmin/application.html.haml
@@ -208,29 +206,45 @@ files:
208
206
  - app/views/upmin/partials/associations/_associations.html.haml
209
207
  - app/views/upmin/partials/attributes/_boolean.html.haml
210
208
  - app/views/upmin/partials/attributes/_datetime.html.haml
209
+ - app/views/upmin/partials/attributes/_decimal.html.haml
211
210
  - app/views/upmin/partials/attributes/_float.html.haml
212
211
  - app/views/upmin/partials/attributes/_integer.html.haml
213
- - app/views/upmin/partials/attributes/_nilable.html.haml
214
212
  - app/views/upmin/partials/attributes/_progress_bar.html.haml
215
213
  - app/views/upmin/partials/attributes/_string.html.haml
216
214
  - app/views/upmin/partials/attributes/_text.html.haml
217
215
  - app/views/upmin/partials/attributes/_unknown.html.haml
218
216
  - app/views/upmin/partials/models/_model.html.haml
219
217
  - app/views/upmin/partials/models/_new_model.html.haml
218
+ - app/views/upmin/partials/parameters/_block_parameter.haml
219
+ - app/views/upmin/partials/parameters/_opt_parameter.html.haml
220
+ - app/views/upmin/partials/parameters/_req_parameter.html.haml
220
221
  - app/views/upmin/partials/search_boxes/_ransack_search_box.html.haml
221
- - app/views/upmin/partials/search_results/_result.html.haml
222
222
  - app/views/upmin/partials/search_results/_results.html.haml
223
223
  - config/routes.rb
224
224
  - lib/tasks/accordive_rails_tasks.rake
225
225
  - lib/tasks/upmin_tasks.rake
226
226
  - lib/upmin.rb
227
+ - lib/upmin/action.rb
228
+ - lib/upmin/active_record/association.rb
229
+ - lib/upmin/active_record/model.rb
230
+ - lib/upmin/active_record/query.rb
227
231
  - lib/upmin/admin.rb
232
+ - lib/upmin/association.rb
233
+ - lib/upmin/attribute.rb
234
+ - lib/upmin/automatic_delegation.rb
235
+ - lib/upmin/configuration.rb
236
+ - lib/upmin/data_mapper/association.rb
237
+ - lib/upmin/data_mapper/model.rb
238
+ - lib/upmin/data_mapper/query.rb
228
239
  - lib/upmin/engine.rb
229
- - lib/upmin/klass.rb
240
+ - lib/upmin/errors.rb
230
241
  - lib/upmin/model.rb
231
242
  - lib/upmin/paginator.rb
243
+ - lib/upmin/parameter.rb
244
+ - lib/upmin/query.rb
232
245
  - lib/upmin/railtie.rb
233
246
  - lib/upmin/railties/active_record.rb
247
+ - lib/upmin/railties/data_mapper.rb
234
248
  - lib/upmin/railties/paginator.rb
235
249
  - lib/upmin/railties/render.rb
236
250
  - lib/upmin/railties/render_helpers.rb
@@ -238,8 +252,10 @@ files:
238
252
  - spec/factories/factories.rb
239
253
  - spec/features/action_spec.rb
240
254
  - spec/features/edit_model_spec.rb
255
+ - spec/features/navbar_spec.rb
241
256
  - spec/features/new_model_spec.rb
242
257
  - spec/features/search_spec.rb
258
+ - spec/lib/configuration_spec.rb
243
259
  - spec/spec_helper.rb
244
260
  homepage: https://www.upmin.com/admin-rails
245
261
  licenses:
@@ -269,6 +285,8 @@ test_files:
269
285
  - spec/factories/factories.rb
270
286
  - spec/features/action_spec.rb
271
287
  - spec/features/edit_model_spec.rb
288
+ - spec/features/navbar_spec.rb
272
289
  - spec/features/new_model_spec.rb
273
290
  - spec/features/search_spec.rb
291
+ - spec/lib/configuration_spec.rb
274
292
  - spec/spec_helper.rb