tb_core 1.3.0.beta2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/admin/core/application.js +0 -3
  3. data/app/assets/stylesheets/admin/core/application.css.scss +6 -0
  4. data/app/controllers/admin/application_controller.rb +1 -32
  5. data/app/controllers/admin/dashboard_controller.rb +1 -17
  6. data/app/controllers/admin/password_resets_controller.rb +1 -1
  7. data/app/controllers/password_resets_controller.rb +1 -1
  8. data/app/controllers/spud/application_controller.rb +3 -21
  9. data/app/helpers/admin/application_helper.rb +0 -18
  10. data/app/helpers/spud/application_helper.rb +1 -13
  11. data/app/models/spud_user_session.rb +5 -0
  12. data/app/views/admin/dashboard/index.html.erb +1 -1
  13. data/app/views/admin/users/index.html.erb +3 -17
  14. data/app/views/layouts/admin/_search.html.erb +13 -0
  15. data/app/views/layouts/admin/application.html.erb +1 -1
  16. data/config/routes.rb +0 -4
  17. data/lib/generators/spud/module_generator.rb +5 -4
  18. data/lib/generators/spud/templates/views/admin/index.html.erb +2 -16
  19. data/lib/generators/spud/templates/views/admin/show.html.erb +1 -2
  20. data/lib/spud_core/configuration.rb +2 -27
  21. data/lib/spud_core/engine.rb +1 -1
  22. data/lib/spud_core/errors.rb +4 -2
  23. data/lib/spud_core/version.rb +1 -1
  24. data/lib/tb_core/form_builder.rb +3 -4
  25. data/spec/{support/authlogic_helper.rb → authlogic_helper.rb} +0 -0
  26. data/spec/controllers/admin/application_controller_spec.rb +8 -12
  27. data/spec/controllers/admin/dashboard_controller_spec.rb +13 -81
  28. data/spec/controllers/admin/password_reset_controller_spec.rb +28 -33
  29. data/spec/controllers/admin/settings_controller_spec.rb +7 -7
  30. data/spec/controllers/admin/setup_controller_spec.rb +10 -17
  31. data/spec/controllers/admin/user_sessions_controller_spec.rb +11 -11
  32. data/spec/controllers/admin/users_controller_spec.rb +40 -65
  33. data/spec/controllers/spud/application_controller_spec.rb +5 -5
  34. data/spec/dummy/app/assets/javascripts/admin/application.js +16 -0
  35. data/spec/dummy/app/assets/javascripts/application.js +16 -13
  36. data/spec/dummy/app/assets/stylesheets/admin/application.css.scss +3 -0
  37. data/spec/dummy/app/assets/stylesheets/application.css.scss +5 -0
  38. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  39. data/spec/dummy/app/views/layouts/application.html.erb +22 -3
  40. data/spec/dummy/config/application.rb +5 -0
  41. data/spec/dummy/config/environments/production.rb +1 -1
  42. data/spec/dummy/config/environments/test.rb +1 -1
  43. data/spec/dummy/db/migrate/20141214200804_create_spud_admin_permissions.tb_core.rb +12 -0
  44. data/spec/dummy/db/migrate/20141214200805_create_spud_users.tb_core.rb +30 -0
  45. data/spec/dummy/db/migrate/20141214200806_add_time_zone_to_spud_user.tb_core.rb +7 -0
  46. data/spec/dummy/db/migrate/20141214200807_add_scope_to_spud_admin_permissions.tb_core.rb +7 -0
  47. data/spec/dummy/db/migrate/20141214200808_create_spud_user_settings.tb_core.rb +12 -0
  48. data/spec/dummy/db/migrate/20141214200809_create_spud_roles.tb_core.rb +11 -0
  49. data/spec/dummy/db/migrate/20141214200810_create_spud_permissions.tb_core.rb +11 -0
  50. data/spec/dummy/db/migrate/20141214200811_create_spud_role_permissions.tb_core.rb +12 -0
  51. data/spec/dummy/db/migrate/20141214200812_drop_spud_admin_permissions.tb_core.rb +16 -0
  52. data/spec/dummy/db/schema.rb +47 -47
  53. data/spec/factories/spud_admin_permission_factories.rb +10 -0
  54. data/spec/factories/spud_role_factories.rb +9 -0
  55. data/spec/factories/spud_user_factories.rb +31 -0
  56. data/spec/helpers/spud/admin/application_helper_spec.rb +11 -119
  57. data/spec/helpers/spud/application_helper_spec.rb +4 -59
  58. data/spec/lib/spud_core/configuration_spec.rb +1 -22
  59. data/spec/models/spud_role_spec.rb +8 -8
  60. data/spec/models/spud_user_spec.rb +8 -8
  61. data/spec/rails_helper.rb +72 -0
  62. data/spec/spec_helper.rb +78 -36
  63. metadata +93 -118
  64. data/app/controllers/sitemaps_controller.rb +0 -7
  65. data/app/views/sitemaps/show.xml.builder +0 -12
  66. data/spec/controllers/sitemap_controllers_spec.rb +0 -15
  67. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  68. data/spec/integration/admin_setup_spec.rb +0 -8
  69. data/spec/javascripts/date_picker_spec.js +0 -8
  70. data/spec/javascripts/support/jasmine.yml +0 -88
  71. data/spec/javascripts/support/jasmine_helper.rb +0 -11
  72. data/spec/views/layouts/admin/application.html.erb_spec.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71d46dd97bbbbce461720a371f68625eb450dd6b
