alchemy_cms 3.1.3 → 3.2.0.beta

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 (110) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +2 -2
  3. data/.hound.yml +2 -0
  4. data/.rubocop.yml +1063 -0
  5. data/.travis.yml +14 -10
  6. data/Gemfile +4 -7
  7. data/README.md +16 -8
  8. data/alchemy_cms.gemspec +8 -7
  9. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +10 -11
  10. data/app/assets/javascripts/alchemy/alchemy.js +1 -1
  11. data/app/assets/stylesheets/alchemy/{admin.css.scss → admin.scss} +1 -0
  12. data/app/assets/stylesheets/alchemy/{icon-font.css.scss → icon-font.scss} +0 -0
  13. data/app/assets/stylesheets/alchemy/{menubar.css.scss → menubar.scss} +0 -0
  14. data/app/assets/stylesheets/alchemy/{print.css.scss → print.scss} +0 -0
  15. data/app/assets/stylesheets/alchemy/selects.scss +0 -6
  16. data/app/controllers/alchemy/admin/contents_controller.rb +3 -4
  17. data/app/controllers/alchemy/admin/pictures_controller.rb +0 -2
  18. data/app/controllers/alchemy/api/contents_controller.rb +1 -1
  19. data/app/controllers/alchemy/api/elements_controller.rb +2 -2
  20. data/app/controllers/alchemy/api/pages_controller.rb +1 -1
  21. data/app/controllers/alchemy/elements_controller.rb +0 -6
  22. data/app/controllers/alchemy/pages_controller.rb +17 -13
  23. data/app/controllers/alchemy/pictures_controller.rb +1 -0
  24. data/app/helpers/alchemy/admin/navigation_helper.rb +1 -1
  25. data/app/models/alchemy/element.rb +41 -17
  26. data/app/models/alchemy/page/page_naming.rb +16 -29
  27. data/bin/alchemy +1 -1
  28. data/config/routes.rb +1 -2
  29. data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -17
  30. data/lib/alchemy/capistrano.rb +3 -4
  31. data/lib/alchemy/controller_actions.rb +2 -1
  32. data/lib/alchemy/engine.rb +1 -0
  33. data/lib/alchemy/errors.rb +7 -0
  34. data/lib/alchemy/essence.rb +4 -4
  35. data/lib/alchemy/permissions.rb +1 -1
  36. data/lib/alchemy/shell.rb +26 -11
  37. data/lib/alchemy/test_support/controller_requests.rb +48 -12
  38. data/lib/alchemy/upgrader.rb +1 -0
  39. data/lib/alchemy/upgrader/three_point_one.rb +0 -1
  40. data/lib/alchemy/upgrader/three_point_two.rb +39 -0
  41. data/lib/alchemy/version.rb +1 -1
  42. data/lib/rails/templates/alchemy.rb +2 -2
  43. data/lib/tasks/alchemy/install.rake +2 -1
  44. data/spec/controllers/admin/attachments_controller_spec.rb +14 -14
  45. data/spec/controllers/admin/clipboard_controller_spec.rb +5 -5
  46. data/spec/controllers/admin/contents_controller_spec.rb +8 -14
  47. data/spec/controllers/admin/dashboard_controller_spec.rb +12 -12
  48. data/spec/controllers/admin/elements_controller_spec.rb +30 -31
  49. data/spec/controllers/admin/essence_files_controller_spec.rb +6 -6
  50. data/spec/controllers/admin/essence_pictures_controller_spec.rb +17 -17
  51. data/spec/controllers/admin/languages_controller_spec.rb +3 -3
  52. data/spec/controllers/admin/layoutpages_controller_spec.rb +3 -3
  53. data/spec/controllers/admin/pages_controller_spec.rb +48 -48
  54. data/spec/controllers/admin/pictures_controller_spec.rb +19 -19
  55. data/spec/controllers/admin/resources_controller_spec.rb +2 -2
  56. data/spec/controllers/admin/trash_controller_spec.rb +5 -5
  57. data/spec/controllers/alchemy/admin/tags_controller_spec.rb +5 -5
  58. data/spec/controllers/alchemy/api/contents_controller_spec.rb +46 -11
  59. data/spec/controllers/alchemy/api/elements_controller_spec.rb +42 -14
  60. data/spec/controllers/alchemy/api/pages_controller_spec.rb +26 -16
  61. data/spec/controllers/attachments_controller_spec.rb +7 -7
  62. data/spec/controllers/elements_controller_spec.rb +16 -19
  63. data/spec/controllers/messages_controller_spec.rb +15 -15
  64. data/spec/controllers/pages_controller_spec.rb +16 -25
  65. data/spec/controllers/pictures_controller_spec.rb +75 -49
  66. data/spec/dummy/Rakefile +1 -1
  67. data/spec/dummy/app/assets/stylesheets/application.css +5 -3
  68. data/spec/dummy/config/application.rb +11 -1
  69. data/spec/dummy/config/boot.rb +1 -1
  70. data/spec/dummy/config/environment.rb +1 -1
  71. data/spec/dummy/config/environments/development.rb +14 -2
  72. data/spec/dummy/config/environments/production.rb +18 -21
  73. data/spec/dummy/config/environments/test.rb +9 -4
  74. data/spec/dummy/config/initializers/assets.rb +11 -0
  75. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  76. data/spec/dummy/config/initializers/mime_types.rb +0 -1
  77. data/spec/dummy/config/initializers/session_store.rb +1 -1
  78. data/spec/dummy/config/secrets.yml +22 -0
  79. data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +380 -0
  80. data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +5 -0
  81. data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +5 -0
  82. data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +5 -0
  83. data/spec/dummy/db/migrate/20150122213511_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +31 -0
  84. data/{db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb → spec/dummy/db/migrate/20150122213512_add_missing_unique_indices.acts_as_taggable_on_engine.rb} +5 -6
  85. data/{db/migrate/20140701160159_add_taggings_counter_cache_to_tags.rb → spec/dummy/db/migrate/20150122213513_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb} +2 -1
  86. data/{db/migrate/20140701160225_add_missing_taggable_index.rb → spec/dummy/db/migrate/20150122213514_add_missing_taggable_index.acts_as_taggable_on_engine.rb} +1 -0
  87. data/spec/dummy/db/schema.rb +27 -31
  88. data/spec/dummy/public/404.html +20 -11
  89. data/spec/dummy/public/422.html +20 -11
  90. data/spec/dummy/public/500.html +19 -10
  91. data/spec/features/admin/page_creation_feature_spec.rb +2 -2
  92. data/spec/libraries/resource_spec.rb +1 -1
  93. data/spec/libraries/shell_spec.rb +2 -0
  94. data/spec/models/page_spec.rb +1 -13
  95. data/spec/spec_helper.rb +6 -4
  96. data/spec/support/rspec-activemodel-mocks_patch.rb +8 -0
  97. metadata +63 -56
  98. data/app/controllers/alchemy/contents_controller.rb +0 -18
  99. data/spec/controllers/contents_controller_spec.rb +0 -22
  100. data/spec/dummy/app/models/dummy_model.rb +0 -3
  101. data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -1
  102. data/spec/dummy/db/migrate/20130828121054_remove_do_not_index_from_alchemy_essence_texts.rb +0 -1
  103. data/spec/dummy/db/migrate/20130828121120_remove_do_not_index_from_alchemy_essence_richtexts.rb +0 -1
  104. data/spec/dummy/db/migrate/20130918201742_add_published_at_to_alchemy_pages.rb +0 -1
  105. data/spec/dummy/db/migrate/20140107192720_add_missing_unique_indices_to_tags_and_taggings.rb +0 -1
  106. data/spec/dummy/db/migrate/20140701160159_add_taggings_counter_cache_to_tags.rb +0 -1
  107. data/spec/dummy/db/migrate/20140701160225_add_missing_taggable_index.rb +0 -1
  108. data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +0 -7
  109. data/spec/dummy/spec/javascripts +0 -1
  110. data/spec/models/dummy_model_spec.rb +0 -11
