push_type_core 0.3.3 → 0.4.0.beta.3

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/push_type/application_controller_methods.rb +15 -50
  3. data/app/controllers/concerns/push_type/filterable.rb +69 -0
  4. data/app/controllers/front_end_controller.rb +1 -33
  5. data/app/controllers/nodes_front_end_controller.rb +21 -0
  6. data/app/controllers/taxonomies_front_end_controller.rb +25 -0
  7. data/app/models/concerns/push_type/nestable.rb +1 -1
  8. data/app/models/concerns/push_type/publishable.rb +3 -3
  9. data/app/models/concerns/push_type/templatable.rb +1 -1
  10. data/app/models/concerns/push_type/unexposable.rb +22 -4
  11. data/app/models/push_type/taxonomy.rb +39 -0
  12. data/db/migrate/20141117170533_create_push_type_users.rb +1 -1
  13. data/db/migrate/20141117204630_create_push_type_nodes.rb +1 -1
  14. data/db/migrate/20141117210644_create_push_type_node_hierarchies.rb +2 -2
  15. data/db/migrate/20141127151930_create_push_type_assets.rb +1 -1
  16. data/db/migrate/20150310115933_create_push_type_taxonomies.rb +18 -0
  17. data/db/migrate/20150310123230_create_push_type_taxonomy_hierarchies.rb +16 -0
  18. data/lib/generators/push_type/install/templates/push_type.rb +2 -0
  19. data/lib/generators/push_type/node/node_generator.rb +1 -1
  20. data/lib/generators/push_type/taxonomy/USAGE +8 -0
  21. data/lib/generators/push_type/taxonomy/taxonomy_generator.rb +13 -0
  22. data/lib/generators/push_type/taxonomy/templates/taxonomy.html.erb +3 -0
  23. data/lib/generators/push_type/taxonomy/templates/taxonomy.rb +6 -0
  24. data/lib/push_type/config.rb +3 -0
  25. data/lib/push_type/core.rb +11 -11
  26. data/lib/push_type/rails/routes.rb +7 -1
  27. data/lib/push_type/tag_list_query.rb +1 -1
  28. data/lib/push_type/testing/common_rake.rb +2 -0
  29. data/lib/push_type/testing/factories.rb +10 -0
  30. data/lib/push_type/testing/setup.rb +3 -0
  31. data/lib/push_type/version.rb +1 -1
  32. data/test/controllers/{front_end_controller_test.rb → nodes_front_end_controller_test.rb} +8 -7
  33. data/test/controllers/taxonomies_front_end_controller_test.rb +58 -0
  34. data/test/dummy/app/models/category.rb +6 -0
  35. data/test/dummy/app/views/taxonomies/category.html.erb +3 -0
  36. data/test/dummy/config/initializers/push_type.rb +3 -1
  37. data/test/dummy/config/secrets.yml +2 -2
  38. data/test/dummy/db/migrate/{20150310192149_create_push_type_users.push_type.rb → 20150406131539_create_push_type_users.push_type.rb} +1 -1
  39. data/test/dummy/db/migrate/{20150310192150_create_push_type_nodes.push_type.rb → 20150406131540_create_push_type_nodes.push_type.rb} +1 -1
  40. data/test/dummy/db/migrate/{20150310192151_create_push_type_node_hierarchies.push_type.rb → 20150406131541_create_push_type_node_hierarchies.push_type.rb} +2 -2
  41. data/test/dummy/db/migrate/{20150310192152_create_push_type_assets.push_type.rb → 20150406131542_create_push_type_assets.push_type.rb} +1 -1
  42. data/test/dummy/db/migrate/20150406131543_create_push_type_taxonomies.push_type.rb +19 -0
  43. data/test/dummy/db/migrate/20150406131544_create_push_type_taxonomy_hierarchies.push_type.rb +17 -0
  44. data/test/dummy/db/schema.rb +29 -9
  45. data/test/dummy/log/test.log +2963 -2021
  46. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  47. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  48. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  49. data/test/dummy/tmp/generators/app/presenters/page_presenter.rb +12 -0
  50. data/test/lib/generators/push_type/taxonomy_generator_test.rb +17 -0
  51. data/test/lib/push_type/core_test.rb +64 -39
  52. data/test/models/concerns/push_type/templatable_test.rb +3 -3
  53. data/test/models/concerns/push_type/unexposable_test.rb +30 -10
  54. data/test/models/push_type/taxonomy_test.rb +35 -0
  55. metadata +41 -19
  56. data/test/dummy/tmp/generators/config/initializers/push_type.rb +0 -36
  57. data/test/dummy/tmp/generators/config/routes.rb +0 -59
  58. /data/lib/generators/push_type/node/templates/{template.html.erb → node.html.erb} +0 -0