4
- data.tar.gz: 1e7ee1ddf9176a6883a2b310d8c829b4fff33d8e
3
+ metadata.gz: 10dce243e38a7dda2ea1667da4ef47454d6c07c7
4
+ data.tar.gz: 21119a1481d42568af16b0afac0772b613b3eced
5
5
  SHA512:
6
- metadata.gz: de1a06e5fb7ca79aa5d747f299da31ddff502b1626535552d7387e5a66c07012fa2ffac2d31fbd6a7f35d2160f1fd8d772e2749568f9b908206bd42f015328d4
7
- data.tar.gz: 8b3656c0f2cc826005e5d33821b4954212efa72abac945092df36472bfccb344995593c23d92107e311ad4eed4069075272f87ba685e514556de244c83f2b293
6
+ metadata.gz: 52a4a4a753ce259fc37b70763755d83b886b366f77700f5ffbe479cb2ae91cba6b85ce02a77d3af4f4eec2dd45b1e25c037cc6c6161b5d486caffceb460b3ae6
7
+ data.tar.gz: 189b24c1e07af8ecd989bd9420e62d72976858ecb58274b5ff4db4f618a2bce452e1f5b34805df4f694613b35d15f269846c805ad884390d1c323c86565c2532
@@ -41,7 +41,4 @@ $(document).ready(function() {
41
41
 
42
42
  $('input[type=submit].btn').click(function() {$(this).button('loading');});
43
43
 
44
- $('#multisite_switcher select').change(function() {
45
- $(this).parent().submit();
46
- });
47
44
  } );
@@ -66,9 +66,15 @@ body {
66
66
  line-height: 36px;
67
67
  font-size: 15px;
68
68
  }
69
+ .application-name{
70
+ white-space: nowrap;
71
+ }
69
72
  }
70
73
 
71
74
  // Detail
