introspective_admin 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/introspective_admin/base.rb +4 -3
- data/lib/introspective_admin/version.rb +1 -1
- data/spec/admin/location_beacon_admin_spec.rb +73 -0
- data/spec/dummy/app/admin/location_beacon_admin.rb +6 -0
- data/spec/dummy/app/models/location_beacon.rb +3 -0
- data/spec/dummy/db/migrate/20150601212924_create_location_beacons.rb +1 -0
- data/spec/dummy/db/schema.rb +1 -0
- data/spec/support/blueprints.rb +2 -2
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34189bc924cbba881f0a7657ab2baff9ee7b3b78
|
4
|
+
data.tar.gz: 480171232780e51a4849ebd4c9b8bd238f022659
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc3cc21f355374e2913030de42303428afebc7f2d22e70685fb5628df57e73175b3381de4ba271ee34fade1e7bced2811091e6e277359a80eb4b610ef252f2df
|
7
|
+
data.tar.gz: 1f4457130ca6007821d290aaa7ce4a21d9fe710d957cbb8acd476b90020815982ef9efa471e3da463c424f2dbd82b37292cc9831e12d4599d2ba96115d78d695
|
data/Gemfile.lock
CHANGED
@@ -56,7 +56,7 @@ module IntrospectiveAdmin
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
def register(model)
|
59
|
+
def register(model, &block)
|
60
60
|
# Defining activeadmin pages will break pending migrations:
|
61
61
|
begin ActiveRecord::Migration.check_pending! rescue return end
|
62
62
|
|
@@ -78,6 +78,8 @@ module IntrospectiveAdmin
|
|
78
78
|
}]
|
79
79
|
|
80
80
|
ActiveAdmin.register model do
|
81
|
+
instance_eval &block if block_given? # Evalutate the passed black for overrides to the defaults
|
82
|
+
|
81
83
|
controller do
|
82
84
|
def scoped_collection
|
83
85
|
super.includes super.nested_attributes_options.keys
|
@@ -85,6 +87,7 @@ module IntrospectiveAdmin
|
|
85
87
|
end
|
86
88
|
|
87
89
|
index do
|
90
|
+
selectable_column
|
88
91
|
cols = model.columns.map(&:name)-klass.exclude_params
|
89
92
|
cols.each_with_index do |c,i|
|
90
93
|
column c
|
@@ -173,8 +176,6 @@ module IntrospectiveAdmin
|
|
173
176
|
end
|
174
177
|
end
|
175
178
|
|
176
|
-
yield # Yield the DSL to the child class for further customization
|
177
|
-
|
178
179
|
end
|
179
180
|
end
|
180
181
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.describe Admin::LocationBeaconsController, :type => :controller do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
before :each do # Why can't I do this shit in a helper like I do for requests?
|
7
|
+
user = double('user')
|
8
|
+
allow(request.env['warden']).to receive(:authenticate!) { user }
|
9
|
+
allow(controller).to receive(:current_user) { user }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "GET index" do
|
13
|
+
it "finds all location beacons" do
|
14
|
+
c = LocationBeacon.make!(last_known_battery_level: 50)
|
15
|
+
d = LocationBeacon.make!(last_known_battery_level: 4)
|
16
|
+
get :index
|
17
|
+
response.status.should == 200
|
18
|
+
assigns(:location_beacons).include?(c).should == true
|
19
|
+
assigns(:location_beacons).include?(d).should == true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "scopes location beacons by low battery level" do
|
23
|
+
c = LocationBeacon.make!(last_known_battery_level: 50)
|
24
|
+
d = LocationBeacon.make!(last_known_battery_level: 4)
|
25
|
+
get :index, { scope: 'low_battery' }
|
26
|
+
response.status.should == 200
|
27
|
+
assigns(:location_beacons).include?(c).should == false
|
28
|
+
assigns(:location_beacons).include?(d).should == true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "SHOW record" do
|
33
|
+
it "finds the record" do
|
34
|
+
c = LocationBeacon.make!
|
35
|
+
get :show, id: c.id
|
36
|
+
response.status.should == 200
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "NEW record" do
|
41
|
+
# will fail until https://github.com/activeadmin/activeadmin/pull/4010 is merged
|
42
|
+
it "renders the form for a new record" do
|
43
|
+
get :new
|
44
|
+
response.status.should == 200
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "CREATE record" do
|
49
|
+
it "creates the record" do
|
50
|
+
c = LocationBeacon.make
|
51
|
+
post :create, location_beacon: c.attributes
|
52
|
+
response.should redirect_to action: :show, id: LocationBeacon.last.id
|
53
|
+
LocationBeacon.last.mac_address.should =~ /#{c.mac_address}/i
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "EDIT record" do
|
58
|
+
it "renders the edit form for an existing record" do
|
59
|
+
r = LocationBeacon.make!
|
60
|
+
get :edit, id: r.id
|
61
|
+
response.status.should == 200
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "UPDATE record" do
|
66
|
+
it "updates the record" do
|
67
|
+
r = LocationBeacon.make!
|
68
|
+
put :update, id: r.id, location_beacon: { last_known_battery_level: 30 }
|
69
|
+
response.should redirect_to action: :show, id: r.id
|
70
|
+
LocationBeacon.find(r.id).last_known_battery_level.should == 30
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -117,6 +117,7 @@ ActiveRecord::Schema.define(version: 20150909225019) do
|
|
117
117
|
t.string "uuid", limit: 32, null: false
|
118
118
|
t.integer "major", null: false
|
119
119
|
t.integer "minor", null: false
|
120
|
+
t.integer "last_known_battery_level"
|
120
121
|
t.datetime "created_at", null: false
|
121
122
|
t.datetime "updated_at", null: false
|
122
123
|
end
|
data/spec/support/blueprints.rb
CHANGED
@@ -52,8 +52,8 @@ Location.blueprint {
|
|
52
52
|
gps { LocationGps.new(lat: 37.615223, lng: -122.389977 ) }
|
53
53
|
}
|
54
54
|
LocationBeacon.blueprint {
|
55
|
-
location { Location.make }
|
56
|
-
company { Company.make }
|
55
|
+
location { Location.make! }
|
56
|
+
company { Company.make! }
|
57
57
|
mac_address { SecureRandom.hex(6) }
|
58
58
|
# e.g. 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6
|
59
59
|
uuid { SecureRandom.hex(4)+'-'+SecureRandom.hex(2)+'-'+SecureRandom.hex(2)+'-'+SecureRandom.hex(2)+'-'+SecureRandom.hex(6) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: introspective_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Buermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass-rails
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- spec/admin/company_admin_spec.rb
|
147
147
|
- spec/admin/job_admin_spec.rb
|
148
148
|
- spec/admin/location_admin_spec.rb
|
149
|
+
- spec/admin/location_beacon_admin_spec.rb
|
149
150
|
- spec/admin/project__admin_spec.rb
|
150
151
|
- spec/admin/user_admin_spec.rb
|
151
152
|
- spec/dummy/README.rdoc
|
@@ -153,6 +154,7 @@ files:
|
|
153
154
|
- spec/dummy/app/admin/company_admin.rb
|
154
155
|
- spec/dummy/app/admin/job_admin.rb
|
155
156
|
- spec/dummy/app/admin/location_admin.rb
|
157
|
+
- spec/dummy/app/admin/location_beacon_admin.rb
|
156
158
|
- spec/dummy/app/admin/project_admin.rb
|
157
159
|
- spec/dummy/app/admin/role_admin.rb
|
158
160
|
- spec/dummy/app/admin/user_admin.rb
|
@@ -272,6 +274,7 @@ test_files:
|
|
272
274
|
- spec/admin/company_admin_spec.rb
|
273
275
|
- spec/admin/job_admin_spec.rb
|
274
276
|
- spec/admin/location_admin_spec.rb
|
277
|
+
- spec/admin/location_beacon_admin_spec.rb
|
275
278
|
- spec/admin/project__admin_spec.rb
|
276
279
|
- spec/admin/user_admin_spec.rb
|
277
280
|
- spec/dummy/README.rdoc
|
@@ -279,6 +282,7 @@ test_files:
|
|
279
282
|
- spec/dummy/app/admin/company_admin.rb
|
280
283
|
- spec/dummy/app/admin/job_admin.rb
|
281
284
|
- spec/dummy/app/admin/location_admin.rb
|
285
|
+
- spec/dummy/app/admin/location_beacon_admin.rb
|
282
286
|
- spec/dummy/app/admin/project_admin.rb
|
283
287
|
- spec/dummy/app/admin/role_admin.rb
|
284
288
|
- spec/dummy/app/admin/user_admin.rb
|