@@ -1,13 +1,13 @@
1
1
  require "test_helper"
2
2
 
3
- describe FrontEndController do
4
-
3
+ describe NodesFrontEndController do
4
+
5
5
  before { @routes = Rails.application.routes }
6
-
7
- describe 'GET #node' do
6
+
7
+ describe 'GET #show' do
8
8
  let(:page) { Page.create attributes }
9
9
  let(:permalink) { page.permalink }
10
- let(:action!) { get :node, permalink: permalink }
10
+ let(:action!) { get :show, permalink: permalink }
11
11
 
12
12
  describe 'when node does not exist' do
13
13
  let(:permalink) { 'does/not/exist' }
@@ -32,6 +32,7 @@ describe FrontEndController do
32
32
  before_node_load { @foo = {} }
33
33
  before_node_action { @foo[:node_action] = true }
34
34
  before_node_action(only: :page) { @foo[:page_action] = true }
35
+ before_node_action(only: :foo) { @foo[:foo_action] = true }
35
36
  before_node_action(except: :page) { @foo[:except_page_action] = true }
36
37
  before_node_action(except: :foo) { @foo[:except_foo_action] = true }
37
38
  before_node_action :test_1, :test_2
@@ -44,7 +45,7 @@ describe FrontEndController do
44
45
  end
45
46
  end
46
47
  let(:page) { FactoryGirl.create :published_node, type: 'Page' }
47
- before { get :node, permalink: page.permalink }
48
+ before { get :show, permalink: page.permalink }
48
49
  it { assigns[:foo].must_be_instance_of Hash }
49
50
  it { assigns[:foo][:node_action].must_equal true }
50
51
  it { assigns[:foo][:page_action].must_equal true }
@@ -55,4 +56,4 @@ describe FrontEndController do
55
56
  it { assigns[:foo][:test_2].must_equal true }
56
57
  end
57
58
 
58
- end
59
+ end
@@ -0,0 +1,58 @@
1
+ require "test_helper"
2
+
3
+ describe TaxonomiesFrontEndController do
4
+
5
+ before { @routes = Rails.application.routes }
6
+
7
+ describe 'GET #show' do
8
+ let(:category) { Category.create FactoryGirl.attributes_for(:taxonomy) }
9
+ let(:taxonomy) { category.base_slug }
10
+ let(:permalink) { category.slug }
11
+ let(:action!) { get :show, taxonomy: taxonomy, permalink: permalink }
12
+
13
+ describe 'when taxonomy class does not exist' do
14
+ let(:taxonomy) { 'noop' }
15
+ it { proc { action! }.must_raise ActiveRecord::RecordNotFound }
16
+ end
17
+ describe 'when taxonomy term does not exist' do
18
+ let(:permalink) { 'does/not/exist' }
19
+ it { proc { action! }.must_raise ActiveRecord::RecordNotFound }
20
+ end
21
+ describe 'when taxonomy term does exist' do
22
+ before { action! }
23
+ it { response.must_render_template 'taxonomies/category' }
24
+ it { assigns[:taxonomy].must_equal category }
25
+ it { assigns[:category].must_equal category }
26
+ end
27
+ end
28
+
29
+ describe 'taxonomy filters' do
30
+ ApplicationController.module_eval do
31
+ before_taxonomy_load { @foo = {} }
32
+ before_taxonomy_action { @foo[:taxonomy_action] = true }
33
+ before_taxonomy_action(only: :category) { @foo[:category_action] = true }
34
+ before_taxonomy_action(only: :foo) { @foo[:foo_action] = true }
35
+ before_taxonomy_action(except: :category) { @foo[:except_category_action] = true }
36
+ before_taxonomy_action(except: :foo) { @foo[:except_foo_action] = true }
37
+ before_taxonomy_action :test_1, :test_2
38
+ private
39
+ def test_1
40
+ @foo[:test_1] = true
41
+ end
42
+ def test_2
43
+ @foo[:test_2] = true
44
+ end
45
+ end
46
+ let(:category) { Category.create FactoryGirl.attributes_for(:taxonomy) }
47
+ before { get :show, taxonomy: category.base_slug, permalink: category.slug }
48
+ it { assigns[:foo].must_be_instance_of Hash }
49
+ it { assigns[:foo][:taxonomy_action].must_equal true }
50
+ it { assigns[:foo][:category_action].must_equal true }
51
+ it { assigns[:foo][:foo_action].wont_be :present? }
52
+ it { assigns[:foo][:except_category_action].wont_be :present? }
53
+ it { assigns[:foo][:except_foo_action].must_equal true }
54
+ it { assigns[:foo][:test_1].must_equal true }
55
+ it { assigns[:foo][:test_2].must_equal true }
56
+ end
57
+
58
+ end
@@ -0,0 +1,6 @@
1
+ class Category < PushType::Taxonomy
2
+
3
+ # Set base slug
4
+ # base_slug :category
5
+
6
+ end
@@ -0,0 +1,3 @@
1
+ <h1><%= @taxonomy.title %></h1>
2
+ <p>This is a generated Category template.</p>
3
+ <p>Find me at: app/views/taxonomies/category.html.erb</p>
@@ -6,6 +6,8 @@ PushType.setup do |config|
6
6
 
