pulitzer 0.12.5 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/pulitzer.scss +107 -4
  3. data/app/controllers/pulitzer/arrangement_styles_controller.rb +52 -0
  4. data/app/controllers/pulitzer/background_styles_controller.rb +52 -0
  5. data/app/controllers/pulitzer/content_elements_controller.rb +2 -2
  6. data/app/controllers/pulitzer/free_form_section_types_controller.rb +2 -2
  7. data/app/controllers/pulitzer/justification_styles_controller.rb +52 -0
  8. data/app/controllers/pulitzer/layouts_controller.rb +2 -2
  9. data/app/controllers/pulitzer/partial_types_controller.rb +1 -1
  10. data/app/controllers/pulitzer/partials_controller.rb +2 -2
  11. data/app/controllers/pulitzer/post_tags_controller.rb +2 -2
  12. data/app/controllers/pulitzer/post_type_content_element_types_controller.rb +2 -2
  13. data/app/controllers/pulitzer/post_types_controller.rb +2 -2
  14. data/app/controllers/pulitzer/posts_controller.rb +1 -1
  15. data/app/controllers/pulitzer/sequence_flow_styles_controller.rb +52 -0
  16. data/app/controllers/pulitzer/tags_controller.rb +3 -3
  17. data/app/interactions/pulitzer/update_post_type_content_elements.rb +1 -1
  18. data/app/models/pulitzer/arrangement_style.rb +8 -0
  19. data/app/models/pulitzer/background_style.rb +8 -0
  20. data/app/models/pulitzer/content_element.rb +4 -0
  21. data/app/models/pulitzer/free_form_section_type.rb +5 -1
  22. data/app/models/pulitzer/justification_style.rb +8 -0
  23. data/app/models/pulitzer/partial.rb +39 -5
  24. data/app/models/pulitzer/partial_type.rb +2 -10
  25. data/app/models/pulitzer/post.rb +1 -1
  26. data/app/models/pulitzer/post_type.rb +4 -5
  27. data/app/models/pulitzer/post_type_content_element_type.rb +20 -1
  28. data/app/models/pulitzer/sequence_flow_style.rb +8 -0
  29. data/app/views/pulitzer/arrangement_styles/_form.html.erb +14 -0
  30. data/app/views/pulitzer/arrangement_styles/_form_fields.html.erb +6 -0
  31. data/app/views/pulitzer/arrangement_styles/_new.html.erb +12 -0
  32. data/app/views/pulitzer/arrangement_styles/_show.html.erb +10 -0
  33. data/app/views/pulitzer/arrangement_styles/_show_wrapper.html.erb +3 -0
  34. data/app/views/pulitzer/background_styles/_form.html.erb +14 -0
  35. data/app/views/pulitzer/background_styles/_form_fields.html.erb +6 -0
  36. data/app/views/pulitzer/background_styles/_new.html.erb +12 -0
  37. data/app/views/pulitzer/background_styles/_show.html.erb +10 -0
  38. data/app/views/pulitzer/background_styles/_show_wrapper.html.erb +3 -0
  39. data/app/views/pulitzer/free_form_section_types/_form.html.erb +16 -7
  40. data/app/views/pulitzer/free_form_section_types/_form_fields.html.erb +6 -4
  41. data/app/views/pulitzer/free_form_section_types/_new.html.erb +12 -7
  42. data/app/views/pulitzer/free_form_section_types/_show.html.erb +10 -12
  43. data/app/views/pulitzer/free_form_section_types/_show_wrapper.html.erb +2 -2
  44. data/app/views/pulitzer/justification_styles/_form.html.erb +14 -0
  45. data/app/views/pulitzer/justification_styles/_form_fields.html.erb +6 -0
  46. data/app/views/pulitzer/justification_styles/_new.html.erb +12 -0
  47. data/app/views/pulitzer/justification_styles/_show.html.erb +10 -0
  48. data/app/views/pulitzer/justification_styles/_show_wrapper.html.erb +3 -0
  49. data/app/views/pulitzer/partial_types/_index.html.erb +2 -2
  50. data/app/views/pulitzer/partial_types/_new.html.erb +1 -12
  51. data/app/views/pulitzer/partial_types/_show.html.erb +15 -5
  52. data/app/views/pulitzer/partial_types/_show_wrapper.html.erb +1 -1
  53. data/app/views/pulitzer/partials/_form.html.erb +31 -13
  54. data/app/views/pulitzer/partials/_new.html.erb +30 -11
  55. data/app/views/pulitzer/partials/_show.html.erb +8 -4
  56. data/app/views/pulitzer/post_type_content_element_types/_form.html.erb +12 -6
  57. data/app/views/pulitzer/post_type_content_element_types/_form_fields.html.erb +15 -13
  58. data/app/views/pulitzer/post_type_content_element_types/_new.html.erb +11 -6
  59. data/app/views/pulitzer/post_type_content_element_types/_show.html.erb +16 -9
  60. data/app/views/pulitzer/post_type_content_element_types/_show_wrapper.html.erb +2 -2
  61. data/app/views/pulitzer/post_types/_new.html.erb +1 -1
  62. data/app/views/pulitzer/post_types/_show.html.erb +10 -10
  63. data/app/views/pulitzer/post_types/_template.html.erb +98 -29
  64. data/app/views/pulitzer/sequence_flow_styles/_form.html.erb +14 -0
  65. data/app/views/pulitzer/sequence_flow_styles/_form_fields.html.erb +6 -0
  66. data/app/views/pulitzer/sequence_flow_styles/_new.html.erb +12 -0
  67. data/app/views/pulitzer/sequence_flow_styles/_show.html.erb +10 -0
  68. data/app/views/pulitzer/sequence_flow_styles/_show_wrapper.html.erb +3 -0
  69. data/config/routes.rb +5 -1
  70. data/db/migrate/20170518142411_create_pulitzer_background_classes.rb +9 -0
  71. data/db/migrate/20170518144418_create_pulitzer_justification_classes.rb +9 -0
  72. data/db/migrate/20170518144449_create_pulitzer_sequence_flow_classes.rb +9 -0
  73. data/db/migrate/20170518144515_create_pulitzer_arrangement_classes.rb +9 -0
  74. data/db/migrate/20170518145318_convert_pulitzer_layouts.rb +9 -0
  75. data/lib/pulitzer/content_element_helper.rb +5 -3
  76. data/lib/pulitzer/version.rb +1 -1
  77. data/spec/controllers/pulitzer/free_form_section_types_controller_spec.rb +6 -6
  78. data/spec/controllers/pulitzer/partials_controller_spec.rb +7 -7
  79. data/spec/controllers/pulitzer/post_types_controller_spec.rb +3 -3
  80. data/spec/controllers/pulitzer/versions_controller_spec.rb +8 -8
  81. data/spec/controllers/tags_controller_spec.rb +28 -29
  82. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  83. data/spec/dummy/config/application.rb +0 -1
  84. data/spec/dummy/config/environments/test.rb +2 -2
  85. data/spec/dummy/db/schema.rb +30 -2
  86. data/spec/dummy/db/test.sqlite3 +0 -0
  87. data/spec/dummy/log/test.log +0 -3971
  88. data/spec/factories/partial_type.rb +0 -1
  89. data/spec/rails_helper.rb +1 -1
  90. metadata +35 -9
  91. data/app/views/pulitzer/layouts/_form.html.erb +0 -8
  92. data/app/views/pulitzer/layouts/_form_fields.html.erb +0 -2
  93. data/app/views/pulitzer/layouts/_new.html.erb +0 -7
  94. data/app/views/pulitzer/layouts/_show.html.erb +0 -9
  95. data/app/views/pulitzer/layouts/_show_wrapper.html.erb +0 -3
  96. data/spec/factories/layout.rb +0 -6