@@ -15,7 +15,7 @@ module Alchemy
15
15
  end
16
16
 
17
17
  it 'should assign @essence_picture and @content instance variables' do
18
- post :edit, id: 1, content_id: 1
18
+ alchemy_post :edit, id: 1, content_id: 1
19
19
  expect(assigns(:essence_picture)).to be_a(EssencePicture)
20
20
  expect(assigns(:content)).to be_a(Content)
21
21
  end
@@ -32,7 +32,7 @@ module Alchemy
32
32
  end
33
33
 
34
34
  it "renders error message" do
35
- get :crop, id: 1
35
+ alchemy_get :crop, id: 1
36
36
  expect(assigns(:no_image_notice)).to eq(Alchemy::I18n.t(:no_image_for_cropper_found))
37
37
  end
38
38
  end
@@ -60,14 +60,14 @@ module Alchemy
60
60
 
61
61
  context 'with sizes in params' do
62
62
  it "sets sizes to given values" do
63
- get :crop, id: 1, options: {image_size: '300x250'}
63
+ alchemy_get :crop, id: 1, options: {image_size: '300x250'}
64
64
  expect(assigns(:min_size)).to eq({ width: 300, height: 250 })
65
65
  end
66
66
  end
67
67
 
68
68
  context 'with no sizes in params' do
