tb_core 1.3.0.beta2 → 1.3.0

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.
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
@@ -1,15 +1,18 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
9
- //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
12
- //
13
1
  //= require jquery
14
2
  //= require jquery_ujs
15
- //= require_tree .
3
+ //= require tb_core
4
+ //= require bootstrap-sprockets
5
+ //= require_self
6
+ //= require_directory .
7
+
8
+ (function(){
9
+
10
+ window.app = {
11
+ init: function(){
12
+ // global initializer
13
+ }
14
+ };
15
+
16
+ $(document).ready(app.init);
17
+
18
+ })();
@@ -0,0 +1,3 @@
1
+ //= require_self
2
+ //= require_tree
3
+
@@ -0,0 +1,5 @@
1
+ //= require_self
2
+ //= require_directory .
3
+
4
+ @import "bootstrap-sprockets";
5
+ @import "bootstrap";
@@ -1,3 +1,3 @@
1
- class ApplicationController < ActionController::Base
1
+ class ApplicationController < Spud::ApplicationController
2
2
  protect_from_forgery
3
3
  end
@@ -1,14 +1,33 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="viewport" content="width=device-width"/>
8
+ <%= tb_page_title() %>
9
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
10
  <%= javascript_include_tag "application" %>
7
11
  <%= csrf_meta_tags %>
12
+ <%= yield :head %>
8
13
  </head>
9
14
  <body>
15
+ <div class="container">
10
16
 
11
- <%= yield %>
17
+ <% if flash[:notice] %>
18
+ <div class="alert alert-info alert-dismissible">
19
+ <%= flash[:notice] %> <a href="#" class="flash-remove">X</a>
20
+ <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
21
+ </div>
22
+ <% elsif flash[:error] %>
23
+ <div class="alert alert-danger alert-dismissible">
24
+ <%= flash[:error] %> <a href="#" class="flash-remove">X</a>
25
+ <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
26
+ </div>
27
+ <% end %>
12
28
 
29
+ <%= content_for?(:body) ? yield(:body) : yield %>
30
+
31
+ </div>
13
32
  </body>
14
33
  </html>
@@ -7,6 +7,11 @@ require "tb_core"
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
10
+ Spud::Core.configure do |config|
11
+ config.site_name = "Dummy"
12
+ config.from_address = "no-reply@dummy.com"
13
+ end
14
+
10
15
  # Settings in config/environments/* take precedence over those specified here.
11
16
  # Application configuration should go into files in config/initializers
12
17
  # -- all .rb files in that directory are automatically loaded.
@@ -9,7 +9,7 @@ Dummy::Application.configure do
9
9
  config.action_controller.perform_caching = true
10
10
 
11
11
  # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
12
+ config.serve_static_files = false
13
13
 
14
14
  # Compress JavaScripts and CSS
15
15
  config.assets.compress = true
@@ -8,7 +8,7 @@ Dummy::Application.configure do
8
8
  config.cache_classes = true
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
11
+ config.serve_static_files = true
12
12
  config.static_cache_control = "public, max-age=3600"
13
13
 
14
14
  # Deprecated