@@ -0,0 +1,14 @@
1
+ <div class="pulitzer-row">
2
+ <%= render 'pulitzer/shared/error_messages', object: sequence_flow_style %>
3
+ <%= form_for sequence_flow_style, html: ajax_form_hash(dom_target(sequence_flow_style)) do |f| %>
4
+ <%= render partial: 'form_fields', locals: { f: f, sequence_flow_style: sequence_flow_style } %>
5
+ <div class="pulitzer-span ten-percent">
6
+ <%= f.submit "Update" %>
7
+ </div>
8
+ <div class="pulitzer-span ten-percent">
9
+ <%= link_to('Cancel', sequence_flow_style_path(sequence_flow_style), :class => 'button',
10
+ data: { ajax_link: true, ajax_target: dom_target(sequence_flow_style) } ) %>
11
+ </div>
12
+ <% end %>
13
+
14
+ </div>
@@ -0,0 +1,6 @@
1
+ <div class="pulitzer-span one-fifth">
2
+ <%= f.text_field :display_name %>
3
+ </div>
4
+ <div class="pulitzer-span one-fifth">
5
+ <%= f.text_field :css_class_name %>
6
+ </div>
@@ -0,0 +1,12 @@
1
+ <div class="pulitzer-row">
2
+ <%= form_for sequence_flow_style, html: ajax_form_hash(dom_target(sequence_flow_style.post_type, :sequence_flow_styles_container), insert_method: 'append', reset_on_success: true) do |f| %>
3
+ <%= f.hidden_field :post_type_id %>
4
+ <%= render partial: 'form_fields', locals: { f: f, sequence_flow_style: sequence_flow_style } %>
5
+ <div class="pulitzer-span ten-percent">
6
+ <%= f.submit "Create", data: {disable_with: false} %>
7
+ </div>
8
+ <div class="pulitzer-span ten-percent">
9
+ <a class="button" data-emptier="true" data-target="<%= dom_target(sequence_flow_style.post_type, :new_sequence_flow_style) %>">Close</a>
10
+ </div>
11
+ <% end %>
12
+ </div>
@@ -0,0 +1,10 @@
1
+ <div class="pulitzer-row">
2
+ <div class="pulitzer-span one-fifth"><%= sequence_flow_style.display_name %></div>
3
+ <div class="pulitzer-span one-fifth"><%= sequence_flow_style.css_class_name %></div>
4
+ <div class="pulitzer-span ten-percent">
5
+ <%= ajax_link "Edit", edit_sequence_flow_style_path(sequence_flow_style), {}, dom_target(sequence_flow_style) %>
6
+ </div>
7
+ <div class="pulitzer-span ten-percent">
8
+ <%= ajax_delete 'Delete', sequence_flow_style_path(sequence_flow_style), {}, dom_target(sequence_flow_style) %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,3 @@
1
+ <div class="pulitzer-row" id="<%= dom_id(sequence_flow_style) %>">
2
+ <%= render partial: '/pulitzer/sequence_flow_styles/show', locals: {sequence_flow_style: sequence_flow_style} %>
3
+ </div>
data/config/routes.rb CHANGED
@@ -34,7 +34,11 @@ Pulitzer::Engine.routes.draw do
34
34
  patch :update_all