69
69
  it "sets sizes to zero" do
70
- get :crop, id: 1
70
+ alchemy_get :crop, id: 1
71
71
  expect(assigns(:min_size)).to eq({ width: 0, height: 0 })
72
72
  end
73
73
  end
@@ -77,7 +77,7 @@ module Alchemy
77
77
  it "sets sizes from these values" do
78
78
  expect(essence).to receive(:render_size).at_least(:once).and_return('30x25')
79
79
 
80
- get :crop, id: 1
80
+ alchemy_get :crop, id: 1
81
81
  expect(assigns(:min_size)).to eq({ width: 30, height: 25 })
82
82
  end
83
83
 
@@ -85,14 +85,14 @@ module Alchemy
85
85
  it 'infers the height from the image file preserving the aspect ratio' do
86
86
  expect(essence).to receive(:render_size).at_least(:once).and_return('30x')
87
87
 
88
- get :crop, id: 1
88
+ alchemy_get :crop, id: 1
89
89
  expect(assigns(:min_size)).to eq({ width: 30, height: 0})
90
90
  end
91
91
 
92
92
  it 'does not infer the height from the image file preserving the aspect ratio' do
93
93
  expect(essence).to receive(:render_size).at_least(:once).and_return('x25')
94
94
 
95
- get :crop, id: 1, options: { fixed_ratio: "2"}
95
+ alchemy_get :crop, id: 1, options: { fixed_ratio: "2"}
96
96
  expect(assigns(:min_size)).to eq({ width: 50, height: 25 })
97
97
  end
98
98
  end
@@ -101,14 +101,14 @@ module Alchemy
101
101
  it 'width is given, it infers the height from width and ratio' do
102
102
  expect(essence).to receive(:render_size).at_least(:once).and_return('30x')
103
103
 
104
- get :crop, id: 1, options: { fixed_ratio: "0.5" }
104
+ alchemy_get :crop, id: 1, options: { fixed_ratio: "0.5" }
105
105
  expect(assigns(:min_size)).to eq({ width: 30, height: 60 })
106
106
  end
107
107
 
108
108
  it 'infers the height from the image file preserving the aspect ratio' do
109
109
  expect(essence).to receive(:render_size).at_least(:once).and_return('x25')
110
110
 
111
- get :crop, id: 1
111
+ alchemy_get :crop, id: 1
112
112
  expect(assigns(:min_size)).to eq({ width: 0, height: 25})
113
113
  end
114
114
  end
@@ -121,7 +121,7 @@ module Alchemy
121
121
  end
122
122
 
123
123
  it "assigns default mask boxes" do
124
- get :crop, id: 1
124
+ alchemy_get :crop, id: 1
125
125
  expect(assigns(:initial_box)).to eq(default_mask)
126
126
  expect(assigns(:default_box)).to eq(default_mask)
127
127
  end
@@ -137,7 +137,7 @@ module Alchemy
137
137
 
138
138
  it "assigns cropping boxes" do
139
139
  expect(essence).to receive(:cropping_mask).and_return(mask)
140
- get :crop, id: 1
140
+ alchemy_get :crop, id: 1
141
141
  expect(assigns(:initial_box)).to eq(mask)
142
142
  expect(assigns(:default_box)).to eq(default_mask)
143
143
  end
@@ -145,14 +145,14 @@ module Alchemy
145
145
 
146
146
  context 'with fixed_ratio set to false' do
147
147
  it "sets ratio to false" do