7
7
  config.home_slug = 'home'
8
8
 
9
+ config.unexposed_taxonomies = []
10
+
9
11
  config.media_styles = {
10
12
  large: '1024x1024>',
11
13
  medium: '512x512>',
@@ -31,6 +33,6 @@ PushType.setup do |config|
31
33
  # secret_access_key: ENV['SECRET_ACCESS_KEY_ID']
32
34
  # }
33
35
 
34
- # config.dragonfly_secret = '62c7b291bb4b75e55e91c199eb240588a142a6ddbfd06e923af2df6f86dc0cbf'
36
+ # config.dragonfly_secret = '4680f3462c2db9165bc66a98f999e9379131ac94ac6a079cb840bd2bc4c24218'
35
37
 
36
38
  end
@@ -11,10 +11,10 @@
11
11
  # if you're sharing your code publicly.
12
12
 
13
13
  development:
14
- secret_key_base: 719f6195700299ffdf1f1aa2e547cd495550ace875b1f22b41b93f105c781aa13e46fe87804f07194bd39f605381f2a4faa030aee0c35c87ba0b893f38d87f19
14
+ secret_key_base: 21a067d3f6f8a04cad3168303419df414458f19da8d16f9e19def525d16297f7260af003a97addf582b14901fdaea40da9c442969da6aefba4a8f5b2f077974b
15
15
 
16
16
  test:
17
- secret_key_base: 5ef40f8a399930aff8c9368b0336178b725c930deb1183ece7d8b47d94d5b22820cdaa355870f61bf30b2b6024bc48b71d1c8b4762d127d66a6bfa21fb770958
17
+ secret_key_base: 37d037b11e63b6ed1d1f3a818744fc86260a0b9f024f700356fa4358184aeb68e60505b3caa817252d24e05baf7fe3a853f059f0ac8cc4c29d5a02dd3c8dc600
18
18
 
19
19
  # Do not keep production secrets in the repository,
20
20
  # instead read values from the environment.
@@ -7,7 +7,7 @@ class CreatePushTypeUsers < ActiveRecord::Migration
7
7
  t.string :email
8
8
  t.jsonb :field_store
9
9
 
10
- t.timestamps
10
+ t.timestamps null: false
11
11
  end
12
12
  end
13
13
  end
@@ -18,7 +18,7 @@ class CreatePushTypeNodes < ActiveRecord::Migration
18
18
  t.uuid :creator_id
19
19
  t.uuid :updater_id
20
20
 
21
- t.timestamps
21
+ t.timestamps null: false
22
22
  t.datetime :deleted_at
23
23
  end
24
24
  end
@@ -9,9 +9,9 @@ class CreatePushTypeNodeHierarchies < ActiveRecord::Migration
9
9
 
10
10
  add_index :push_type_node_hierarchies, [:ancestor_id, :descendant_id, :generations],
11
11
  unique: true,
12
- name: "anc_desc_idx"
12
+ name: "node_anc_desc_idx"
13
13
 
14
14
  add_index :push_type_node_hierarchies, [:descendant_id],
15
- name: "desc_idx"
15
+ name: "node_desc_idx"
16
16
  end
17
17
  end
@@ -12,7 +12,7 @@ class CreatePushTypeAssets < ActiveRecord::Migration
12
12
 
13
13
  t.uuid :uploader_id
14
14
 
15
- t.timestamps
15
+ t.timestamps null: false
16
16
  t.datetime :deleted_at
17
17
  end
18
18
  end
@@ -0,0 +1,19 @@
1
+ # This migration comes from push_type (originally 20150310115933)
2
+ class CreatePushTypeTaxonomies < ActiveRecord::Migration
3
+ def change
4
+ enable_extension 'uuid-ossp' unless extension_enabled?('uuid-ossp')
5
+ create_table :push_type_taxonomies, id: :uuid, default: 'uuid_generate_v4()' do |t|
6
+ t.string :type
7
+ t.string :title
8
+ t.string :slug
9
+
10
+ t.uuid :parent_id
11
+ t.integer :sort_order
12
+
13
+ t.timestamps null: false
14
+ end
15
+
16
+ # Also add a tags array to Assets
17
+ add_column :push_type_assets, :tags, :string, array: true
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # This migration comes from push_type (originally 20150310123230)
2
+ class CreatePushTypeTaxonomyHierarchies < ActiveRecord::Migration
3
+ def change
4
+ create_table :push_type_taxonomy_hierarchies, id: false do |t|
5
+ t.uuid :ancestor_id, null: false
6
+ t.uuid :descendant_id, null: false
7
+ t.integer :generations, null: false
8
+ end
9
+
10
+ add_index :push_type_taxonomy_hierarchies, [:ancestor_id, :descendant_id, :generations],
11
+ unique: true,
12
+ name: "taxonomy_anc_desc_idx"
13
+
14
+ add_index :push_type_taxonomy_hierarchies, [:descendant_id],
15
+ name: "taxonomy_desc_idx"
16
+ end
17
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20150310192152) do
14
+ ActiveRecord::Schema.define(version: 20150406131544) do
15
15
 