75
+ .admin-search-form{
76
+ display: inline;
77
+ }
72
78
  .detail-wrapper {
73
79
  background:#fff;
74
80
  min-height:300px;
@@ -1,19 +1,9 @@
1
1
  class Admin::ApplicationController < Spud::ApplicationController
2
2
 
3
3
  before_action :require_admin_user
4
- before_action :verify_site_mode
5
4
  add_breadcrumb "Dashboard", :admin_root_path
6
5
  layout 'admin/detail'
7
- respond_to :html, :json, :xml, :js
8
- unloadable
9
-
10
- def current_admin_site
11
- if(session[:admin_site] == nil)
12
- return 0
13
- else
14
- return session[:admin_site]
15
- end
16
- end
6
+ respond_to :html, :json
17
7
 
18
8
  private
19
9
 
@@ -30,25 +20,4 @@ private
30
20
  end
31
21
  end
32
22
 
33
- def verify_site_mode
34
- if(session[:admin_site] == nil)
35
- session[:admin_site] = 0
36
- end
37
- end
38
-
39
- def multisite_caching
40
- if Spud::Core.multisite_mode_enabled
41
- @old_cache_directory = Rails.application.config.action_controller.page_cache_directory
42
- if(@old_cache_directory.blank?)
43
- @old_cache_directory = Rails.application.config.action_controller.page_cache_directory = File.join(Rails.root,'public')
44
- end
45
- if session && session[:admin_site]
46
- site_config = Spud::Core.site_config_for_id(session[:admin_site])
47
- else
48
- site_config = Spud::Core.site_config_for_host(request.host_with_port)
49
- end
50
- self.class.page_cache_directory = File.join(@old_cache_directory.to_s, site_config[:short_name].to_s.downcase)
51
- logger.debug "Cache directory set to: #{Rails.application.config.action_controller.page_cache_directory}"
52
- end
53
- end
54
23
  end
@@ -13,27 +13,11 @@ class Admin::DashboardController < Admin::ApplicationController
13
13
  @admin_applications = Spud::Core.admin_applications.select do |admin_application|
14
14
  if current_user.can_view_app?(admin_application)
15
15
  if admin_application[:badge]
16
- begin
17
- data << {:key => admin_application[:key], :badge_count => admin_application[:badge].call(current_user)}
18
- rescue Exception => e
19
- logger.error e
20
- end
16
+ data << {:key => admin_application[:key], :badge_count => admin_application[:badge].call(current_user)}
21
17
  end
22
18
  end
23
19
  end
24
20
  render :json => {:data => data}
25
21
  end
26
22
 
27
- def switch
28
- if !params[:multisite_select].blank?
29
- if Spud::Core.multisite_config.select{|p| p[:site_id].to_i == params[:multisite_select].to_i}.blank? == false
30
- session[:admin_site] = params[:multisite_select].to_i
31
- else
32
- flash[:error] = "Site does not exist."
33
- end
34
- else
35
- session[:admin_site] = 0
36
- end
37
- redirect_to(back_or_default(!request.referer.blank? ? request.referer : admin_root_path)) and return
38
- end
39
23
  end
@@ -12,7 +12,7 @@ class Admin::PasswordResetsController < Admin::ApplicationController
12
12
  @user = SpudUser.find_by_email(params[:email])
13
13
  if @user
14
14
  @user.reset_perishable_token!
15
- CoreMailer.forgot_password_notification(@user, admin_password_reset_url(@user.perishable_token)).deliver
15
+ CoreMailer.forgot_password_notification(@user, admin_password_reset_url(@user.perishable_token)).deliver_later
16
16
  flash[:notice] = "Instructions to reset your password have been emailed to you. " +
17
17
  "Please check your email."
18
18
  redirect_to admin_login_path
@@ -13,7 +13,7 @@ class PasswordResetsController < ApplicationController
13
13
  @user = SpudUser.find_by_email(params[:email])
14
14
  if @user
15
15
  @user.reset_perishable_token!
16
- CoreMailer.forgot_password_notification(@user, password_reset_url(@user.perishable_token)).deliver
16
+ CoreMailer.forgot_password_notification(@user, password_reset_url(@user.perishable_token)).deliver_later
17
17
  flash[:notice] = "Password reset instructions have been sent to your email"
18
18
  redirect_to login_path
19
19
  else
@@ -6,14 +6,11 @@ class Spud::ApplicationController < ActionController::Base
6
6
  helper_method :current_user_session, :current_user, :current_user_id
7
7
  around_filter :set_time_zone
8
8
 
9
- if Spud::Core.multisite_mode_enabled
10
- before_action :multisite_caching
11
- end
12
9
  include Spud::ApplicationHelper
13
10
  before_action :set_mailer_default_url
14
11
 
15
12
  rescue_from Spud::RequestError, :with => :handle_request_error
16
- rescue_from ActionController::UnknownFormat, ActionView::MissingTemplate, :with => :handle_unknown_format_error
13
+ rescue_from ActionController::UnknownFormat, :with => :handle_unknown_format_error
17
14
 
18
15
  def not_found
19
16
  raise Spud::NotFoundError
@@ -82,19 +79,6 @@ private
82
79
  Time.zone = old_time_zone
83
80
  end
84
81
 
85
- def multisite_caching
86
- if Spud::Core.multisite_mode_enabled
87
- @old_cache_directory = Rails.application.config.action_controller.page_cache_directory
88
- if(@old_cache_directory.blank?)
89
- @old_cache_directory = Rails.application.config.action_controller.page_cache_directory = File.join(Rails.root,'public')
90
- end
91
- site_config = Spud::Core.site_config_for_host request.host_with_port
92
-
93
- self.class.page_cache_directory = File.join(@old_cache_directory.to_s,site_config[:short_name].to_s.downcase)
94
- logger.debug "Cache directory set to: #{Rails.application.config.action_controller.page_cache_directory}"
95
- end
96
- end
97
-
98
82
  def handle_request_error(error)
99
83
  error.request_url = request.original_url
100
84
  respond_to do |format|
@@ -108,10 +92,8 @@ private
108
92
  end
109
93
 
110
94
  def handle_unknown_format_error(error)
111
- if Rails.env.production?
112
- error = Spud::NotFoundError.new()
113
- handle_request_error(error)
114
- end
95
+ error = Spud::NotFoundError.new()
96
+ handle_request_error(error)
115
97
  end
116
98
 
117
99
  end
@@ -5,24 +5,6 @@ module Admin::ApplicationHelper
5
5
  return Time.now() - timedate > 604800 ? timedate.strftime("%B %d") + ' at ' + timedate.strftime("%I:%M %p") : time_ago_in_words(timedate) + ' ago'
6
6
  end
7
7
 
8
- def current_admin_site_name
9
- site_name = Spud::Core.site_name
10
- if Spud::Core.multisite_mode_enabled && !session[:admin_site].blank?
11
- config = Spud::Core.multisite_config.select{|p| p[:site_id].to_i == session[:admin_site].to_i}
12
- site_name = config[0][:site_name] if !config.blank?
13
- end
14
- return site_name
15
- end
16
-
17
- def header_style
18
- style_str = ''
19
- if Spud::Core.multisite_mode_enabled
20
- config = Spud::Core.multisite_config.select{|p| p[:site_id].to_i == session[:admin_site].to_i}
21
- style_str = config[0][:header_style] if !config.blank? && config[0].has_key?(:header_style)
22
- end
23
- return style_str
24
- end
25
-
26
8
  def url_for_admin_dashboard_application(url)
27
9
  if Rails.configuration.relative_url_root.blank?
28
10
  return url
@@ -12,16 +12,7 @@ module Spud::ApplicationHelper
12
12
  end
13
13
 
14
14
  def current_site_name
15
- return Spud::Core.site_name if !Spud::Core.multisite_mode_enabled
16
- config = Spud::Core.site_config_for_host(request.host_with_port)
17
- return Spud::Core.site_name if config.blank?
18
-
19
- return config[:site_name]
20
- end
21
-
22
- def current_site_id
23
- config = Spud::Core.site_config_for_host(request.host_with_port)
24
- return config[:site_id] unless config.blank?
15
+ return Spud::Core.config.site_name
25
16
  end
26
17
 
27
18
  def cache_key_for_spud_collection(collection, key:'view', cache_params:[], for_user:false)
@@ -33,9 +24,6 @@ module Spud::ApplicationHelper
33
24
  if cache_params.any?
34
25
  cache_keys += cache_params.collect{ |cache_param| params[cache_param] || 'nil' }
35
26
  end
36
- if Spud::Core.multisite_mode_enabled
37
- cache_keys.unshift(current_site_id)
38
- end
39
27
  cache_keys += collection.collect(&:id)
40
28
  cache_key = cache_keys.join('/')
41
29
  if cache_key.length > 250
@@ -1,4 +1,9 @@
1
1
  class SpudUserSession < Authlogic::Session::Base
2
+
3
+ # Rails 4.2 fix. Possibly temporary?
4
+ # https://github.com/binarylogic/authlogic/issues/432#issuecomment-62506755
5
+ extend ActiveModel::Naming
6
+
2
7
  generalize_credentials_error_messages true
3
8
 
4
9
  # Dont update last_request_at timestamp on every page request
@@ -4,7 +4,7 @@
4
4
  <%= link_to url_for_admin_dashboard_application(admin_application[:url]) do %>
5
5
  <%= image_tag(admin_application[:thumbnail]) %>
6
6
  <span class="dash-icon-badge" ></span>
7
- <span class="application_name"><%= admin_application[:name] %></span>
7
+ <span class="application-name"><%= admin_application[:name] %></span>
8
8
  <% end %>
9
9
  </div>
10
10
  <% end %>
@@ -1,21 +1,7 @@
1
1
  <%= content_for :data_controls do %>
2
- <%= form_tag admin_users_path, :method => :get, :class => 'form-inline' do %>
3
- <div class="form-group">
4
- <div class="input-group">
5
- <div class="input-group-addon"><span class="glyphicon glyphicon-search"></span></div>
6
- <%= search_field_tag :search, params[:search], :placeholder => 'Search', :class => 'form-control' %>
7
- <% if params[:search] %>
8
- <div class="input-group-addon">
9
- <%= link_to raw('<span class="glyphicon glyphicon-remove"></span>'), admin_users_path %>
10
- </div>
11
- <% end %>
12
- </div>
13
- </div>
14
- <div class="form-group">
15
- <%= link_to 'Roles', admin_roles_path, :class => 'btn btn-default admin-role-btn' %>
16
- <%= link_to "New User", new_admin_user_path, :class => "btn btn-primary admin-user-add-btn", :title => "New User" %>
17
- </div>
18
- <% end %>
2
+ <%= render :partial => '/layouts/admin/search', :locals => {:search_path => admin_users_path} %>
3
+ <%= link_to 'Roles', admin_roles_path, :class => 'btn btn-default admin-role-btn' %>
4
+ <%= link_to "New User", new_admin_user_path, :class => "btn btn-primary admin-user-add-btn", :title => "New User" %>
19
5
  <% end %>
20
6
 
21
7
  <%= content_for :detail do %>
@@ -0,0 +1,13 @@
1
+ <%= form_tag search_path, :method => :get, :class => 'form-inline admin-search-form' do %>
2
+ <div class="form-group">
3
+ <div class="input-group">
4
+ <div class="input-group-addon"><span class="glyphicon glyphicon-search"></span></div>
5
+ <%= search_field_tag :search, params[:search], :placeholder => 'Search', :class => 'form-control' %>
6
+ <% if params[:search] %>
7
+ <div class="input-group-addon">
8
+ <%= link_to raw('<span class="glyphicon glyphicon-remove"></span>'), search_path %>
9
+ </div>
10
+ <% end %>
11
+ </div>
12
+ </div>
13
+ <% end %>
@@ -15,7 +15,7 @@
15
15
  <p><strong>Notice:</strong> This is a staging version of your website. To update your live website, please <%= link_to 'log in to production.', "http://#{Spud::Core.production_alert_domain}/admin" %></p>
16
16
  </div>
17
17
  <% end %>
18
- <div id="header" style="<%=header_style%>">
18
+ <div id="header">
19
19
  <div class="container">
20
20
  <%= link_to '/' do %>
21
21
  <h1><%= Spud::Core.config.site_name %></h1>
data/config/routes.rb CHANGED
@@ -15,13 +15,9 @@ Rails.application.routes.draw do
15
15
  resources :users, :controller
16
16
  resources :roles
17
17
 
18
- match 'switch' => "dashboard#switch", :via => [:get, :post]
19
-
20
18
  get 'setup' => 'setup#new'
21
19
  post 'setup' => 'setup#create'
22
20
  end
23
-
24
- resource :sitemap, :only => [:show]
25
21
 
26
22
  # Non-admin login paths
27
23
  get 'login' => 'user_sessions#new', :as => 'login'
@@ -10,10 +10,10 @@ class Spud::ModuleGenerator < ::Rails::Generators::Base
10
10
  def create_module
11
11
  template "admin_controller.rb.erb", "app/controllers/admin/#{module_name_formatted}_controller.rb"
12
12
  template "controller.rb.erb", "app/controllers/#{module_name_formatted}_controller.rb"
13
-
14
13
  template "assets/module.js.erb", "app/assets/javascripts/#{module_name_formatted}.js"
15
14
  template "assets/admin/module.js.erb", "app/assets/javascripts/admin/#{module_name_formatted}.js"
16
- create_file "app/assets/stylesheets/admin/#{module_name_formatted}.css.scss", "// Place #{module_name} module styles here\n\n"
15
+ create_file "app/assets/stylesheets/admin/#{module_name_formatted}.css.scss", "// Place #{module_name} admin styles here\n\n"
16
+ create_file "app/assets/stylesheets/#{module_name_formatted}.css.scss", "// Place #{module_name} styles here\n\n"
17
17
  template "views/admin/index.html.erb", "app/views/admin/#{module_name_formatted}/index.html.erb"
18
18
  template "views/admin/show.html.erb", "app/views/admin/#{module_name_formatted}/show.html.erb"
19
19
  template "views/admin/new.html.erb", "app/views/admin/#{module_name_formatted}/new.html.erb"
@@ -23,8 +23,9 @@ class Spud::ModuleGenerator < ::Rails::Generators::Base
23
23
  template "views/frontend/show.html.erb", "app/views/#{module_name_formatted}/show.html.erb"
24
24
  environment("Spud::Core.config.admin_applications += [{:name => '#{module_name_formatted.humanize.titlecase}', :thumbnail => \"admin/module_icon.png\", :url => \"/admin/#{module_name_formatted}\"}]")
25
25
  create_routes
26
- invoke "model", [module_name_formatted.singularize] + attributes
27
-
26
+ Rails::Generators.invoke "model", [module_name_formatted.singularize] + attributes, :behavior => behavior
27
+ Rails::Generators.invoke 'helper', [module_name], :behavior => behavior
28
+ Rails::Generators.invoke 'helper', ["Admin/#{module_name}"], :behavior => behavior
28
29
  if self.behavior == :invoke
29
30
  create_model_scopes()
30
31
  end
@@ -1,20 +1,6 @@
1
1
  <%% content_for :data_controls do %>
2
- <%%= form_tag admin_<%= module_name_formatted %>_path, :method => :get, :class => 'form-inline' do %>
3
- <div class="form-group">
4
- <div class="input-group">
5
- <div class="input-group-addon"><span class="glyphicon glyphicon-search"></span></div>
6
- <%%= text_field_tag 'search', params[:search], :placeholder => 'Search', :class => 'form-control' %>
7
- <%% if params[:search] %>
8
- <div class="input-group-addon">
9
- <%%= link_to raw('<span class="glyphicon glyphicon-remove"></span>'), admin_<%= module_name_formatted %>_path %>
10
- </div>
11
- <%% end %>
12
- </div>
13
- </div>
14
- <div class="form-group">
15
- <%%= link_to "New <%=module_name_formatted.singularize.humanize.titlecase%>", new_admin_<%=module_name_formatted.singularize%>_path, :class => "btn btn-primary", :title => "New <%=module_name_formatted.singularize.humanize.titlecase%>" %>
16
- </div>
17
- <%% end %>
2
+ <%%= render :partial => '/layouts/admin/search', :locals => {:search_path => admin_<%= module_name_formatted %>_path } %>
3
+ <%%= link_to "New <%=module_name_formatted.singularize.humanize.titlecase%>", new_admin_<%=module_name_formatted.singularize%>_path, :class => "btn btn-primary", :title => "New <%=module_name_formatted.singularize.humanize.titlecase%>" %>
18
4
  <%% end %>
19
5
 
20
6
  <%% content_for :detail do %>
@@ -1,5 +1,6 @@
1
1
  <%% content_for :data_controls do %>
2
2
  <%%= link_to 'Edit', edit_admin_<%=module_name_formatted.singularize%>_path(@<%=module_name_formatted.singularize%>), :class => 'btn btn-default' %>
3
+ <%%= link_to "Back", admin_<%= module_name_formatted %>_path, :class => "btn btn-default" %>
3
4
  <%% end %>
4
5
 
5
6
  <dl class="dl-horizontal">
@@ -9,8 +10,6 @@
9
10
  <%- end -%>
10
11
  </dl>
11
12
 
12
- <%%= link_to "Back", admin_<%= module_name_formatted %>_path, :class => "btn btn-default" %>
13
-
14
13
  <script>
15
14
  $(document).ready(app.admin.<%= module_name_formatted %>.show);
16
15
  </script>
@@ -1,18 +1,15 @@
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,
5
- :from_address, :site_id, :short_name, :javascripts, :stylesheets, :admin_javascripts, :admin_stylesheets,
4
+ config_accessor :site_name, :admin_applications, :from_address, :site_id, :short_name,
5
+ :javascripts, :stylesheets, :admin_javascripts, :admin_stylesheets,
6
6
  :permissions, :production_alert_domain, :use_email_as_login
7
7
  self.admin_applications = []
8
8
  self.site_name = "Company Name"
9
9
  self.site_id = 0
10
10
  self.short_name = 'default'
11
- self.sitemap_urls = []
12
11
  self.javascripts = []
13
12
  self.stylesheets = []
14
- self.multisite_mode_enabled = false
15
- self.multisite_config = []
16
13
  self.from_address = "no-reply@companyname.com"
17
14
  self.permissions = []
18
15
  self.admin_javascripts = ['admin/core/application', 'admin/application']
@@ -20,28 +17,6 @@ module Spud
20
17
  self.production_alert_domain = nil
21
18
  self.use_email_as_login = false
22
19
 
23
- def self.site_config_for_host(host)
24
- configs = Spud::Core.multisite_config.select{|p| p[:hosts].include?(host)}
25
- if configs.blank?
26
- return default_site_config
27
- else
28
- return configs[0]
29
- end
30
- end
31
-
32
- def self.site_config_for_id(id)
33
- if(id == Spud::Core.config.site_id)
34
- return self.default_site_config
35
- else
36
- matches = Spud::Core.config.multisite_config.select{ |site| site[:site_id] == id }
37
- return matches[0] if matches.any?
38
- end
39
- end
40
-
41
- def self.default_site_config
42
- return {:site_id => Spud::Core.config.site_id, :site_name => Spud::Core.config.site_name, :short_name => Spud::Core.config.short_name}
43
- end
44
-
45
20
  def self.append_admin_javascripts(*args)
46
21
  if args[0].class == Array
47
22
  Spud::Core.config.admin_javascripts += args[0]
@@ -1,3 +1,4 @@
1
+ require 'responders'
1
2
  require 'jquery-rails'
2
3
  require 'authlogic'
3
4
  require 'bootstrap-sass'
@@ -21,7 +22,6 @@ module Spud
21
22
 
22
23
  engine_name :tb_core
23
24
  config.autoload_paths << "#{root}/lib"
24
- #config.autoload_paths << File.expand_path("../lib", __FILE__)
25
25
 
26
26
  initializer 'tb_core.controller_overrides' do |config|
27
27
  ActionController::Base.class_eval do
@@ -14,7 +14,8 @@ class Spud::AccessDeniedError < Spud::RequestError
14
14
  @template = opts[:template]
15
15
  @code = 403
16
16
  @title = "Access Denied"
17
- super("You are not authorized to view the requested #{item.downcase}.")
17
+ message = opts[:message] || "You are not authorized to view the requested #{item.downcase}."
18
+ super(message)
18
19
  end
19
20
  end
20
21
 
@@ -24,6 +25,7 @@ class Spud::NotFoundError < Spud::RequestError
24
25
  @template = opts[:template]
25
26
  @code = 404
26
27
  @title = "Not Found"
27
- super("The #{item.downcase} you were looking for could not be found.")
28
+ message = opts[:message] || "The #{item.downcase} you were looking for could not be found."
29
+ super(message)
28
30
  end
29
31
  end
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "1.3.0.beta2"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
@@ -31,10 +31,9 @@ class TbCore::FormBuilder < ActionView::Helpers::FormBuilder
31
31
  if block_given?
32
32
  concat(yield(attribute))
33
33
  else
34
- concat send(input_type, attribute, objectify_options(
35
- :placeholder => @object.class.human_attribute_name(attribute),
36
- :class => 'form-control'
37
- ))
34
+ options[:class] ||= 'form-control'
35
+ options[:placeholder] ||= @object.class.human_attribute_name(attribute)
36
+ concat send(input_type, attribute, objectify_options(options))
38
37
  end
39
38
  error_message = @object.errors[attribute].first
40
39
  if error_message
@@ -1,6 +1,6 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::ApplicationController do
3
+ RSpec.describe Admin::ApplicationController, :type => :controller do
4
4
 
5
5
  before :each do
6
6
  activate_authlogic
@@ -9,7 +9,7 @@ describe Admin::ApplicationController do
9
9
  @session = SpudUserSession.create(@user)
10
10
  end
11
11
 
12
- describe :require_user do
12
+ describe 'require_user' do
13
13
  controller(Admin::ApplicationController) do
14
14
  def index
15
15
  render :nothing => true
@@ -18,8 +18,7 @@ describe Admin::ApplicationController do
18
18
  it "should respond successfully if the current user is a super admin" do
19
19
  @user.update_attribute(:super_admin, true)
20
20
  get :index
21
-
22
- response.should be_success
21
+ expect(response).to be_success
23
22
  end
24
23
 
25
24
  it "should respond successfully if the current user has admin permissions" do
@@ -28,15 +27,13 @@ describe Admin::ApplicationController do
28
27
  @user.role = @role
29
28
  @user.save()
30
29
  get :index
31
-
32
- response.should be_success
30
+ expect(response).to be_success
33
31
  end
34
32
 
35
33
  it "should redirect to the login if the current user is not logged in" do
36
34
  @session.destroy
37
35
  get :index
38
-
39
- response.should redirect_to(admin_login_path)
36
+ expect(response).to redirect_to(admin_login_path(:return_to => '/admin/application'))
40
37
  end
41
38
 
42
39
  it "should redirect to the root for a user without administrative priviledges" do
@@ -44,9 +41,8 @@ describe Admin::ApplicationController do
44
41
  @user.role = nil
45
42
  @user.save
46
43
  get :index
47
-
48
- response.code.should eq("403")
49
- response.should render_template('layouts/admin/error_page')
44
+ expect(response.code).to eq('403')
45
+ expect(response).to render_template('layouts/admin/error_page')
50
46
  end
51
47
 
52
48
  end