148
- get :crop, id: 1, options: {fixed_ratio: false}
148
+ alchemy_get :crop, id: 1, options: {fixed_ratio: false}
149
149
  expect(assigns(:ratio)).to eq(false)
150
150
  end
151
151
  end
152
152
 
153
153
  context 'with no fixed_ratio set in params' do
154
154
  it "sets a fixed ratio from sizes" do
155
- get :crop, id: 1, options: {image_size: '80x60'}
155
+ alchemy_get :crop, id: 1, options: {image_size: '80x60'}
156
156
  expect(assigns(:ratio)).to eq(80.0/60.0)
157
157
  end
158
158
  end
@@ -169,12 +169,12 @@ module Alchemy
169
169
 
170
170
  it "updates the essence attributes" do
171
171
  expect(essence).to receive(:update).and_return(true)
172
- xhr :put, :update, id: 1, essence_picture: attributes
172
+ alchemy_xhr :put, :update, id: 1, essence_picture: attributes
173
173
  end
174
174
 
175
175
  it "saves the cropping mask" do
176
176
  expect(essence).to receive(:update).and_return(true)
177
- xhr :put, :update, id: 1, essence_picture: {render_size: '1x1', crop_from: '0x0', crop_size: '100x100'}
177
+ alchemy_xhr :put, :update, id: 1, essence_picture: {render_size: '1x1', crop_from: '0x0', crop_size: '100x100'}
178
178
  end
179
179
  end
180
180
 
@@ -188,13 +188,13 @@ module Alchemy
188
188
  end
189
189
 
190
190
  it "should assign a Picture" do
191
- xhr :put, :assign, content_id: '1', picture_id: '1'
191
+ alchemy_xhr :put, :assign, content_id: '1', picture_id: '1'
192
192
  expect(assigns(:content).essence.picture).to eq(picture)
193
193
  end
194
194
 
195
195
  it "updates the content timestamp" do
196
196
  expect {
197
- xhr :put, :assign, content_id: '1', picture_id: '1'
197
+ alchemy_xhr :put, :assign, content_id: '1', picture_id: '1'
198
198
  }.to change(content, :updated_at)
199
199
  end
200
200
  end
@@ -19,7 +19,7 @@ describe Alchemy::Admin::LanguagesController do
19
19
  end
20
20
 
21
21
  it "uses it as page_layout-default for the new language" do
22
- get :new
22
+ alchemy_get :new
23
23
  expect(assigns(:language).page_layout).to eq("new_standard")
24
24
  end
25
25
  end
@@ -36,7 +36,7 @@ describe Alchemy::Admin::LanguagesController do
36
36
  end
37
37
 
38
38
  it "falls back to default database value." do
39
- get :new
39
+ alchemy_get :new
40
40
  expect(assigns(:language).page_layout).to eq("intro")
41
41
  end
42
42
  end
@@ -53,7 +53,7 @@ describe Alchemy::Admin::LanguagesController do
53
53
  end
54
54
 
55
55
  it "falls back to default database value." do
56
- get :new
56
+ alchemy_get :new
57
57
  expect(assigns(:language).page_layout).to eq("intro")
58
58
  end
59
59
  end
@@ -9,17 +9,17 @@ module Alchemy
9
9
 
10
10
  describe "#index" do
11
11
  it "should assign @locked_pages" do
12
- get :index
12
+ alchemy_get :index
13
13
  expect(assigns(:locked_pages)).to eq([])
14
14
  end
15
15
 
16
16
  it "should assign @layout_root" do
17
- get :index
17
+ alchemy_get :index
18
18
  expect(assigns(:layout_root)).to be_a(Page)
19
19
  end
20
20
 
21
21
  it "should assign @languages" do
22
- get :index
22
+ alchemy_get :index
23
23
  expect(assigns(:languages).first).to be_a(Language)
24
24
  end
25
25
  end
@@ -6,7 +6,7 @@ module Alchemy
6
6
 
7
7
  context 'a guest' do
8
8
  it 'can not access page tree' do
9
- get :index
9
+ alchemy_get :index
10
10
  expect(request).to redirect_to(Alchemy.login_path)
11
11
  end
12
12
  end
@@ -15,7 +15,7 @@ module Alchemy
15
15
  before { sign_in(member_user) }
16
16
 
17
17
  it 'can not access page tree' do