@@ -0,0 +1,12 @@
1
+ # This migration comes from tb_core (originally 20111214161011)
2
+ class CreateSpudAdminPermissions < ActiveRecord::Migration
3
+ def change
4
+ create_table :spud_admin_permissions do |t|
5
+ t.integer :user_id
6
+ t.string :name
7
+ t.boolean :access
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ # This migration comes from tb_core (originally 20111214161146)
2
+ class CreateSpudUsers < ActiveRecord::Migration
3
+ def change
4
+ create_table :spud_users do |t|
5
+
6
+ t.string :first_name
7
+ t.string :last_name
8
+ t.boolean :super_admin
9
+ t.string :login, :null => false # optional, you can use email instead, or both
10
+ t.string :email, :null => false # optional, you can use login instead, or both
11
+ t.string :crypted_password, :null => false # optional, see below
12
+ t.string :password_salt, :null => false # optional, but highly recommended
13
+ t.string :persistence_token, :null => false # required
14
+ t.string :single_access_token, :null => false # optional, see Authlogic::Session::Params
15
+ t.string :perishable_token, :null => false # optional, see Authlogic::Session::Perishability
16
+
17
+ # Magic columns, just like ActiveRecord's created_at and updated_at. These are automatically maintained by Authlogic if they are present.
18
+ t.integer :login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
19
+ t.integer :failed_login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
20
+ t.datetime :last_request_at # optional, see Authlogic::Session::MagicColumns
21
+ t.datetime :current_login_at # optional, see Authlogic::Session::MagicColumns
22
+ t.datetime :last_login_at # optional, see Authlogic::Session::MagicColumns
23
+ t.string :current_login_ip # optional, see Authlogic::Session::MagicColumns
24
+ t.string :last_login_ip # optional, see Authlogic::Session::MagicColumns
25
+ t.timestamps
26
+ end
27
+ add_index :spud_users,:login
28
+ add_index :spud_users,:email
29
+ end
30
+ end
@@ -0,0 +1,7 @@
1
+ # This migration comes from tb_core (originally 20120327124229)
2
+ class AddTimeZoneToSpudUser < ActiveRecord::Migration
3
+ def change
4
+ add_column :spud_users, :time_zone, :string
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # This migration comes from tb_core (originally 20120328235431)
2
+ class AddScopeToSpudAdminPermissions < ActiveRecord::Migration
3
+ def change
4
+ add_column :spud_admin_permissions, :scope, :string
5
+
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # This migration comes from tb_core (originally 20120329174000)
2
+ class CreateSpudUserSettings < ActiveRecord::Migration
3
+ def change
4
+ create_table :spud_user_settings do |t|
5
+ t.integer :spud_user_id
6
+ t.string :key
7
+ t.string :value
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ # This migration comes from tb_core (originally 20130620143010)
2
+ class CreateSpudRoles < ActiveRecord::Migration
3
+ def change
4
+ create_table :spud_roles do |t|
5
+ t.string :name
6
+ t.timestamps
7
+ end
8
+ add_column :spud_users, :spud_role_id, :integer
9
+ add_index :spud_users, :spud_role_id
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # This migration comes from tb_core (originally 20130620143941)
2
+ class CreateSpudPermissions < ActiveRecord::Migration
3
+ def change
4
+ create_table :spud_permissions do |t|
5
+ t.string :name, :null => false
6
+ t.string :tag, :null => false
7
+ t.timestamps
8
+ end
9
+ add_index :spud_permissions, :tag, :unique => true
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ # This migration comes from tb_core (originally 20130620151132)
2
+ class CreateSpudRolePermissions < ActiveRecord::Migration
3
+ def change
4
+ create_table :spud_role_permissions do |t|
5
+ t.integer :spud_role_id, :null => false
6
+ t.string :spud_permission_tag, :null => false
7
+ t.timestamps
8
+ end
9
+ add_index :spud_role_permissions, :spud_role_id
10
+ add_index :spud_role_permissions, :spud_permission_tag
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ # This migration comes from tb_core (originally 20130620163144)
2
+ class DropSpudAdminPermissions < ActiveRecord::Migration
3
+ def up
4
+ drop_table :spud_admin_permissions
5
+ end
6
+
7
+ def down
8
+ create_table :spud_admin_permissions do |t|
9
+ t.integer :user_id
10
+ t.string :name
11
+ t.boolean :access
12
+ t.string :scope
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -9,69 +9,69 @@
9
9
  # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
10
  # you'll amass, the slower it'll run and the greater likelihood for issues).
11
11
  #
12
- # It's strongly recommended to check this file into your version control system.
12
+ # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20130620163144) do
14
+ ActiveRecord::Schema.define(version: 20141214200812) do
15
15
 
16
- create_table "spud_permissions", :force => true do |t|
17
- t.string "name", :null => false
18
- t.string "tag", :null => false
19
- t.datetime "created_at", :null => false
20
- t.datetime "updated_at", :null => false
16
+ create_table "spud_permissions", force: true do |t|
17
+ t.string "name", limit: 255, null: false
18
+ t.string "tag", limit: 255, null: false
19
+ t.datetime "created_at"
20
+ t.datetime "updated_at"
21
21
  end
22
22
 
23
- add_index "spud_permissions", ["tag"], :name => "index_spud_permissions_on_tag", :unique => true
23
+ add_index "spud_permissions", ["tag"], name: "index_spud_permissions_on_tag", unique: true, using: :btree
24
24
 
25
- create_table "spud_role_permissions", :force => true do |t|
26
- t.integer "spud_role_id", :null => false
27
- t.string "spud_permission_tag", :null => false
28
- t.datetime "created_at", :null => false
29
- t.datetime "updated_at", :null => false
25
+ create_table "spud_role_permissions", force: true do |t|
26
+ t.integer "spud_role_id", limit: 4, null: false
27
+ t.string "spud_permission_tag", limit: 255, null: false
28
+ t.datetime "created_at"
29
+ t.datetime "updated_at"
30
30
  end