35
35
  end
36
36
  end
37
- resources :layouts
37
+ resources :background_styles
38
+ resources :justification_styles
39
+ resources :sequence_flow_styles
40
+ resources :arrangement_styles
41
+
38
42
  resources :free_form_sections
39
43
  root to: 'post_types#index'
40
44
  end
@@ -0,0 +1,9 @@
1
+ class CreatePulitzerBackgroundClasses < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :pulitzer_background_styles do |t|
4
+ t.integer :post_type_id
5
+ t.string :display_name
6
+ t.string :css_class_name
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreatePulitzerJustificationClasses < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :pulitzer_justification_styles do |t|
4
+ t.integer :post_type_id
5
+ t.string :display_name
6
+ t.string :css_class_name
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreatePulitzerSequenceFlowClasses < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :pulitzer_sequence_flow_styles do |t|
4
+ t.integer :post_type_id
5
+ t.string :display_name
6
+ t.string :css_class_name
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreatePulitzerArrangementClasses < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :pulitzer_arrangement_styles do |t|
4
+ t.integer :post_type_id
5
+ t.string :display_name
6
+ t.string :view_file_name
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class ConvertPulitzerLayouts < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :pulitzer_partials, :background_style_id, :integer
4
+ add_column :pulitzer_partials, :justification_style_id, :integer
5
+ add_column :pulitzer_partials, :sequence_flow_style_id, :integer
6
+ add_column :pulitzer_partials, :arrangement_style_id, :integer
7
+ end
8
+
9
+ end
@@ -1,6 +1,10 @@
1
1
  module Pulitzer