18
- get :index
18
+ alchemy_get :index
19
19
  expect(request).to redirect_to(root_path)
20
20
  end
21
21
  end
@@ -35,7 +35,7 @@ module Alchemy
35
35
  end
36
36
 
37
37
  it "assigns @page_root variable" do
38
- get :index
38
+ alchemy_get :index
39
39
  expect(assigns(:page_root)).to be(language_root)
40
40
  end
41
41
  end
@@ -49,7 +49,7 @@ module Alchemy
49
49
  end
50
50
 
51
51
  it "it assigns current language" do
52
- get :index
52
+ alchemy_get :index
53
53
  expect(assigns(:language)).to be(language)
54
54
  end
55
55
  end
@@ -67,7 +67,7 @@ module Alchemy
67
67
  it "should remove the cache of all pages" do
68
68
  expect(page_1).to receive(:publish!)
69
69
  expect(page_2).to receive(:publish!)
70
- xhr :post, :flush
70
+ alchemy_xhr :post, :flush
71
71
  end
72
72
  end
73
73
 
@@ -79,7 +79,7 @@ module Alchemy
79
79
  before { clipboard['pages'] = [{'id' => page.id.to_s, 'action' => 'copy'}] }
80
80
 
81
81
  it "should load all pages from clipboard" do
82
- xhr :get, :new, {page_id: page.id}
82
+ alchemy_xhr :get, :new, {page_id: page.id}
83
83
  expect(assigns(:clipboard_items)).to be_kind_of(Array)
84
84
  end
85
85
  end
@@ -94,23 +94,23 @@ module Alchemy
94
94
  end
95
95
 
96
96
  it "should assign @preview_mode with true" do
97
- get :show, id: page.id
97
+ alchemy_get :show, id: page.id
98
98
  expect(assigns(:preview_mode)).to eq(true)
99
99
  end
100
100
 
101
101
  it "should store page as current preview" do
102
102
  Page.current_preview = nil
103
- get :show, id: page.id
103
+ alchemy_get :show, id: page.id
104
104
  expect(Page.current_preview).to eq(page)
105
105
  end
106
106
 
107
107
  it "should set the I18n locale to the pages language code" do
108
- get :show, id: page.id
108
+ alchemy_get :show, id: page.id
109
109
  expect(::I18n.locale).to eq(:nl)
110
110
  end
111
111
 
112
112
  it "renders the application layout" do
113
- get :show, id: page.id
113
+ alchemy_get :show, id: page.id
114
114
  expect(response).to render_template(layout: 'application')
115
115
  end
116
116
  end
@@ -125,7 +125,7 @@ module Alchemy
125
125
  let(:set_of_pages) { [page_item_1] }
126
126
 
127
127
  it "stores the new order" do
128
- xhr :post, :order, set: set_of_pages.to_json
128
+ alchemy_xhr :post, :order, set: set_of_pages.to_json
129
129
  page_1.reload
130
130
  expect(page_1.descendants).to eq([page_2, page_3])
131
131
  end
@@ -136,7 +136,7 @@ module Alchemy
136
136
  end
137
137
 
138
138
  it "updates the pages urlnames" do
139
- xhr :post, :order, set: set_of_pages.to_json
139
+ alchemy_xhr :post, :order, set: set_of_pages.to_json
140
140
  [page_1, page_2, page_3].map(&:reload)
141
141
  expect(page_1.urlname).to eq("#{page_1.slug}")
142
142
  expect(page_2.urlname).to eq("#{page_1.slug}/#{page_2.slug}")
@@ -154,7 +154,7 @@ module Alchemy
154
154
  end
155
155
 
156
156
  it "does not use this pages slug in urlnames of descendants" do
157
- xhr :post, :order, set: set_of_pages.to_json
157
+ alchemy_xhr :post, :order, set: set_of_pages.to_json
158
158
  [page_1, page_2, page_3].map(&:reload)
159
159
  expect(page_1.urlname).to eq("#{page_1.slug}")
160
160
  expect(page_2.urlname).to eq("#{page_1.slug}/#{page_2.slug}")
@@ -173,7 +173,7 @@ module Alchemy
173
173
  end
174
174
 
175
175
  it "does not use this pages slug in urlnames of descendants" do