31
31
 
32
- add_index "spud_role_permissions", ["spud_permission_tag"], :name => "index_spud_role_permissions_on_spud_permission_tag"
33
- add_index "spud_role_permissions", ["spud_role_id"], :name => "index_spud_role_permissions_on_spud_role_id"
32
+ add_index "spud_role_permissions", ["spud_permission_tag"], name: "index_spud_role_permissions_on_spud_permission_tag", using: :btree
33
+ add_index "spud_role_permissions", ["spud_role_id"], name: "index_spud_role_permissions_on_spud_role_id", using: :btree
34
34
 
35
- create_table "spud_roles", :force => true do |t|
36
- t.string "name"
37
- t.datetime "created_at", :null => false
38
- t.datetime "updated_at", :null => false
35
+ create_table "spud_roles", force: true do |t|
36
+ t.string "name", limit: 255
37
+ t.datetime "created_at"
38
+ t.datetime "updated_at"
39
39
  end
40
40
 
41
- create_table "spud_user_settings", :force => true do |t|
42
- t.integer "spud_user_id"
43
- t.string "key"
44
- t.string "value"
45
- t.datetime "created_at", :null => false
46
- t.datetime "updated_at", :null => false
41
+ create_table "spud_user_settings", force: true do |t|
42
+ t.integer "spud_user_id", limit: 4
43
+ t.string "key", limit: 255
44
+ t.string "value", limit: 255
45
+ t.datetime "created_at"
46
+ t.datetime "updated_at"
47
47
  end
48
48
 
49
- create_table "spud_users", :force => true do |t|
50
- t.string "first_name"
51
- t.string "last_name"
52
- t.boolean "super_admin"
53
- t.string "login", :null => false
54
- t.string "email", :null => false
55
- t.string "crypted_password", :null => false
56
- t.string "password_salt", :null => false
57
- t.string "persistence_token", :null => false
58
- t.string "single_access_token", :null => false
59
- t.string "perishable_token", :null => false
60
- t.integer "login_count", :default => 0, :null => false
61
- t.integer "failed_login_count", :default => 0, :null => false
49
+ create_table "spud_users", force: true do |t|
50
+ t.string "first_name", limit: 255
51
+ t.string "last_name", limit: 255
52
+ t.boolean "super_admin", limit: 1
53
+ t.string "login", limit: 255, null: false
54
+ t.string "email", limit: 255, null: false
55
+ t.string "crypted_password", limit: 255, null: false
56
+ t.string "password_salt", limit: 255, null: false
57
+ t.string "persistence_token", limit: 255, null: false
58
+ t.string "single_access_token", limit: 255, null: false
59
+ t.string "perishable_token", limit: 255, null: false
60
+ t.integer "login_count", limit: 4, default: 0, null: false
61
+ t.integer "failed_login_count", limit: 4, default: 0, null: false
62
62
  t.datetime "last_request_at"
63
63
  t.datetime "current_login_at"
64
64
  t.datetime "last_login_at"
65
- t.string "current_login_ip"
66
- t.string "last_login_ip"
67
- t.datetime "created_at", :null => false
68
- t.datetime "updated_at", :null => false
69
- t.string "time_zone"
70
- t.integer "spud_role_id"
65
+ t.string "current_login_ip", limit: 255
66
+ t.string "last_login_ip", limit: 255
67
+ t.datetime "created_at"
68
+ t.datetime "updated_at"
69
+ t.string "time_zone", limit: 255
70
+ t.integer "spud_role_id", limit: 4
71
71
  end
72
72
 
73
- add_index "spud_users", ["email"], :name => "index_spud_users_on_email"
74
- add_index "spud_users", ["login"], :name => "index_spud_users_on_login"
75
- add_index "spud_users", ["spud_role_id"], :name => "index_spud_users_on_spud_role_id"
73
+ add_index "spud_users", ["email"], name: "index_spud_users_on_email", using: :btree
74
+ add_index "spud_users", ["login"], name: "index_spud_users_on_login", using: :btree
75
+ add_index "spud_users", ["spud_role_id"], name: "index_spud_users_on_spud_role_id", using: :btree
76
76
 
77
77
  end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ sequence :permission_name do |n|