2
2
  module ContentElementHelper
3
3
 
4
+ def cms_content_present?(element)
5
+ element.present? && element.has_content?
6
+ end
7
+
4
8
  def render_cms_element(element,options = {})
5
9
  if element.image_type?
6
10
  render_image(element,options)
@@ -51,9 +55,7 @@ module Pulitzer
51
55
 
52
56
  def render_cms_section(version, section_name)
53
57
  version.section(section_name).partials.collect do |partial|
54
- if partial.has_display?
55
- render partial: partial.full_view_path, locals: {partial: partial}
56
- end
58
+ render partial: partial.full_view_path, locals: {partial: partial}
57
59
  end.join.html_safe
58
60
  end
59
61
  end
@@ -1,3 +1,3 @@
1
1
  module Pulitzer
2
- VERSION = '0.12.5'
2
+ VERSION = '0.13.0'
3
3
  end
@@ -7,36 +7,36 @@ describe Pulitzer::FreeFormSectionTypesController do
7
7
  let(:post_type) { Pulitzer::PostType.create(name: 'free as a bird', plural: true, kind: Pulitzer::PostType.kinds[:template]) }
8
8
  let(:free_form_section_type) { post_type.free_form_section_types.create(name: 'main content') }
9
9
 
10
- describe "#amenities" do
10
+ describe "#amenities", type: :request do
11
11
  it "renders the new form" do
12
12
  post_type
13
- get :new, post_type_id: post_type.id
13
+ get pulitzer.new_free_form_section_type_path post_type_id: post_type.id
14
14
  expect(response.status).to eq 200
15
15
  expect(response.body).to match /free_form_section_type\[name\]/
16
16
  end
17
17
 
18
18
  it "creates a new free form section type" do
19
- post :create, free_form_section_type: {post_type_id: post_type.id, name: 'test sidebar'}
19
+ post pulitzer.free_form_section_types_path free_form_section_type: {post_type_id: post_type.id, name: 'test sidebar'}
20
20
  expect(response.status).to eq 200
21
21
  ffst = Pulitzer::FreeFormSectionType.order(id: :desc).first
22
22
  expect(ffst.name).to eq "test sidebar"
23
23
  end
24
24
 
25
25
  it "edits an free_form_section_type" do
26
- get :edit, id: free_form_section_type.id
26
+ get pulitzer.edit_free_form_section_type_path id: free_form_section_type.id
27
27
  expect(response.status).to eq 200
28
28
 
29
29
  expect(response.body).to match 'main content'
30
30
  end
31
31
 
32
32
  it "updates an free_form_section_type" do
33
- patch :update, id: free_form_section_type.id, free_form_section_type: {name: 'edited name'}
33
+ patch pulitzer.free_form_section_type_path id: free_form_section_type.id, free_form_section_type: {name: 'edited name'}
34
34
  expect(response.status).to eq 200
35
35
  expect(free_form_section_type.reload.name).to eq 'edited name'
36
36
  end
37
37
 
38
38
  it "deletes an free_form_section_type" do
39
- delete :destroy, id: free_form_section_type.id
39
+ delete pulitzer.free_form_section_type_path id: free_form_section_type.id
40
40
  expect(response.status).to eq 200
41
41
  expect(Pulitzer::FreeFormSectionType.find_by(id: free_form_section_type.id)).to be nil
42
42
  end
@@ -6,18 +6,18 @@ describe Pulitzer::PartialsController do
6
6
 
7
7
  let(:post_type) { Pulitzer::PostType.create(name: 'Centered Text White BG', plural: true, kind: Pulitzer::PostType.kinds[:partial]) }
