tb_core 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTVkMDA5M2UwNGE0Mjc5Y2QyZjFkYWU3MjA4MGEzMzBhYWVmMmI0OA==
4
+ YzM4ZjU3ZmRjOGE0N2M1MDAzYzdmNjI0MmRkM2FmMWQ3NjQ5YTAzMQ==
5
5
  data.tar.gz: !binary |-
6
- N2E2MTRhMmIxNzVmZTkzMTg5MTBmOTBmNTc2ZTdhNTg1MzMzNzMwZg==
6
+ Yzc5M2QwYmMzNDM1ZWU1YWI5NDljNjg4MGE3NzNlZTNiM2M3MzQ5NQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- M2UzYjI1NGUxZWNlNTcyNGM2MjkzYzBmZTZmNjBlNWM2Mzc0NzUyOTU4OGY4
10
- YjU1YjMwYjQzN2FiOGMwMmM1OGEyZDc4ZGYxMjJmOGRhOWFiMWU4NDliY2Qx
11
- YzNlMTY0ZThmMzMyYWFkZTQzY2YyODM1MWQwZDk1ODFjOWFmNWU=
9
+ NDMxMzMwZmVlMzg1OTBjMDdiYjNlNGQ2OGYxOWVjYWY1Mzc2ZTRlMjFjN2Y4
10
+ MTA5MDkyMDFlYjU2ZGZjNWJhNzBlMDc0OTJlYTA5YmY5MzhjZDliMjQxOGM4
11
+ Njk2Y2JjNDEwNWNmYjgzNTg5MjViMDJiNmU3ZjBhN2NiZTViYzk=
12
12
  data.tar.gz: !binary |-
13
- MTMwMTc3NzYzZDI5YmJhMDMyNWQ2ZTM2MTExMzg4Y2YxNzMwZmZkMWQ1OTE1
14
- MjNkNTc5MDBkODBlNWMyZjY5M2IyNGRmMGU5ODExNDZkNTlhODhkODlkN2M2
15
- NGRmNGQyMjc4MGQ4NDQzZDczZDYxMWY5NjlhYjdiYzgzMDc1Njc=
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
- bundle exec rake tb_core:install:migrations
17
- rake db:migrate
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
@@ -1,5 +1,5 @@
1
1
  <%
2
- @page_thumbnail = "spud/admin/users_thumb.png"
2
+ @page_thumbnail = "admin/users_thumb.png"
3
3
  @page_name = "First Time Setup"
4
4
  %>
5
5
 
@@ -9,7 +9,7 @@
9
9
  </head>
10
10
  <body>
11
11
  <div id="header" style="<%=header_style%>">
12
- <%= link_to root_path do %>
12
+ <%= link_to '/' do %>
13
13
  <h1><%= Spud::Core.config.site_name %></h1>
14
14
  <% end %>
15
15
  <% if current_user %>
@@ -0,0 +1,6 @@
1
+ <%= content_for :body do %>
2
+ <h1>404: Not Found!</h1>
3
+ <p>The <%= @exception.item %> you requested could not be found.</p>
4
+ <p>Requested URL: <%= @exception.request_url %></p>
5
+ <% end %>
6
+ <%= render :template => 'layouts/application' %>
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)}
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "1.1.4"
3
+ VERSION = "1.1.5"
4
4
  end
5
5
  end
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe Admin::ApplicationController do
4
4
 
5
-
6
5
  before :each do
7
6
  activate_authlogic
8
7
  @user = FactoryGirl.create(:spud_user)
@@ -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