3
+ "app#{n}"
4
+ end
5
+
6
+ factory :spud_admin_permission do
7
+ name { FactoryGirl.generate(:permission_name) }
8
+ access true
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ sequence :name do |n|
3
+ "SomeRole#{n}"
4
+ end
5
+
6
+ factory :spud_role do
7
+ name { FactoryGirl.generate(:name) }
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ FactoryGirl.define do
2
+ sequence :first_name do |n|
3
+ "John#{n}"
4
+ end
5
+
6
+ sequence :last_name do |n|
7
+ "Doe#{n}"
8
+ end
9
+
10
+ sequence :login do |n|
11
+ "john#{n}doe#{n}"
12
+ end
13
+
14
+ sequence :email do |n|
15
+ "john#{n}doe#{n}@email.com"
16
+ end
17
+
18
+ sequence :single_access_token do |n|
19
+ "k3cF#{n}"
20
+ end
21
+
22
+ factory :spud_user do
23
+ first_name { FactoryGirl.generate(:first_name) }
24
+ last_name { FactoryGirl.generate(:last_name) }
25
+ login { FactoryGirl.generate(:login) }
26
+ email { FactoryGirl.generate(:email) }
27
+ password "password"
28
+ password_confirmation "password"
29
+ single_access_token { FactoryGirl.generate(:single_access_token) }
30
+ end
31
+ end
@@ -1,150 +1,42 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Admin::ApplicationHelper do
4
- describe :timestamp do
3
+ describe Admin::ApplicationHelper, :type => :helper do
4
+ describe '#timestamp' do
5
5
  it "should return 'Never' if a timedate is not given" do
6
- timestamp.should == 'Never'
6
+ expect(timestamp).to eq('Never')
7
7
  end
8
8
 
9
9
  it "should reutrn 'x ago' when the supplied timestamp is less than a week ago" do
10
- timestamp(6.days.ago).should match('.*? ago')
10
+ expect(timestamp(6.days.ago)).to match('.*? ago')
11
11
  end
12
12
 
13
13
  it "should not return 'x at x' when the timestamp is less than a week ago" do
14
- timestamp(5.minutes.ago).should_not match(/.*? at .*/)
14
+ expect(timestamp(5.minutes.ago)).to_not match(/.*? at .*/)
15
15
  end
16
16
 
17
17
  it "should return 'x at x' when the timestamp is more than a week ago" do
18
- timestamp(7.days.ago).should match(/.*? at .*/)
18
+ expect(timestamp(7.days.ago)).to match(/.*? at .*/)
19
19
  end
20
20
 
21
21
  it "should not reutrn 'x ago' when the supplied timestamp is more than a week ago" do
22
- timestamp(8.days.ago).should_not match('.*? ago')
22
+ expect(timestamp(8.days.ago)).to_not match('.*? ago')
23
23
  end
24
24
 
25
25
  end
26
26
 
27
- describe :current_admin_site_name do
28
- let(:core_site_name) { "Spud" }
29
- let(:multi_site_name) { "Spud2" }
30
- before(:each) do
31
- Spud::Core.stubs(:site_name).returns(core_site_name)
32
- end
33
-
34
- context "with multisite mode enabled" do
35
- before(:each) do
36
- Spud::Core.stubs(:multisite_mode_enabled).returns(true)
37
- end
38
-
39
- context "with a site selected" do
40
- before(:each) do
41
- controller.stubs(:session).returns({:admin_site => 1})
42
- end
43
-
44
- it "should return the spud core site name if the selected site's name is not configured" do
45
- Spud::Core.stubs(:multisite_config).returns([{:site_id => 2, :site_name => multi_site_name}])
46
- helper.current_admin_site_name.should == core_site_name
47
- end
48
-
49
- it "should return the selected site name if the select site's name is configured" do
50
- Spud::Core.stubs(:multisite_config).returns([{:site_id => 1, :site_name => multi_site_name}])
51
- helper.current_admin_site_name.should == multi_site_name
52
- end
53
- end
54
-
55
- context "without a site selected" do
56
- before(:each) do
57
- controller.stubs(:session).returns({:admin_site => nil})
58
- end
59
-
60
- it "should return the core's site name" do
61
- helper.current_admin_site_name.should == core_site_name
62
- end
63
- end
64
- end
65
-
66
- context "with multisite mode disabled" do
67
- before(:each) do
68
- Spud::Core.stubs(:multisite_mode_enabled).returns(false)
69
- end
70
-
71
- it "should return the core's site name" do
72
- helper.current_admin_site_name.should == core_site_name
73
- end
74
- end
75
- end
76
-
77
- describe :header_style do
78
- let(:style_string) { 'Big' }
79
-
80
- context "with multisite mode enabled" do
81
- before(:each) do
82
- Spud::Core.stubs(:multisite_mode_enabled).returns(true)
83
- end
84
-
85
- context "and an admin site is selected" do
86
- before(:each) do
87
- controller.stubs(:session).returns({:admin_site => 1})
88
- end
89
-
90
- it "should return a style string if the site is configured" do
91
- Spud::Core.stubs(:multisite_config).returns([{:site_id => 1, :header_style => style_string}])
92
- helper.header_style.should == style_string
93
- end
94
-
95
- it "should return an empty string if the site is not configured" do
96
- Spud::Core.stubs(:multisite_config).returns([])
97
- helper.header_style.should == ''
98
- end
99
- end
100
-
101
- context "and an admin site is not selected" do
102
- before(:each) do
103
- controller.stubs(:session).returns({:admin_site => nil})
104
- end
105
-
106
- it "should return an empty string" do
107
- helper.header_style.should == ''
108
- end
109
- end
110
- end
111
-
112
- context "with multisite mode disabled" do
113
- before(:each) do
114
- Spud::Core.stubs(:multisite_mode_enabled).returns(false)
115
- end
116
-
117
- it "should return an empty string" do
118
- helper.header_style.should == ''
119
- end
120
- end
121
- end
122
-
123
- describe :tb_form_errors do
27
+ describe '#tb_form_errors' do
124
28
  before(:each) do