8
8
  let(:free_form_section) { Pulitzer::FreeFormSection.create(name: 'free as a bird') }
9
- let(:partial) { free_form_section.partials.create(post_type_id: post_type.id) }
9
+ let(:partial) { free_form_section.partials.create(post_type_id: post_type.id, label: 'test partial') }
10
10
 
11
- describe "#amenities" do
11
+ describe "#amenities", type: :request do
12
12
  it "renders the new form" do
13
13
  post_type
14
- get :new, partial: {free_form_section_id: free_form_section.id}
14
+ get pulitzer.new_partial_path partial: {free_form_section_id: free_form_section.id}
15
15
  expect(response.status).to eq 200
16
16
  expect(response.body).to match post_type.name
17
17
  end
18
18
 
19
19
  it "creates a new partial" do
20
- post :create, partial: {post_type_id: post_type.id, free_form_section_id: free_form_section.id}
20
+ post pulitzer.partials_path partial: {post_type_id: post_type.id, free_form_section_id: free_form_section.id}
21
21
  expect(response.status).to eq 200
22
22
  partial = Pulitzer::Partial.order(id: :desc).first
23
23
  expect(partial.free_form_section_id).to eq free_form_section.id
@@ -25,15 +25,15 @@ describe Pulitzer::PartialsController do
25
25
  end
26
26
 
27
27
  it "edits a partial" do
28
- get :edit, id: partial.id
28
+ get pulitzer.edit_partial_path id: partial.id
29
29
  expect(response.status).to eq 200
30
30
 
31
- expect(response.body).to match post_type.name
31
+ expect(response.body).to match partial.label
32
32
  end
33
33
 
34
34
  it "updates a partial" do
35
35
  other_post_type = Pulitzer::PostType.create(name: 'Left Text White BG', plural: true, kind: Pulitzer::PostType.kinds[:partial])
36
- patch :update, id: partial.id, partial: {post_type_id: other_post_type.id}
36
+ patch pulitzer.partial_path id: partial.id, partial: {post_type_id: other_post_type.id}
37
37
  expect(response.status).to eq 200
38
38
  expect(partial.reload.name).to eq 'Left Text White BG'
39
39
  end
@@ -4,16 +4,16 @@ describe Pulitzer::PostTypesController do
4
4
  routes { Pulitzer::Engine.routes }
5
5
  render_views
6
6
 
7
- describe "#create" do
7
+ describe "#create", type: :request do
8
8
  it "Creates a plural post type without an intial post" do
9
- post :create, post_type: { name: 'Flock of birds', kind: 'template', plural: '1' }
9
+ post pulitzer.post_types_path post_type: { name: 'Flock of birds', kind: 'template', plural: '1' }
10
10
  expect(response.status).to eq 200
11
11
  expect(response.body).to match /Flock of birds/
12
12
  expect(Pulitzer::PostType.find_by(name: 'Flock of birds').posts.any?).to be false
13
13
  end
14
14
 
15
15
  it "Creates a single post type with an intial post" do
16
- post :create, post_type: { name: 'Crow', kind: 'template', plural: '0' }
16
+ post pulitzer.post_types_path post_type: { name: 'Crow', kind: 'template', plural: '0' }
17
17
  post_type = Pulitzer::PostType.find_by(name: 'Crow')
18
18
  expect(response.status).to eq 200
19
19
  expect(response.body).to match post_type.name
@@ -6,15 +6,15 @@ describe Pulitzer::VersionsController do
6
6
 
7
7
  let(:post_type) { Pulitzer::PostType.named('Welcome') }
8
8
  let(:content_element_type) { post_type.post_type_content_element_types.first.content_element_type }
9
- let(:post) { post_type.posts.first }
10
- let(:version) {post.preview_version}
9
+ let(:ppost) { post_type.posts.first }
10
+ let(:version) {ppost.preview_version}
11
11
 
12
- describe "updating versions" do
12
+ describe "updating versions", type: :request do
13
13
  it "abandons a post that was never published" do
