tb_core 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +101 -51
- data/app/assets/javascripts/admin/core/application.js +1 -5
- data/app/assets/javascripts/tb_core/remote.js +179 -0
- data/app/assets/libs/jquery-ui/jquery-ui.scss +16 -16
- data/app/assets/stylesheets/admin/core/{application.css.scss → application.scss} +22 -0
- data/app/assets/stylesheets/admin/core/{login.css.scss → login.scss} +0 -0
- data/app/controllers/admin/application_controller.rb +6 -0
- data/app/controllers/admin/users_controller.rb +4 -10
- data/app/controllers/spud/application_controller.rb +8 -2
- data/app/controllers/user_sessions_controller.rb +1 -1
- data/app/helpers/tb_core/application_helper.rb +88 -0
- data/app/views/admin/users/_form.html.erb +21 -17
- data/app/views/admin/users/edit.html.erb +1 -3
- data/app/views/admin/users/new.html.erb +1 -3
- data/app/views/layouts/admin/_search.html.erb +3 -0
- data/app/views/layouts/admin/detail.html.erb +1 -1
- data/app/views/layouts/admin/error_page.html.erb +10 -12
- data/config/locales/en.yml +8 -0
- data/lib/generators/spud/controller_spec_generator.rb +34 -0
- data/lib/generators/spud/module_generator.rb +37 -0
- data/lib/generators/spud/setup_generator.rb +5 -0
- data/lib/generators/spud/templates/admin_controller.rb.erb +2 -7
- data/lib/generators/spud/templates/assets/application.scss +1 -0
- data/lib/generators/spud/templates/controller.rb.erb +1 -5
- data/lib/generators/spud/templates/controller_spec.rb.erb +79 -0
- data/lib/generators/spud/templates/views/admin/_form.html.erb +2 -2
- data/lib/generators/spud/templates/views/layouts/application.html.erb +2 -3
- data/lib/spud_core/belongs_to_app.rb +1 -1
- data/lib/spud_core/engine.rb +2 -0
- data/lib/spud_core/errors.rb +23 -14
- data/lib/spud_core/version.rb +1 -1
- data/lib/tb_core/form_builder.rb +11 -1
- data/lib/tb_core/responder.rb +32 -0
- data/lib/tb_core/test_helper.rb +42 -0
- data/spec/controllers/admin/dashboard_controller_spec.rb +3 -7
- data/spec/controllers/admin/settings_controller_spec.rb +1 -4
- data/spec/controllers/admin/user_sessions_controller_spec.rb +1 -2
- data/spec/controllers/admin/users_controller_spec.rb +1 -4
- data/spec/dummy/app/assets/stylesheets/admin/{application.css.scss → application.scss} +0 -0
- data/spec/dummy/app/assets/stylesheets/{application.css.scss → application.scss} +0 -0
- data/spec/rails_helper.rb +2 -1
- metadata +14 -14
- data/app/helpers/spud/application_helper.rb +0 -36
- data/app/helpers/twice_baked/application_helper.rb +0 -42
- data/spec/authlogic_helper.rb +0 -2
- data/spec/helpers/spud/application_helper_spec.rb +0 -11
@@ -16,16 +16,13 @@ RSpec.describe Admin::DashboardController, :type => :controller do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
before(:each) do
|
19
|
-
|
20
|
-
@user = FactoryGirl.create(:spud_user, :role => FactoryGirl.create(:spud_role))
|
21
|
-
SpudUserSession.create(@user)
|
19
|
+
activate_session(admin: true)
|
22
20
|
end
|
23
21
|
|
24
22
|
describe 'index' do
|
25
23
|
it "should display applications the current user has access to given that the current user is not a super admin" do
|
26
24
|
@user.super_admin = false
|
27
|
-
@user.role.permission_tags
|
28
|
-
@user.role.save()
|
25
|
+
@user.role = FactoryGirl.create(:spud_role, :permission_tags => ['admin.users.full_access'])
|
29
26
|
@user.save()
|
30
27
|
get :index
|
31
28
|
|
@@ -34,8 +31,7 @@ RSpec.describe Admin::DashboardController, :type => :controller do
|
|
34
31
|
|
35
32
|
it "should not display applications the current user does not have access to given that the current user is not a super admin" do
|
36
33
|
@user.super_admin = false
|
37
|
-
@user.role.permission_tags
|
38
|
-
@user.role.save()
|
34
|
+
@user.role = FactoryGirl.create(:spud_role, :permission_tags => ['admin.users.full_access'])
|
39
35
|
@user.save()
|
40
36
|
get :index
|
41
37
|
|
@@ -2,10 +2,7 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
describe Admin::SettingsController, :type => :controller do
|
4
4
|
before(:each) do
|
5
|
-
|
6
|
-
user = FactoryGirl.build(:spud_user)
|
7
|
-
user.super_admin = true
|
8
|
-
SpudUserSession.create(user)
|
5
|
+
activate_session(admin: true)
|
9
6
|
end
|
10
7
|
|
11
8
|
describe 'edit' do
|
@@ -36,8 +36,7 @@ describe Admin::UserSessionsController, :type => :controller do
|
|
36
36
|
|
37
37
|
describe 'destroy' do
|
38
38
|
it "should redirect to login after logout when no referer" do
|
39
|
-
|
40
|
-
SpudUserSession.create(FactoryGirl.build(:spud_user))
|
39
|
+
activate_session(admin: true)
|
41
40
|
delete :destroy
|
42
41
|
expect(response).to redirect_to(admin_login_path)
|
43
42
|
end
|
@@ -3,8 +3,7 @@ require 'rails_helper'
|
|
3
3
|
describe Admin::UsersController, :type => :controller do
|
4
4
|
|
5
5
|
before(:each) do
|
6
|
-
|
7
|
-
@user = SpudUserSession.create(FactoryGirl.build(:spud_user, :super_admin => true))
|
6
|
+
activate_session(admin: true)
|
8
7
|
@role = FactoryGirl.create(:spud_role)
|
9
8
|
Spud::Core.admin_applications += [{:name => 'Test', :key => :test}]
|
10
9
|
Spud::Core.permissions.push(SpudPermission.new('admin.test.full_access', 'Test', [:test]))
|
@@ -97,7 +96,6 @@ describe Admin::UsersController, :type => :controller do
|
|
97
96
|
expect {
|
98
97
|
post :create, :spud_user => FactoryGirl.attributes_for(:spud_user)
|
99
98
|
}.to change(SpudUser, :count).by(1)
|
100
|
-
expect(response).to be_success
|
101
99
|
end
|
102
100
|
|
103
101
|
it "should not create a user with an invalid form entry" do
|
@@ -151,7 +149,6 @@ describe Admin::UsersController, :type => :controller do
|
|
151
149
|
expect {
|
152
150
|
delete :destroy, :id => "23532"
|
153
151
|
}.to_not change(SpudUser, :count)
|
154
|
-
expect(response).to be_redirect
|
155
152
|
end
|
156
153
|
end
|
157
154
|
end
|
File without changes
|
File without changes
|
data/spec/rails_helper.rb
CHANGED
@@ -3,7 +3,8 @@ ENV["RAILS_ENV"] ||= 'test'
|
|
3
3
|
|
4
4
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
5
|
require 'spec_helper'
|
6
|
-
require '
|
6
|
+
# require 'session_helper'
|
7
|
+
require 'tb_core/test_helper'
|
7
8
|
require 'rspec/rails'
|
8
9
|
require 'database_cleaner'
|
9
10
|
require 'simplecov'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tb_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Woods
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -288,6 +288,7 @@ files:
|
|
288
288
|
- app/assets/javascripts/tb_core.js.erb
|
289
289
|
- app/assets/javascripts/tb_core/configuration.js.erb
|
290
290
|
- app/assets/javascripts/tb_core/console.js
|
291
|
+
- app/assets/javascripts/tb_core/remote.js
|
291
292
|
- app/assets/javascripts/tb_core/utility.js
|
292
293
|
- app/assets/libs/datepicker/css/datepicker.css
|
293
294
|
- app/assets/libs/datepicker/js/bootstrap-datepicker.js
|
@@ -308,8 +309,8 @@ files:
|
|
308
309
|
- app/assets/libs/jquery-ui/jquery-ui.js
|
309
310
|
- app/assets/libs/jquery-ui/jquery-ui.scss
|
310
311
|
- app/assets/stylesheets/admin/application.css
|
311
|
-
- app/assets/stylesheets/admin/core/application.
|
312
|
-
- app/assets/stylesheets/admin/core/login.
|
312
|
+
- app/assets/stylesheets/admin/core/application.scss
|
313
|
+
- app/assets/stylesheets/admin/core/login.scss
|
313
314
|
- app/controllers/admin/application_controller.rb
|
314
315
|
- app/controllers/admin/dashboard_controller.rb
|
315
316
|
- app/controllers/admin/password_resets_controller.rb
|
@@ -324,8 +325,7 @@ files:
|
|
324
325
|
- app/controllers/user_sessions_controller.rb
|
325
326
|
- app/helpers/admin/application_helper.rb
|
326
327
|
- app/helpers/admin/roles_helper.rb
|
327
|
-
- app/helpers/
|
328
|
-
- app/helpers/twice_baked/application_helper.rb
|
328
|
+
- app/helpers/tb_core/application_helper.rb
|
329
329
|
- app/mailers/core_mailer.rb
|
330
330
|
- app/models/spud/spud_user_model.rb
|
331
331
|
- app/models/spud_permission.rb
|
@@ -379,6 +379,7 @@ files:
|
|
379
379
|
- db/migrate/20130620151132_create_spud_role_permissions.rb
|
380
380
|
- db/migrate/20130620163144_drop_spud_admin_permissions.rb
|
381
381
|
- db/seeds.rb
|
382
|
+
- lib/generators/spud/controller_spec_generator.rb
|
382
383
|
- lib/generators/spud/module_generator.rb
|
383
384
|
- lib/generators/spud/setup_generator.rb
|
384
385
|
- lib/generators/spud/templates/admin_controller.rb.erb
|
@@ -390,6 +391,7 @@ files:
|
|
390
391
|
- lib/generators/spud/templates/assets/application.scss
|
391
392
|
- lib/generators/spud/templates/assets/module.js.erb
|
392
393
|
- lib/generators/spud/templates/controller.rb.erb
|
394
|
+
- lib/generators/spud/templates/controller_spec.rb.erb
|
393
395
|
- lib/generators/spud/templates/views/admin/_form.html.erb
|
394
396
|
- lib/generators/spud/templates/views/admin/edit.html.erb
|
395
397
|
- lib/generators/spud/templates/views/admin/index.html.erb
|
@@ -411,7 +413,8 @@ files:
|
|
411
413
|
- lib/tasks/spud_core_tasks.rake
|
412
414
|
- lib/tb_core.rb
|
413
415
|
- lib/tb_core/form_builder.rb
|
414
|
-
-
|
416
|
+
- lib/tb_core/responder.rb
|
417
|
+
- lib/tb_core/test_helper.rb
|
415
418
|
- spec/controllers/admin/application_controller_spec.rb
|
416
419
|
- spec/controllers/admin/dashboard_controller_spec.rb
|
417
420
|
- spec/controllers/admin/password_reset_controller_spec.rb
|
@@ -424,8 +427,8 @@ files:
|
|
424
427
|
- spec/dummy/Rakefile
|
425
428
|
- spec/dummy/app/assets/javascripts/admin/application.js
|
426
429
|
- spec/dummy/app/assets/javascripts/application.js
|
427
|
-
- spec/dummy/app/assets/stylesheets/admin/application.
|
428
|
-
- spec/dummy/app/assets/stylesheets/application.
|
430
|
+
- spec/dummy/app/assets/stylesheets/admin/application.scss
|
431
|
+
- spec/dummy/app/assets/stylesheets/application.scss
|
429
432
|
- spec/dummy/app/controllers/application_controller.rb
|
430
433
|
- spec/dummy/app/helpers/application_helper.rb
|
431
434
|
- spec/dummy/app/views/layouts/application.html.erb
|
@@ -464,7 +467,6 @@ files:
|
|
464
467
|
- spec/factories/spud_role_factories.rb
|
465
468
|
- spec/factories/spud_user_factories.rb
|
466
469
|
- spec/helpers/spud/admin/application_helper_spec.rb
|
467
|
-
- spec/helpers/spud/application_helper_spec.rb
|
468
470
|
- spec/lib/spud_core/configuration_spec.rb
|
469
471
|
- spec/models/spud_role_spec.rb
|
470
472
|
- spec/models/spud_user_spec.rb
|
@@ -494,7 +496,6 @@ signing_key:
|
|
494
496
|
specification_version: 4
|
495
497
|
summary: Twice Baked Core Engine
|
496
498
|
test_files:
|
497
|
-
- spec/authlogic_helper.rb
|
498
499
|
- spec/controllers/admin/application_controller_spec.rb
|
499
500
|
- spec/controllers/admin/dashboard_controller_spec.rb
|
500
501
|
- spec/controllers/admin/password_reset_controller_spec.rb
|
@@ -505,8 +506,8 @@ test_files:
|
|
505
506
|
- spec/controllers/spud/application_controller_spec.rb
|
506
507
|
- spec/dummy/app/assets/javascripts/admin/application.js
|
507
508
|
- spec/dummy/app/assets/javascripts/application.js
|
508
|
-
- spec/dummy/app/assets/stylesheets/admin/application.
|
509
|
-
- spec/dummy/app/assets/stylesheets/application.
|
509
|
+
- spec/dummy/app/assets/stylesheets/admin/application.scss
|
510
|
+
- spec/dummy/app/assets/stylesheets/application.scss
|
510
511
|
- spec/dummy/app/controllers/application_controller.rb
|
511
512
|
- spec/dummy/app/helpers/application_helper.rb
|
512
513
|
- spec/dummy/app/views/layouts/application.html.erb
|
@@ -547,7 +548,6 @@ test_files:
|
|
547
548
|
- spec/factories/spud_role_factories.rb
|
548
549
|
- spec/factories/spud_user_factories.rb
|
549
550
|
- spec/helpers/spud/admin/application_helper_spec.rb
|
550
|
-
- spec/helpers/spud/application_helper_spec.rb
|
551
551
|
- spec/lib/spud_core/configuration_spec.rb
|
552
552
|
- spec/models/spud_role_spec.rb
|
553
553
|
- spec/models/spud_user_spec.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Spud::ApplicationHelper
|
2
|
-
|
3
|
-
def tb_page_title
|
4
|
-
if content_for?(:title)
|
5
|
-
title = content_for(:title) + ' : ' + Spud::Core.site_name
|
6
|
-
elsif @page_title
|
7
|
-
title = @page_title + ' : ' + Spud::Core.site_name
|
8
|
-
else
|
9
|
-
title = Spud::Core.site_name
|
10
|
-
end
|
11
|
-
return content_tag :title, title
|
12
|
-
end
|
13
|
-
|
14
|
-
def current_site_name
|
15
|
-
return Spud::Core.config.site_name
|
16
|
-
end
|
17
|
-
|
18
|
-
def cache_key_for_spud_collection(collection, key:'view', cache_params:[], for_user:false)
|
19
|
-
cache_keys = [controller_name, action_name, key]
|
20
|
-
cache_keys << collection.collect(&:updated_at).max().try(:utc).try(:to_i)
|
21
|
-
if for_user
|
22
|
-
cache_keys << current_user_id
|
23
|
-
end
|
24
|
-
if cache_params.any?
|
25
|
-
cache_keys += cache_params.collect{ |cache_param| params[cache_param] || 'nil' }
|
26
|
-
end
|
27
|
-
cache_keys += collection.collect(&:id)
|
28
|
-
cache_key = cache_keys.join('/')
|
29
|
-
if cache_key.length > 250
|
30
|
-
return Digest::SHA1.hexdigest(cache_key)
|
31
|
-
else
|
32
|
-
return cache_key
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module TwiceBaked::ApplicationHelper
|
2
|
-
|
3
|
-
def tb_form_errors(record, *fields_to_display)
|
4
|
-
if record.errors.any?
|
5
|
-
content_tag :div, :class => 'form-errors' do
|
6
|
-
concat(tb_form_error_header(record))
|
7
|
-
concat(raw "<ul>")
|
8
|
-
if fields_to_display.any?
|
9
|
-
messages = fields_to_display.collect{ |field| record.errors.full_messages_for(field) }.flatten()
|
10
|
-
else
|
11
|
-
messages = record.errors.full_messages
|
12
|
-
end
|
13
|
-
concat(raw messages.collect{ |msg| "<li>#{msg}</li>" }.join())
|
14
|
-
concat(raw "</ul>")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def tb_form_error_header(record)
|
20
|
-
if record.errors.any?
|
21
|
-
message = "Please correct the following #{'error'.pluralize(record.errors.size)}:"
|
22
|
-
return content_tag :h4, message, :class => 'form-field-error'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def tb_form_error_field(record, attribute)
|
27
|
-
message = record.errors[attribute].first
|
28
|
-
if message
|
29
|
-
return content_tag :p, message, :class => 'help-block form-field-error'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def tb_form_field(attribute)
|
34
|
-
content_tag :div, :class => 'form-group' do
|
35
|
-
concat label_tag attribute, attribute, :class => 'col-sm-2 control-label'
|
36
|
-
concat(content_tag(:div, :class => 'col-sm-10') do
|
37
|
-
text_field_tag attribute, :placeholder => attribute, :class => 'form-control'
|
38
|
-
end)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
data/spec/authlogic_helper.rb
DELETED