176
- xhr :post, :order, set: set_of_pages.to_json
176
+ alchemy_xhr :post, :order, set: set_of_pages.to_json
177
177
  [page_1, page_2, page_3].map(&:reload)
178
178
  expect(page_3.urlname).to eq("#{page_1.slug}/#{page_3.slug}")
179
179
  end
@@ -191,7 +191,7 @@ module Alchemy
191
191
  end
192
192
 
193
193
  it "updates restricted status of descendants" do
194
- xhr :post, :order, set: set_of_pages.to_json
194
+ alchemy_xhr :post, :order, set: set_of_pages.to_json
195
195
  page_3.reload
196
196
  expect(page_3.restricted).to be_truthy
197
197
  end
@@ -208,19 +208,19 @@ module Alchemy
208
208
 
209
209
  it "does not raise error" do
210
210
  expect {
211
- xhr :post, :order, set: set_of_pages.to_json
211
+ alchemy_xhr :post, :order, set: set_of_pages.to_json
212
212
  }.not_to raise_error
213
213
  end
214
214
 
215
215
  it "still generates the correct urlname on page_3" do
216
- xhr :post, :order, set: set_of_pages.to_json
216
+ alchemy_xhr :post, :order, set: set_of_pages.to_json
217
217
  [page_1, page_2, page_3].map(&:reload)
218
218
  expect(page_3.urlname).to eq("#{page_1.slug}/#{page_2.slug}/#{page_3.slug}")
219
219
  end
220
220
  end
221
221
 
222
222
  it "creates legacy urls" do
223
- xhr :post, :order, set: set_of_pages.to_json
223
+ alchemy_xhr :post, :order, set: set_of_pages.to_json
224
224
  [page_2, page_3].map(&:reload)
225
225
  expect(page_2.legacy_urls.size).to eq(1)
226
226
  expect(page_3.legacy_urls.size).to eq(1)
@@ -232,10 +232,10 @@ module Alchemy
232
232
  render_views
233
233
 
234
234
  context "with page having nested urlname" do
235
- let(:page) { create(:page, name: 'Foobar') }
235
+ let(:page) { create(:page, name: 'Foobar', urlname: 'foobar') }
236
236
 
237
237
  it "should always show the slug" do
238
- xhr :get, :configure, {id: page.id}
238
+ alchemy_xhr :get, :configure, {id: page.id}
239
239
  expect(response.body).to match /value="foobar"/
240
240
  end
241
241
  end
@@ -254,21 +254,21 @@ module Alchemy
254
254
 
255
255
  it "is nested under given parent" do
256
256
  allow(controller).to receive(:edit_admin_page_path).and_return('bla')
257
- xhr :post, :create, {page: page_params}
257
+ alchemy_xhr :post, :create, {page: page_params}
258
258
  expect(assigns(:page).parent_id).to eq(parent.id)
259
259
  end
260
260
 
261
261
  it "redirects to edit page template" do
262
262
  page = mock_model('Page')
263
263
  expect(controller).to receive(:edit_admin_page_path).and_return('bla')
264
- post :create, page: page_params
264
+ alchemy_post :create, page: page_params
265
265
  expect(response).to redirect_to('bla')
266
266
  end
267
267
 
268
268
  context "if new page can not be saved" do
269
269
  it "renders the create form" do
270
270
  allow_any_instance_of(Page).to receive(:save).and_return(false)
271
- post :create, page: {name: 'page'}
271
+ alchemy_post :create, page: {name: 'page'}
272
272
  expect(response).to render_template('new')
273
273
  end
274
274
  end
@@ -279,7 +279,7 @@ module Alchemy
279
279
  end
280
280
 
281
281
  it "should redirect to given url" do
282
- post :create, page: page_params, redirect_to: admin_pictures_path
282
+ alchemy_post :create, page: page_params, redirect_to: admin_pictures_path
283
283
  expect(response).to redirect_to(admin_pictures_path)
284
284
  end
285
285
 
@@ -288,7 +288,7 @@ module Alchemy
288
288
 
289
289
  it "should render the `new` template" do
290
290
  allow_any_instance_of(Page).to receive(:save).and_return(false)
291
- xhr :post, :create, page: {name: 'page'}, redirect_to: admin_pictures_path
291
+ alchemy_xhr :post, :create, page: {name: 'page'}, redirect_to: admin_pictures_path
292
292
  expect(response.body).to match /form.+action=\"\/admin\/pages\"/
