tb_core 1.1.4 → 1.1.5
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 +8 -8
- data/README.md +29 -3
- data/Rakefile +9 -0
- data/app/controllers/spud/application_controller.rb +12 -0
- data/app/views/admin/setup/new.html.erb +1 -1
- data/app/views/layouts/admin/application.html.erb +1 -1
- data/app/views/layouts/not_found.html.erb +6 -0
- data/config/routes.rb +1 -0
- data/lib/spud_core/configuration.rb +2 -1
- data/lib/spud_core/exceptions.rb +7 -0
- data/lib/spud_core/version.rb +1 -1
- data/spec/controllers/admin/application_controller_spec.rb +0 -1
- data/spec/controllers/spud/application_controller_spec.rb +9 -0
- data/spec/dummy/log/test.log +69964 -0
- data/spec/integration/admin_setup_spec.rb +8 -0
- data/spec/javascripts/date_picker_spec.js +8 -0
- data/spec/javascripts/support/jasmine.yml +88 -0
- data/spec/javascripts/support/jasmine_helper.rb +11 -0
- data/spec/models/spud_user_spec.rb +13 -0
- data/spec/spec_helper.rb +4 -1
- metadata +40 -5
- data/spec/requests/legacy_spec.rb +0 -8
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzM4ZjU3ZmRjOGE0N2M1MDAzYzdmNjI0MmRkM2FmMWQ3NjQ5YTAzMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yzc5M2QwYmMzNDM1ZWU1YWI5NDljNjg4MGE3NzNlZTNiM2M3MzQ5NQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDMxMzMwZmVlMzg1OTBjMDdiYjNlNGQ2OGYxOWVjYWY1Mzc2ZTRlMjFjN2Y4
|
10
|
+
MTA5MDkyMDFlYjU2ZGZjNWJhNzBlMDc0OTJlYTA5YmY5MzhjZDliMjQxOGM4
|
11
|
+
Njk2Y2JjNDEwNWNmYjgzNTg5MjViMDJiNmU3ZjBhN2NiZTViYzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmVjNmY5Yjk0NDZhMzFlNDI2MTMyZWYxYjkzZGQ0MDM5ODMzODM3ZmQ2MTI4
|
14
|
+
NzRkYjY1NWFhYzdkMGI4ZmYzYzk5YWYzNGUyMzZhZjRhZjdiNWI4N2Q4ZTIy
|
15
|
+
MGY3MDdjM2Y1ZjdhZDY1YzZkZWRhZjcxYjk0YmYyNzZmYzliMTk=
|
data/README.md
CHANGED
@@ -11,10 +11,11 @@ Installation/Usage
|
|
11
11
|
gem 'tb_core'
|
12
12
|
|
13
13
|
2. Run bundle install
|
14
|
+
|
14
15
|
3. Copy in database migrations to your new rails project
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
bundle exec rake tb_core:install:migrations
|
18
|
+
rake db:migrate
|
18
19
|
|
19
20
|
4. run a rails server instance and point your browser to /admin
|
20
21
|
|
@@ -68,10 +69,28 @@ Finally, custom permissions may optionally be tied to one or more dashboard apps
|
|
68
69
|
:apps => [:clients, :projects]
|
69
70
|
}]
|
70
71
|
|
72
|
+
404 Handling
|
73
|
+
------------
|
74
|
+
|
75
|
+
The base `Spud::ApplicationController` will automatically rescue from any `Spud::NotFoundError` errors by rendering out the template specified in `Spud::Core.not_found_template`. The default tempalte is `layouts/not_found.html`. To customize this view, create a template by that name in your own project.
|
76
|
+
|
77
|
+
When building your own apps you may raise a `Spud::NotFoundError` at any time to halt further execution and cause the 404 page to render. For example:
|
78
|
+
|
79
|
+
class CarsController
|
80
|
+
before_filter :get_record
|
81
|
+
# ... actions here
|
82
|
+
def get_record
|
83
|
+
@car = Car.where(:id => params[:id]).first
|
84
|
+
if @car.blank?
|
85
|
+
raise Spud::NotFoundError(:item => 'car')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
71
90
|
Testing
|
72
91
|
-----------------
|
73
92
|
|
74
|
-
Twice Baked uses RSpec for testing. Get the tests running with a few short commands:
|
93
|
+
Twice Baked uses RSpec, Capybara and Jasmine for testing. Get the tests running with a few short commands:
|
75
94
|
|
76
95
|
1. Create and migrate the databases:
|
77
96
|
|
@@ -87,3 +106,10 @@ Twice Baked uses RSpec for testing. Get the tests running with a few short comma
|
|
87
106
|
rspec spec
|
88
107
|
|
89
108
|
After the tests have completed the current code coverage stats is available by opening `/coverage/index.html` in a browser.
|
109
|
+
|
110
|
+
### Jasmine
|
111
|
+
|
112
|
+
For running the javascript unit tets:
|
113
|
+
|
114
|
+
rake jasmine:ci
|
115
|
+
|
data/Rakefile
CHANGED
@@ -26,3 +26,12 @@ load 'rails/tasks/engine.rake'
|
|
26
26
|
Bundler::GemHelper.install_tasks
|
27
27
|
|
28
28
|
require 'rake'
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'jasmine'
|
32
|
+
load 'jasmine/tasks/jasmine.rake'
|
33
|
+
rescue LoadError
|
34
|
+
task :jasmine do
|
35
|
+
abort "Jasmine is not available. In order to run jasmine, you must: (sudo) gem install jasmine"
|
36
|
+
end
|
37
|
+
end
|
@@ -11,6 +11,12 @@ class Spud::ApplicationController < ActionController::Base
|
|
11
11
|
include Spud::ApplicationHelper
|
12
12
|
before_filter :set_mailer_default_url
|
13
13
|
|
14
|
+
rescue_from Spud::NotFoundError, :with => :handle_not_found
|
15
|
+
|
16
|
+
def not_found
|
17
|
+
raise Spud::NotFoundError
|
18
|
+
end
|
19
|
+
|
14
20
|
private
|
15
21
|
|
16
22
|
def set_mailer_default_url
|
@@ -72,4 +78,10 @@ private
|
|
72
78
|
end
|
73
79
|
end
|
74
80
|
|
81
|
+
def handle_not_found(exception)
|
82
|
+
@exception = exception
|
83
|
+
@exception.request_url = request.original_url
|
84
|
+
render :template => Spud::Core.not_found_template, :layout => nil, :formats => [:html], :status => 404
|
85
|
+
end
|
86
|
+
|
75
87
|
end
|
data/config/routes.rb
CHANGED
@@ -30,5 +30,6 @@ Rails.application.routes.draw do
|
|
30
30
|
resources :password_resets, :only => [:index, :create, :show, :update], :path => 'login/forgot'
|
31
31
|
|
32
32
|
get 'spud/admin' => 'admin/user_sessions#legacy_redirect'
|
33
|
+
get 'spud/not_found' => 'spud/application#not_found', :as => 'not_found'
|
33
34
|
|
34
35
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spud
|
2
2
|
module Core
|
3
3
|
include ActiveSupport::Configurable
|
4
|
-
config_accessor :site_name,:admin_applications,:sitemap_urls,:multisite_mode_enabled,:multisite_config,:from_address,:site_id,:short_name, :javascripts,:stylesheets, :admin_javascripts, :admin_stylesheets, :permissions
|
4
|
+
config_accessor :site_name,:admin_applications,:sitemap_urls,:multisite_mode_enabled,:multisite_config,:from_address,:site_id,:short_name, :javascripts,:stylesheets, :admin_javascripts, :admin_stylesheets, :permissions, :not_found_template
|
5
5
|
self.admin_applications = []
|
6
6
|
self.site_name = "Company Name"
|
7
7
|
self.site_id = 0
|
@@ -15,6 +15,7 @@ module Spud
|
|
15
15
|
self.permissions = []
|
16
16
|
self.admin_javascripts = ['admin/application']
|
17
17
|
self.admin_stylesheets = ['admin/application']
|
18
|
+
self.not_found_template = 'layouts/not_found'
|
18
19
|
|
19
20
|
def self.site_config_for_host(host)
|
20
21
|
configs = Spud::Core.multisite_config.select{|p| p[:hosts].include?(host)}
|
data/lib/spud_core/exceptions.rb
CHANGED
@@ -3,5 +3,12 @@ class Spud::AccessDeniedError < StandardError
|
|
3
3
|
end
|
4
4
|
|
5
5
|
class Spud::NotFoundError < StandardError
|
6
|
+
|
7
|
+
attr_accessor :request_url, :item
|
8
|
+
|
9
|
+
def initialize(opts={})
|
10
|
+
@item = opts[:item] || 'page'
|
11
|
+
super("The #{item.downcase} you were looking for could not be found.")
|
12
|
+
end
|
6
13
|
|
7
14
|
end
|
data/lib/spud_core/version.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'rspec/mocks'
|
3
|
+
require 'rspec/mocks/standalone'
|
2
4
|
|
3
5
|
describe Spud::ApplicationController do
|
4
6
|
|
7
|
+
describe :not_found do
|
8
|
+
it 'throws a 404 error' do
|
9
|
+
get :not_found
|
10
|
+
response.code.should eq("404")
|
11
|
+
response.should render_template(Spud::Core.not_found_template)
|
12
|
+
end
|
13
|
+
end
|
5
14
|
|
6
15
|
end
|