125
29
  @user = FactoryGirl.create(:spud_user)
126
30
  end
127
31
 
128
32
  it "should return blank when no errors exist" do
129
- helper.tb_form_errors(@user).should == ''
130
- end
131
-
132
- it "should display 1 error when the subject has 2 errors" do
133
- @user.errors[:base] << "error 1"
134
- helper.tb_form_errors(@user).should include("1 error")
135
- end
136
-
137
- (1..3).each do |error_count|
138
- it "should display #{error_count} errors when the subject has #{error_count} errors" do
139
- error_count.times {|x| @user.errors[:base] << "error #{x}" }
140
- helper.tb_form_errors(@user).should include("#{@user.errors[:base].size} error")
141
- end
33
+ expect(helper.tb_form_errors(@user)).to be_blank
142
34
  end
143
35
 
144
36
  it "should display the error" do
145
37
  error = "You're invalid"
146
38
  @user.errors[:base] << error
147
- helper.tb_form_errors(@user).should include(error)
39
+ expect(helper.tb_form_errors(@user)).to include(error)
148
40
  end
149
41
  end
150
42
  end
@@ -1,66 +1,11 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe Spud::ApplicationHelper do
4
- before :each do
3
+ describe Spud::ApplicationHelper, :type => :helper do
4
+
5
+ before :each do
5
6
  activate_authlogic
6
7
  @user = FactoryGirl.create(:spud_user)
7
8
  @session = SpudUserSession.create(@user)
8
9
  end
9
10
 
10
- describe :current_site_name do
11
-
12
- it "should return config site name if multisite is disabled" do
13
- Spud::Core.configure do |config|
14
- config.multisite_mode_enabled = false
15
- config.site_name = "Test Site"
16
- config.multisite_config = []
17
- end
18
- helper.current_site_name.should == 'Test Site'
19
- end
20
-
21
- it "should return config site name if multisite is enabled but multisite name is blank" do
22
- Spud::Core.configure do |config|
23
- config.site_name = "Test Site"
24
- config.multisite_mode_enabled = true
25
- config.multisite_config = []
26
-
27
- end
28
-
29
- helper.current_site_name.should == 'Test Site'
30
- end
31
-
32
- it "should return multisite name if multisite is enabled" do
33
- Spud::Core.configure do |config|
34
- config.site_name = "Test Site"
35
- config.multisite_mode_enabled = true
36
- config.multisite_config += [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1}]
37
- end
38
-
39
- helper.current_site_name.should == 'Site B'
40
- end
41
- end
42
-
43
- describe :current_site_id do
44
-
45
-
46
-
47
- it "should return the default site id if multisite is disabled" do
48
- Spud::Core.configure do |config|
49
- config.site_id = 0
50
- config.multisite_mode_enabled = false
51
- config.multisite_config = []
52
- end
53
- helper.current_site_id.should == 0
54
- end
55
-
56
- it "should return the current site id if multisite is enabled" do
57
- Spud::Core.configure do |config|
58
- config.multisite_mode_enabled = true
59
- config.multisite_config = [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1}]
60
- end
61
- # @controller.request = request
62
- helper.current_site_id.should == 1
63
- end
64
-
65
- end
66
11
  end