tb_redirects 0.0.1 → 0.9.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +42 -0
  3. data/app/models/tb_redirect.rb +2 -1
  4. data/lib/tb_redirects/version.rb +1 -1
  5. data/spec/concerns/tb_redirects/has_redirects_spec.rb +22 -0
  6. data/spec/controllers/admin/tb_redirects_controller_spec.rb +77 -0
  7. data/spec/controllers/application_controller_spec.rb +25 -0
  8. data/spec/dummy/README.rdoc +28 -0
  9. data/spec/dummy/Rakefile +6 -0
  10. data/spec/dummy/app/assets/javascripts/admin/application.js +16 -0
  11. data/spec/dummy/app/assets/javascripts/application.js +17 -0
  12. data/spec/dummy/app/assets/javascripts/bootstrap_modules.js +14 -0
  13. data/spec/dummy/app/assets/stylesheets/admin/application.scss +3 -0
  14. data/spec/dummy/app/assets/stylesheets/application.scss +6 -0
  15. data/spec/dummy/app/assets/stylesheets/imports/bootstrap_modules.scss +56 -0
  16. data/spec/dummy/app/assets/stylesheets/imports/bootstrap_theme.scss +875 -0
  17. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  18. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  19. data/spec/dummy/app/models/widget.rb +3 -0
  20. data/spec/dummy/app/views/layouts/application.html.erb +32 -0
  21. data/spec/dummy/app/views/layouts/error_page.html.erb +8 -0
  22. data/spec/dummy/bin/bundle +3 -0
  23. data/spec/dummy/bin/rails +4 -0
  24. data/spec/dummy/bin/rake +4 -0
  25. data/spec/dummy/bin/setup +29 -0
  26. data/spec/dummy/config.ru +4 -0
  27. data/spec/dummy/config/application.rb +31 -0
  28. data/spec/dummy/config/boot.rb +5 -0
  29. data/spec/dummy/config/database.yml +28 -0
  30. data/spec/dummy/config/environment.rb +5 -0
  31. data/spec/dummy/config/environments/development.rb +41 -0
  32. data/spec/dummy/config/environments/production.rb +79 -0
  33. data/spec/dummy/config/environments/test.rb +44 -0
  34. data/spec/dummy/config/initializers/assets.rb +11 -0
  35. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  36. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  37. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  38. data/spec/dummy/config/initializers/inflections.rb +16 -0
  39. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  40. data/spec/dummy/config/initializers/session_store.rb +3 -0
  41. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/spec/dummy/config/locales/en.yml +23 -0
  43. data/spec/dummy/config/routes.rb +56 -0
  44. data/spec/dummy/config/secrets.yml +22 -0
  45. data/spec/dummy/db/migrate/20160211160614_create_spud_admin_permissions.tb_core.rb +12 -0
  46. data/spec/dummy/db/migrate/20160211160615_create_spud_users.tb_core.rb +30 -0
  47. data/spec/dummy/db/migrate/20160211160616_add_time_zone_to_spud_user.tb_core.rb +7 -0
  48. data/spec/dummy/db/migrate/20160211160617_add_scope_to_spud_admin_permissions.tb_core.rb +7 -0
  49. data/spec/dummy/db/migrate/20160211160618_create_spud_user_settings.tb_core.rb +12 -0
  50. data/spec/dummy/db/migrate/20160211160619_create_spud_roles.tb_core.rb +11 -0
  51. data/spec/dummy/db/migrate/20160211160620_create_spud_permissions.tb_core.rb +11 -0
  52. data/spec/dummy/db/migrate/20160211160621_create_spud_role_permissions.tb_core.rb +12 -0
  53. data/spec/dummy/db/migrate/20160211160622_drop_spud_admin_permissions.tb_core.rb +16 -0
  54. data/spec/dummy/db/migrate/20160211160623_add_requires_password_change_to_spud_users.tb_core.rb +6 -0
  55. data/spec/dummy/db/migrate/20160211185931_create_widgets.rb +9 -0
  56. data/spec/dummy/db/migrate/20160212211331_create_tb_redirects.tb_redirects.rb +15 -0
  57. data/spec/dummy/db/schema.rb +97 -0
  58. data/spec/dummy/public/404.html +67 -0
  59. data/spec/dummy/public/422.html +67 -0
  60. data/spec/dummy/public/500.html +66 -0
  61. data/spec/dummy/public/favicon.ico +0 -0
  62. data/spec/factories/tb_redirects.rb +9 -0
  63. data/spec/helpers/admin/tb_redirects_helper_spec.rb +16 -0
  64. data/spec/jobs/tb_redirects/detect_redirect_loop_job_spec.rb +69 -0
  65. data/spec/models/tb_redirect_spec.rb +77 -0
  66. data/spec/rails_helper.rb +78 -0
  67. data/spec/spec_helper.rb +92 -0
  68. metadata +132 -5