14
- active_version = post.active_version
14
+ active_version = ppost.active_version
15
15
  active_version.destroy
16
16
  old_post_id = version.post.id
17
- patch :update, id: version.id, status: 'abandoned'
17
+ patch pulitzer.version_path id: version.id, status: 'abandoned'
18
18
  expect(response.status).to eq 200
19
19
  expect(Pulitzer::Version.find_by(id: version.id)).to eq nil
20
20
  expect(Pulitzer::Post.find_by(id: old_post_id)).to eq nil
@@ -25,7 +25,7 @@ describe Pulitzer::VersionsController do
25
25
  Pulitzer::UpdateVersionStatus.new(version, 'active').call
26
26
  expect(version.status).to eq 'active'
27
27
  expect(version.post.active_version).not_to be_nil
28
- patch :update, id: version.id, status: 'abandoned'
28
+ patch pulitzer.version_path id: version.id, status: 'abandoned'
29
29
  expect(response.status).to eq 200
30
30
  expect(version.reload.status).to eq 'abandoned'
31
31
  expect(version.post.active_version).to be_nil
@@ -36,7 +36,7 @@ describe Pulitzer::VersionsController do
36
36
  active_version = version
37
37
  expect(active_version.status).to eq 'active'
38
38
  old_preview = version.post.preview_version
39
- patch :update, id: old_preview.id, status: 'abandoned'
39
+ patch pulitzer.version_path id: old_preview.id, status: 'abandoned'
40
40
  expect(response.status).to eq 200
41
41
  expect(active_version.reload.status).to eq 'active'
42
42
  expect(old_preview.reload.status).to eq 'abandoned'
@@ -45,7 +45,7 @@ describe Pulitzer::VersionsController do
45
45
  it "responds with errors if the interaction has one" do
46
46
  ptcet = post_type.post_type_content_element_types.create(label: 'test', required: true, content_element_type: content_element_type)
47
47
  version.content_elements.first.update_columns(body: nil, post_type_content_element_type_id: ptcet.id)
48
- patch :update, id: version.id, status: 'active'
48
+ patch pulitzer.version_path id: version.id, status: 'active'
49
49
  expect(response.status).to eq 409
50
50
  expect(response.body).to match "It's not possible to activate a version without filling required content elements"
51
51
  end
@@ -5,50 +5,49 @@ describe Pulitzer::TagsController do
5
5
  routes { Pulitzer::Engine.routes }
6
6
  render_views
7
7
 
8
- describe "#index" do
8
+ describe "#index", type: :request do
9
9
  let!(:flat_tag) { create :tag, hierarchical: false }
10
10
  let!(:root_tag) { create :tag, hierarchical: true }
11
11
 
12
- before { get :index }
12
+ before { get pulitzer.tags_path }
13
13
 
14
14
  it "renders the index template" do
15
15
  expect(response).to render_template("_index")
16
16
  end
17
17
 
18
- it "assigns to flat tags" do
19
- expect(assigns[:flat_tags]).to eq [flat_tag]
18
+ it "renders flat tags" do
19
+ expect(response.body).to match(flat_tag.name)
20
20
  end
21
21
 
22
- it "assigns to root tags" do
23
- expect(assigns[:root_tags]).to eq [root_tag]
22
+ it "renders root tags" do
23
+ expect(response.body).to match(root_tag.name)
24
24
  end
25
25
  end
26
26
 
27
- describe "#show" do
27
+ describe "#show", type: :request do
28
28
  let(:tag) { create :tag }
29
29
 
30
30
  it "finds the right tag" do
31
- get :show, id: tag.id
32
- expect(assigns[:tag]).to eq tag
31
+ get pulitzer.tag_path id: tag.id
32
+ expect(response.body).to match(tag.name)
33
33
  end
34
34
 
35
35
  it "renders the right template" do
36
- get :show, id: tag.id
36
+ get pulitzer.tag_path id: tag.id
37
37
  expect(response).to render_template(partial: "show", locals: { tag: tag })
38
38
  end
39
39
  end
40
40
 