16
16
  # These are extensions that must be enabled in order to support this database
17
17
  enable_extension "plpgsql"
@@ -25,9 +25,10 @@ ActiveRecord::Schema.define(version: 20150310192152) do
25
25
  t.string "mime_type"
26
26
  t.string "description"
27
27
  t.uuid "uploader_id"
28
- t.datetime "created_at"
29
- t.datetime "updated_at"
28
+ t.datetime "created_at", null: false
29
+ t.datetime "updated_at", null: false
30
30
  t.datetime "deleted_at"
31
+ t.string "tags", array: true
31
32
  end
32
33
 
33
34
  create_table "push_type_node_hierarchies", id: false, force: :cascade do |t|
@@ -36,8 +37,8 @@ ActiveRecord::Schema.define(version: 20150310192152) do
36
37
  t.integer "generations", null: false
37
38
  end
38
39
 
39
- add_index "push_type_node_hierarchies", ["ancestor_id", "descendant_id", "generations"], name: "anc_desc_idx", unique: true, using: :btree
40
- add_index "push_type_node_hierarchies", ["descendant_id"], name: "desc_idx", using: :btree
40
+ add_index "push_type_node_hierarchies", ["ancestor_id", "descendant_id", "generations"], name: "node_anc_desc_idx", unique: true, using: :btree
41
+ add_index "push_type_node_hierarchies", ["descendant_id"], name: "node_desc_idx", using: :btree
41
42
 
42
43
  create_table "push_type_nodes", id: :uuid, default: "uuid_generate_v4()", force: :cascade do |t|
43
44
  t.string "type"
@@ -51,17 +52,36 @@ ActiveRecord::Schema.define(version: 20150310192152) do
51
52
  t.datetime "published_to"
52
53
  t.uuid "creator_id"
53
54
  t.uuid "updater_id"
54
- t.datetime "created_at"
55
- t.datetime "updated_at"
55
+ t.datetime "created_at", null: false
56
+ t.datetime "updated_at", null: false
56
57
  t.datetime "deleted_at"
57
58
  end
58
59
 
60
+ create_table "push_type_taxonomies", id: :uuid, default: "uuid_generate_v4()", force: :cascade do |t|
61
+ t.string "type"
62
+ t.string "title"
63
+ t.string "slug"
64
+ t.uuid "parent_id"
65
+ t.integer "sort_order"
66
+ t.datetime "created_at", null: false
67
+ t.datetime "updated_at", null: false
68
+ end
69
+
70
+ create_table "push_type_taxonomy_hierarchies", id: false, force: :cascade do |t|
71
+ t.uuid "ancestor_id", null: false
72
+ t.uuid "descendant_id", null: false
73
+ t.integer "generations", null: false
74
+ end
75
+
76
+ add_index "push_type_taxonomy_hierarchies", ["ancestor_id", "descendant_id", "generations"], name: "taxonomy_anc_desc_idx", unique: true, using: :btree
77
+ add_index "push_type_taxonomy_hierarchies", ["descendant_id"], name: "taxonomy_desc_idx", using: :btree
78
+
59
79
  create_table "push_type_users", id: :uuid, default: "uuid_generate_v4()", force: :cascade do |t|
60
80
  t.string "name"
61
81
  t.string "email"
62
82
  t.jsonb "field_store"
63
- t.datetime "created_at"
64
- t.datetime "updated_at"
83
+ t.datetime "created_at", null: false
84
+ t.datetime "updated_at", null: false
65
85
  end
66
86
 
67
87
  end