293
293
  end
294
294
  end
@@ -297,7 +297,7 @@ module Alchemy
297
297
  context 'with page redirecting to external' do
298
298
  it "redirects to sitemap" do
299
299
  expect_any_instance_of(Page).to receive(:redirects_to_external?).and_return(true)
300
- post :create, page: page_params
300
+ alchemy_post :create, page: page_params
301
301
  expect(response).to redirect_to(admin_pages_path)
302
302
  end
303
303
  end
@@ -319,7 +319,7 @@ module Alchemy
319
319
  ).and_return(
320
320
  mock_model('Page', save: true, name: 'pasted Page', redirects_to_external?: false)
321
321
  )
322
- xhr :post, :create, {paste_from_clipboard: page_in_clipboard.id, page: {parent_id: parent.id, name: 'pasted Page'}}
322
+ alchemy_xhr :post, :create, {paste_from_clipboard: page_in_clipboard.id, page: {parent_id: parent.id, name: 'pasted Page'}}
323
323
  end
324
324
  end
325
325
  end
@@ -342,25 +342,25 @@ module Alchemy
342
342
 
343
343
  it "should copy the language root page over to the other language" do
344
344
  expect(Page).to receive(:copy).with(language_root_to_copy_from, {language_id: '2', language_code: 'it'})
345
- post :copy_language_tree, params
345
+ alchemy_post :copy_language_tree, params
346
346
  end
347
347
 
348
348
  it "should move the newly created language-root-page below the absolute root page" do
349
349
  expect(copy_of_language_root).to receive(:move_to_child_of).with(root_page)
350
- post :copy_language_tree, params
350
+ alchemy_post :copy_language_tree, params
351
351
  end
352
352
 
353
353
  it "should copy all childs of the original page over to the new created one" do
354
354
  expect(controller).to receive(:language_root_to_copy_from).and_return(language_root_to_copy_from)
355
355
  expect(controller).to receive(:copy_of_language_root).and_return(copy_of_language_root)
356
356
  expect(language_root_to_copy_from).to receive(:copy_children_to).with(copy_of_language_root)
357
- post :copy_language_tree, params
357
+ alchemy_post :copy_language_tree, params
358
358
  end
359
359
 
360
360
  it "should redirect to admin_pages_path" do
361
361
  allow(controller).to receive(:copy_of_language_root)
362
362
  allow(controller).to receive(:language_root_to_copy_from).and_return(double(copy_children_to: nil))
363
- post :copy_language_tree, params
363
+ alchemy_post :copy_language_tree, params
364
364
  expect(response).to redirect_to(admin_pages_path)
365
365
  end
366
366
  end
@@ -378,7 +378,7 @@ module Alchemy
378
378
  end
379
379
 
380
380
  it 'redirects to sitemap' do
381
- get :edit, id: page.id
381
+ alchemy_get :edit, id: page.id
382
382
  expect(response).to redirect_to(admin_pages_path)
383
383
  end
384
384
  end
@@ -389,7 +389,7 @@ module Alchemy
389
389
  end
390
390
 
391
391
  it 'renders the edit view' do
392
- get :edit, id: page.id
392
+ alchemy_get :edit, id: page.id
393
393
  expect(response).to render_template(:edit)
394
394
  end
395
395
  end
@@ -402,7 +402,7 @@ module Alchemy
402
402
  end
403
403
 
404
404
  it 'renders the edit view' do
405
- get :edit, id: page.id
405
+ alchemy_get :edit, id: page.id
406
406
  expect(response).to render_template(:edit)
407
407
  end
408
408
  end
@@ -413,13 +413,13 @@ module Alchemy
413
413
  end
414
414
 
415
415
  it 'renders the edit view' do
416
- get :edit, id: page.id
416
+ alchemy_get :edit, id: page.id
417
417
  expect(response).to render_template(:edit)
418
418
  end
419
419
 
420
420
  it "lockes the page to myself" do
421
421
  expect_any_instance_of(Page).to receive(:lock_to!)
422
- get :edit, id: page.id
422
+ alchemy_get :edit, id: page.id
423
423
  end
424
424
  end
425
425
  end
@@ -431,7 +431,7 @@ module Alchemy
431
431
  before { clipboard['pages'] = [{'id' => page.id.to_s}] }