41
- describe "#new" do
41
+ describe "#new", type: :request do
42
42
  it "builds a new tag with the right params" do
43
- get :new, tag: { hierarchical: true }
44
- expect(assigns[:tag]).to be_a Pulitzer::Tag
45
- expect(assigns[:tag].new_record?).to eq true
46
- expect(assigns[:tag].hierarchical?).to eq true
43
+ get pulitzer.new_tag_path tag: { hierarchical: true }
44
+ expect(response).to have_http_status(:success)
45
+ expect(response.body).to match('tag\[name\]')
47
46
  end
48
47
 
49
48
  context "with hierarchical: true" do
50
49
  it "responds with the right template" do
51
- get :new, tag: { hierarchical: true }
50
+ get pulitzer.new_tag_path tag: { hierarchical: true }
52
51
  expect(response).to render_template('_new_hierarchical')
53
52
  end
54
53
 
@@ -56,22 +55,22 @@ describe Pulitzer::TagsController do
56
55
 
57
56
  context "with hierarchical: false" do
58
57
  it "responds with the right template" do
59
- get :new, tag: { hierarchical: false }
58
+ get pulitzer.new_tag_path tag: { hierarchical: false }
60
59
  expect(response).to render_template('_new_flat')
61
60
  end
62
61
  end
63
62
  end
64
63
 
65
- describe "#create" do
64
+ describe "#create", type: :request do
66
65
  let(:attributes) { attributes_for :tag }
67
66
  context "with good arguments" do
68
67
 
69
68
  it "creates the tag" do
70
- expect { post :create, tag: attributes }.to change { Pulitzer::Tag.count }.by(1)
69
+ expect { post pulitzer.tags_path tag: attributes }.to change { Pulitzer::Tag.count }.by(1)
71
70
  end
72
71
 
73
72
  it "renders the right template" do
74
- post :create, tag: attributes
73
+ post pulitzer.tags_path tag: attributes
75
74
  expect(response).to render_template('_show_wrapper')
76
75
  end
77
76
  end
@@ -84,26 +83,26 @@ describe Pulitzer::TagsController do
84
83
  end
85
84
 
86
85
  it "doesn't save the tag" do
87
- expect { post :create, tag: attributes }.not_to change { Pulitzer::Tag.count }
86
+ expect { post pulitzer.tags_path tag: attributes }.not_to change { Pulitzer::Tag.count }
88
87
  end
89
88
 
90
89
  it "renders the right template" do
91
- post :create, tag: attributes
90
+ post pulitzer.tags_path tag: attributes
92
91
  expect(response).to render_template("_new_flat")
93
92
  end
94
93
  end
95
94
  end
96
95
 
97
- describe "#edit" do
96
+ describe "#edit", type: :request do
98
97
  let(:tag) { create :tag }
99
98
 
100
99
  it "finds the right tag" do
101
- get :edit, id: tag.id
102
- expect(assigns[:tag]).to eq tag
100
+ get pulitzer.edit_tag_path id: tag.id
101
+ expect(response.body).to match(tag.name)
103
102
  end
104
103
 
105
104
  it "renders the right template" do
106
- get :edit, id: tag.id
105
+ get pulitzer.edit_tag_path id: tag.id
107
106
  expect(response).to render_template("_form")
108
107
  end
109
108
  end
@@ -148,7 +147,7 @@ describe Pulitzer::TagsController do
148
147
  end
149
148
  end
150
149
 
151
- describe "#destroy" do
150
+ describe "#destroy", type: :request do
152
151
  let(:tag) { create :tag }
153
152
  render_views
154
153
 
@@ -156,11 +155,11 @@ describe Pulitzer::TagsController do
156
155
 
157
156
  it "destroys the record" do
158
157
  expect(tag).to receive(:destroy)
159
- delete :destroy, id: tag.id
158
+ delete pulitzer.tag_path id: tag.id
160
159
  end
161
160
 
162
161
  it "renders nothing" do
163
- delete :destroy, id: tag.id
162
+ delete pulitzer.tag_path id: tag.id
164
163
  expect(response.body).to eq ""
165
164
  end
166
165
  end