@@ -0,0 +1,56 @@
1
+ Rails.application.routes.draw do
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+ # See how all your routes lay out with "rake routes".
4
+
5
+ # You can have the root of your site routed with "root"
6
+ # root 'welcome#index'
7
+
8
+ # Example of regular route:
9
+ # get 'products/:id' => 'catalog#view'
10
+
11
+ # Example of named route that can be invoked with purchase_url(id: product.id)
12
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
+
14
+ # Example resource route (maps HTTP verbs to controller actions automatically):
15
+ # resources :products
16
+
17
+ # Example resource route with options:
18
+ # resources :products do
19
+ # member do
20
+ # get 'short'
21
+ # post 'toggle'
22
+ # end
23
+ #
24
+ # collection do
25
+ # get 'sold'
26
+ # end
27
+ # end
28
+
29
+ # Example resource route with sub-resources:
30
+ # resources :products do
31
+ # resources :comments, :sales
32
+ # resource :seller
33
+ # end
34
+
35
+ # Example resource route with more complex sub-resources:
36
+ # resources :products do
37
+ # resources :comments
38
+ # resources :sales do
39
+ # get 'recent', on: :collection
40
+ # end
41
+ # end
42
+
43
+ # Example resource route with concerns:
44
+ # concern :toggleable do
45
+ # post 'toggle'
46
+ # end
47
+ # resources :posts, concerns: :toggleable
48
+ # resources :photos, concerns: :toggleable
49
+
50
+ # Example resource route within a namespace:
51
+ # namespace :admin do
52
+ # # Directs /admin/products/* to Admin::ProductsController
53
+ # # (app/controllers/admin/products_controller.rb)
54
+ # resources :products
55
+ # end
56
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 13a9193573076340d0331270921cea4e6584f7d17c425d409cab77c43a839fcfcebca506d0c9ce128146dd0e240aa85e431a3638b61c3ab12bb75edbfc1346bd
15
+
16
+ test:
17
+ secret_key_base: e9b8721f43329fc9a0385b22012bfc5f170cf89d891a38d3f4666eb97b1c75f27b8f5823dbc22ed0d73726d4b8058f949c3046f9291390410d963fb3d7341c3c
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -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
@@ -0,0 +1,6 @@
1
+ # This migration comes from tb_core (originally 20150610143438)
2
+ class AddRequiresPasswordChangeToSpudUsers < ActiveRecord::Migration
3
+ def change
4
+ add_column :spud_users, :requires_password_change, :boolean, :default => false
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ class CreateWidgets < ActiveRecord::Migration
2
+ def change
3
+ create_table :widgets do |t|
4
+ t.string :name
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ # This migration comes from tb_redirects (originally 20160211162513)
2
+ class CreateTbRedirects < ActiveRecord::Migration
3
+ def change
4
+ create_table :tb_redirects do |t|
5
+ t.string :owner_type
6
+ t.integer :owner_id
7
+ t.string :source, :null => false
8
+ t.string :destination, :null => false
9
+ t.string :created_by
10
+ t.timestamps null: false
11
+ end
12
+ add_index :tb_redirects, [:owner_type, :owner_id]
13
+ add_index :tb_redirects, :source, :unique => true
14
+ end
15
+ end
@@ -0,0 +1,97 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20160212211331) do
15
+
16
+ create_table "spud_permissions", force: :cascade 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
+ end
22
+
23
+ add_index "spud_permissions", ["tag"], name: "index_spud_permissions_on_tag", unique: true, length: {"tag"=>191}, using: :btree
24
+
25
+ create_table "spud_role_permissions", force: :cascade 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
+ end
31
+
32
+ add_index "spud_role_permissions", ["spud_permission_tag"], name: "index_spud_role_permissions_on_spud_permission_tag", length: {"spud_permission_tag"=>191}, using: :btree
33
+ add_index "spud_role_permissions", ["spud_role_id"], name: "index_spud_role_permissions_on_spud_role_id", using: :btree
34
+
35
+ create_table "spud_roles", force: :cascade do |t|
36
+ t.string "name", limit: 255
37
+ t.datetime "created_at"
38
+ t.datetime "updated_at"
39
+ end
40
+
41
+ create_table "spud_user_settings", force: :cascade 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
+ end
48
+
49
+ create_table "spud_users", force: :cascade do |t|
50
+ t.string "first_name", limit: 255
51
+ t.string "last_name", limit: 255
52
+ t.boolean "super_admin"
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
+ t.datetime "last_request_at"
63
+ t.datetime "current_login_at"
64
+ t.datetime "last_login_at"
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
+ t.boolean "requires_password_change", default: false
72
+ end
73
+
74
+ add_index "spud_users", ["email"], name: "index_spud_users_on_email", length: {"email"=>191}, using: :btree
75
+ add_index "spud_users", ["login"], name: "index_spud_users_on_login", length: {"login"=>191}, using: :btree
76
+ add_index "spud_users", ["spud_role_id"], name: "index_spud_users_on_spud_role_id", using: :btree
77
+
78
+ create_table "tb_redirects", force: :cascade do |t|
79
+ t.string "owner_type", limit: 255
80
+ t.integer "owner_id", limit: 4
81
+ t.string "source", limit: 255, null: false
82
+ t.string "destination", limit: 255, null: false
83
+ t.string "created_by", limit: 255
84
+ t.datetime "created_at", null: false
85
+ t.datetime "updated_at", null: false
86
+ end
87
+
88
+ add_index "tb_redirects", ["owner_type", "owner_id"], name: "index_tb_redirects_on_owner_type_and_owner_id", length: {"owner_type"=>191, "owner_id"=>nil}, using: :btree
89
+ add_index "tb_redirects", ["source"], name: "index_tb_redirects_on_source", unique: true, length: {"source"=>191}, using: :btree
90
+
91
+ create_table "widgets", force: :cascade do |t|
92
+ t.string "name", limit: 255
93
+ t.datetime "created_at", null: false
94
+ t.datetime "updated_at", null: false
95
+ end
96
+
97
+ end
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>