432
432
 
433
433
  it "should also remove the page from clipboard" do
434
- xhr :post, :destroy, {id: page.id, _method: :delete}
434
+ alchemy_xhr :post, :destroy, {id: page.id, _method: :delete}
435
435
  expect(clipboard['pages']).to be_empty
436
436
  end
437
437
  end
@@ -446,7 +446,7 @@ module Alchemy
446
446
 
447
447
  it "should publish the page" do
448
448
  expect(page).to receive(:publish!)
449
- post :publish, { id: page.id }
449
+ alchemy_post :publish, { id: page.id }
450
450
  end
451
451
  end
452
452
 
@@ -460,7 +460,7 @@ module Alchemy
460
460
  end
461
461
 
462
462
  it "should redirect to the page path" do
463
- expect(post :visit, id: page.id).to redirect_to(show_page_path(urlname: 'home'))
463
+ expect(alchemy_post :visit, id: page.id).to redirect_to(show_page_path(urlname: 'home'))
464
464
  end
465
465
  end
466
466
 
@@ -473,7 +473,7 @@ module Alchemy
473
473
 
474
474
  it "should fold the page" do
475
475
  expect(page).to receive(:fold!).with(user.id, true).and_return(true)
476
- xhr :post, :fold, id: page.id
476
+ alchemy_xhr :post, :fold, id: page.id
477
477
  end
478
478
  end
479
479
 
@@ -482,7 +482,7 @@ module Alchemy
482
482
 
483
483
  it "should unfold the page" do
484
484
  expect(page).to receive(:fold!).with(user.id, false).and_return(true)
485
- xhr :post, :fold, id: page.id
485
+ alchemy_xhr :post, :fold, id: page.id
486
486
  end
487
487
  end
488
488
  end
@@ -491,7 +491,7 @@ module Alchemy
491
491
  before { allow(Page).to receive(:language_root_for).and_return(mock_model(Alchemy::Page)) }
492
492
 
493
493
  it "should assign @sorting with true" do
494
- xhr :get, :sort
494
+ alchemy_xhr :get, :sort
495
495
  expect(assigns(:sorting)).to eq(true)
496
496
  end
497
497
  end
@@ -506,17 +506,17 @@ module Alchemy
506
506
  end
507
507
 
508
508
  it "should unlock the page" do
509
- xhr :post, :unlock, id: "#{page.id}"
509
+ alchemy_xhr :post, :unlock, id: "#{page.id}"
510
510
  end
511
511
 
512
512
  context 'requesting for html format' do
513
513
  it "should redirect to admin_pages_path" do
514
- expect(post :unlock, id: page.id).to redirect_to(admin_pages_path)
514
+ expect(alchemy_post :unlock, id: page.id).to redirect_to(admin_pages_path)
515
515
  end
516
516
 
517
517
  context 'if passing :redirect_to through params' do
518
518
  it "should redirect to the given path" do
519
- expect(post :unlock, id: page.id, redirect_to: 'this/path').to redirect_to('this/path')
519
+ expect(alchemy_post :unlock, id: page.id, redirect_to: 'this/path').to redirect_to('this/path')
520
520
  end
521
521
  end
522
522
  end
@@ -530,12 +530,12 @@ module Alchemy
530
530
  end
531
531
 
532
532
  it "should store the current language in session" do
533
- get :switch_language, {language_id: language.id}
533
+ alchemy_get :switch_language, {language_id: language.id}
534
534
  expect(session[:alchemy_language_id]).to eq(language.id)
535
535
  end
536
536
 
537
537
  it "should redirect to sitemap" do
538
- expect(get :switch_language, {language_id: language.id}).to redirect_to(admin_pages_path)
538
+ expect(alchemy_get :switch_language, {language_id: language.id}).to redirect_to(admin_pages_path)
539
539
  end
540
540
 
541
541
  context "coming from layoutpages" do
@@ -544,7 +544,7 @@ module Alchemy
544
544
  }
545
545
 
546
546
  it "should redirect to layoutpages" do
547
- expect(get :switch_language, {language_id: language.id}).to redirect_to(admin_layoutpages_path)
547
+ expect(alchemy_get :switch_language, {language_id: language.id}).to redirect_to(admin_layoutpages_path)
548
548
  end
549
549
  end
550
550
  end