alchemy_cms 3.1.3 → 3.2.0.beta

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -18,13 +18,13 @@ module Alchemy
18
18
 
19
19
  describe "#insert" do
20
20
  it "should hold element ids" do
21
- xhr :post, :insert, {remarkable_type: 'elements', remarkable_id: element.id}
21
+ alchemy_xhr :post, :insert, {remarkable_type: 'elements', remarkable_id: element.id}
22
22
  expect(session[:alchemy_clipboard]['elements']).to eq([{'id' => element.id.to_s, 'action' => 'copy'}])
23
23
  end
24
24
 
25
25
  it "should not have the same element twice" do
26
26
  session[:alchemy_clipboard]['elements'] = [{'id' => element.id.to_s, 'action' => 'copy'}]
27
- xhr :post, :insert, {remarkable_type: 'elements', remarkable_id: element.id}
27
+ alchemy_xhr :post, :insert, {remarkable_type: 'elements', remarkable_id: element.id}
28
28
  expect(session[:alchemy_clipboard]['elements'].collect { |e| e['id'] }).not_to eq([element.id, element.id])
29
29
  end
30
30
  end
@@ -33,7 +33,7 @@ module Alchemy
33
33
  it "should remove element ids from clipboard" do
34
34
  session[:alchemy_clipboard]['elements'] = [{'id' => element.id.to_s, 'action' => 'copy'}]
35
35
  session[:alchemy_clipboard]['elements'] << {'id' => another_element.id.to_s, 'action' => 'copy'}
36
- xhr :delete, :remove, {remarkable_type: 'elements', remarkable_id: another_element.id}
36
+ alchemy_xhr :delete, :remove, {remarkable_type: 'elements', remarkable_id: another_element.id}
37
37
  expect(session[:alchemy_clipboard]['elements']).to eq([{'id' => element.id.to_s, 'action' => 'copy'}])
38
38
  end
39
39
  end
@@ -43,7 +43,7 @@ module Alchemy
43
43
  context "with elements as remarkable_type" do
44
44
  it "should clear the elements clipboard" do
45
45
  session[:alchemy_clipboard]['elements'] = [{'id' => element.id.to_s}]
46
- xhr :delete, :clear, {remarkable_type: 'elements'}
46
+ alchemy_xhr :delete, :clear, {remarkable_type: 'elements'}
47
47
  expect(session[:alchemy_clipboard]['elements']).to be_empty
48
48
  end
49
49
  end
@@ -51,7 +51,7 @@ module Alchemy
51
51
  context "with pages as remarkable_type" do
52
52
  it "should clear the pages clipboard" do
53
53
  session[:alchemy_clipboard]['pages'] = [{'id' => public_page.id.to_s}]
54
- xhr :delete, :clear, {remarkable_type: 'pages'}
54
+ alchemy_xhr :delete, :clear, {remarkable_type: 'pages'}
55
55
  expect(session[:alchemy_clipboard]['pages']).to be_empty
56
56
  end
57
57
  end
@@ -19,12 +19,12 @@ module Alchemy
19
19
 
20
20
  it "creates a content from name" do
21
21
  expect(Content).to receive(:create_from_scratch).and_return(content)
22
- xhr :post, :create, {content: {element_id: element.id, name: 'headline'}}
22
+ alchemy_xhr :post, :create, {content: {element_id: element.id, name: 'headline'}}
23
23
  end
24
24
 
25
25
  it "creates a content from essence_type" do
26
26
  expect(Content).to receive(:create_from_scratch).and_return(content)
27
- xhr :post, :create, {content: {element_id: element.id, essence_type: 'EssencePicture'}}
27
+ alchemy_xhr :post, :create, {content: {element_id: element.id, essence_type: 'EssencePicture'}}
28
28
  end
29
29
  end
30
30
 
@@ -34,14 +34,14 @@ module Alchemy
34
34
  end
35
35
 
36
36
  it "adds it into the gallery editor" do
37
- xhr :post, :create, attributes
37
+ alchemy_xhr :post, :create, attributes
38
38
  expect(assigns(:content_dom_id)).to eq("#add_picture_#{element.id}")
39
39
  end
40
40
 
41
41
  context 'with picture_id given' do
42
42
  it "assigns the picture" do
43
43
  expect_any_instance_of(Content).to receive(:update_essence).with(picture_id: '1')
44
- xhr :post, :create, attributes.merge(picture_id: '1')
44
+ alchemy_xhr :post, :create, attributes.merge(picture_id: '1')
45
45
  end
46
46
  end
47
47
  end
@@ -54,23 +54,17 @@ module Alchemy
54
54
 
55
55
  it "should update a content via ajax" do
56
56
  expect(content.essence).to receive(:update).with('ingredient' => 'Peters Petshop')
57
- xhr :post, :update, {id: content.id, content: {ingredient: 'Peters Petshop'}}
57
+ alchemy_xhr :post, :update, {id: content.id, content: {ingredient: 'Peters Petshop'}}
58
58
  end
59
59
  end
60
60
 
61
61
  describe "#order" do
62
62
  context "with content_ids in params" do
63
- let(:element) do
64
- create(:element, name: 'all_you_can_eat', create_contents_after_create: true)
65
- end
66
-
67
- let(:content_ids) { element.contents.pluck(:id).shuffle }
68
-
69
63
  it "should reorder the contents" do
70
- xhr :post, :order, {content_ids: content_ids}
71
-
64
+ content_ids = element.contents.essence_texts.pluck(:id)
65
+ alchemy_xhr :post, :order, {content_ids: content_ids.reverse}
72
66
  expect(response.status).to eq(200)
73
- expect(element.contents(true).pluck(:id)).to eq(content_ids)
67
+ expect(element.contents.essence_texts.pluck(:id)).to eq(content_ids.reverse)
74
68
  end
75
69
  end
76
70
  end
@@ -13,12 +13,12 @@ module Alchemy
13
13
  end
14
14
 
15
15
  it "assigns @last_edited_pages" do
16
- get :index
16
+ alchemy_get :index
17
17
  expect(assigns(:last_edited_pages)).to eq([])
18
18
  end
19
19
 
20
20
  it "assigns @locked_pages" do
21
- get :index
21
+ alchemy_get :index
22
22
  expect(assigns(:locked_pages)).to eq([])
23
23
  end
24
24
 
@@ -31,14 +31,14 @@ module Alchemy
31
31
  end
32
32
 
33
33
  it "assigns @online_users" do
34
- get :index
34
+ alchemy_get :index
35
35
  expect(assigns(:online_users)).to eq([another_user])
36
36
  end
37
37
  end
38
38
 
39
39
  context 'without other users online' do
40
40
  it "does not assign @online_users" do
41
- get :index
41
+ alchemy_get :index
42
42
  expect(assigns(:online_users)).to eq([])
43
43
  end
44
44
  end
@@ -51,20 +51,20 @@ module Alchemy
51
51
  end
52
52
 
53
53
  it "assigns @first_time" do
54
- get :index
54
+ alchemy_get :index
55
55
  expect(assigns(:first_time)).to eq(false)
56
56
  end
57
57
  end
58
58
 
59
59
  it "assigns @sites" do
60
- get :index
60
+ alchemy_get :index
61
61
  expect(assigns(:sites)).to eq(Site.all)
62
62
  end
63
63
  end
64
64
 
65
65
  describe '#info' do
66
66
  it "assigns @alchemy_version with the current Alchemy version" do
67
- get :info
67
+ alchemy_get :info
68
68
  expect(assigns(:alchemy_version)).to eq(Alchemy.version)
69
69
  end
70
70
  end
@@ -77,7 +77,7 @@ module Alchemy
77
77
  }
78
78
 
79
79
  it "should render 'false'" do
80
- get :update_check
80
+ alchemy_get :update_check
81
81
  expect(response.body).to eq('false')
82
82
  end
83
83
  end
@@ -89,7 +89,7 @@ module Alchemy
89
89
  }
90
90
 
91
91
  it "should render 'true'" do
92
- get :update_check
92
+ alchemy_get :update_check
93
93
  expect(response.body).to eq('true')
94
94
  end
95
95
  end
@@ -103,7 +103,7 @@ module Alchemy
103
103
  }
104
104
 
105
105
  it "should have response code of 200" do
106
- get :update_check
106
+ alchemy_get :update_check
107
107
  expect(response.code).to eq('200')
108
108
  end
109
109
  end
@@ -117,7 +117,7 @@ module Alchemy
117
117
  }
118
118
 
119
119
  it "should have response code of 200" do
120
- get :update_check
120
+ alchemy_get :update_check
121
121
  expect(response.code).to eq('200')
122
122
  end
123
123
  end
@@ -130,7 +130,7 @@ module Alchemy
130
130
  }
131
131
 
132
132
  it "should have status code 503" do
133
- get :update_check
133
+ alchemy_get :update_check
134
134
  expect(response.code).to eq('503')
135
135
  end
136
136
  end
@@ -25,7 +25,7 @@ module Alchemy
25
25
 
26
26
  it "groups elements by cell" do
27
27
  expect(alchemy_page).to receive(:elements_grouped_by_cells)
28
- get :index, {page_id: alchemy_page.id}
28
+ alchemy_get :index, {page_id: alchemy_page.id}
29
29
  expect(assigns(:cells)).to eq([cell])
30
30
  end
31
31
  end
@@ -37,25 +37,24 @@ module Alchemy
37
37
 
38
38
  it "assigns page elements" do
39
39
  expect(alchemy_page).to receive(:elements).and_return(double(not_trashed: []))
40
- get :index, {page_id: alchemy_page.id}
40
+ alchemy_get :index, {page_id: alchemy_page.id}
41
41
  end
42
42
  end
43
43
  end
44
44
 
45
45
  describe '#list' do
46
- let(:alchemy_page) { build_stubbed(:page) }
47
-
48
46
  context 'without page_id, but with page_urlname' do
49
47
  it "loads page from urlname" do
50
- expect(Language).to receive(:current).at_least(:once).and_return(double(code: 'en', pages: double(find_by: double(id: 1001))))
51
- xhr :get, :list, {page_urlname: 'contact'}
48
+ expect {
49
+ alchemy_xhr :get, :list, {page_urlname: alchemy_page.urlname}
50
+ }.to_not raise_error
52
51
  end
53
52
 
54
53
  describe 'view' do
55
54
  render_views
56
55
 
57
56
  it "should return a select tag with elements" do
58
- xhr :get, :list, {page_urlname: alchemy_page.urlname}
57
+ alchemy_xhr :get, :list, {page_urlname: alchemy_page.urlname}
59
58
  expect(response.body).to match(/select(.*)elements_from_page_selector(.*)option/)
60
59
  end
61
60
  end
@@ -63,7 +62,7 @@ module Alchemy
63
62
 
64
63
  context 'with page_id' do
65
64
  it "loads page from urlname" do
66
- xhr :get, :list, {page_id: alchemy_page.id}
65
+ alchemy_xhr :get, :list, {page_id: alchemy_page.id}
67
66
  expect(assigns(:page_id)).to eq(alchemy_page.id.to_s)
68
67
  end
69
68
  end
@@ -76,7 +75,7 @@ module Alchemy
76
75
  let(:element_ids) { [element_1.id, element_3.id, element_2.id] }
77
76
 
78
77
  it "sets new position for given element ids" do
79
- xhr :post, :order, element_ids: element_ids
78
+ alchemy_xhr :post, :order, element_ids: element_ids
80
79
  expect(Element.all.pluck(:id)).to eq(element_ids)
81
80
  end
82
81
 
@@ -89,24 +88,24 @@ module Alchemy
89
88
  end
90
89
 
91
90
  it "sets a list of trashed element ids" do
92
- xhr :post, :order, element_ids: [trashed_element.id]
91
+ alchemy_xhr :post, :order, element_ids: [trashed_element.id]
93
92
  expect(assigns(:trashed_elements).to_a).to eq [trashed_element.id]
94
93
  end
95
94
 
96
95
  it "sets a new position to the element" do
97
- xhr :post, :order, element_ids: [trashed_element.id]
96
+ alchemy_xhr :post, :order, element_ids: [trashed_element.id]
98
97
  trashed_element.reload
99
98
  expect(trashed_element.position).to_not be_nil
100
99
  end
101
100
 
102
101
  it "should assign the (new) page_id to the element" do
103
- xhr :post, :order, element_ids: [trashed_element.id], page_id: 1, cell_id: nil
102
+ alchemy_xhr :post, :order, element_ids: [trashed_element.id], page_id: 1, cell_id: nil
104
103
  trashed_element.reload
105
104
  expect(trashed_element.page_id).to be 1
106
105
  end
107
106
 
108
107
  it "should assign the (new) cell_id to the element" do
109
- xhr :post, :order, element_ids: [trashed_element.id], page_id: 1, cell_id: 5
108
+ alchemy_xhr :post, :order, element_ids: [trashed_element.id], page_id: 1, cell_id: 5
110
109
  trashed_element.reload
111
110
  expect(trashed_element.cell_id).to be 5
112
111
  end
@@ -122,7 +121,7 @@ module Alchemy
122
121
 
123
122
  it "assign variable for all available element definitions" do
124
123
  expect(alchemy_page).to receive(:available_element_definitions)
125
- get :new, {page_id: alchemy_page.id}
124
+ alchemy_get :new, {page_id: alchemy_page.id}
126
125
  end
127
126
 
128
127
  context "with elements in clipboard" do
@@ -132,7 +131,7 @@ module Alchemy
132
131
 
133
132
  it "should load all elements from clipboard" do
134
133
  expect(Element).to receive(:all_from_clipboard_for_page).and_return(clipboard_items)
135
- get :new, {page_id: alchemy_page.id}
134
+ alchemy_get :new, {page_id: alchemy_page.id}
136
135
  expect(assigns(:clipboard_items)).to eq(clipboard_items)
137
136
  end
138
137
  end
@@ -143,7 +142,7 @@ module Alchemy
143
142
  before { element }
144
143
 
145
144
  it "should insert the element at bottom of list" do
146
- xhr :post, :create, {element: {name: 'news', page_id: alchemy_page.id}}
145
+ alchemy_xhr :post, :create, {element: {name: 'news', page_id: alchemy_page.id}}
147
146
  expect(alchemy_page.elements.count).to eq(2)
148
147
  expect(alchemy_page.elements.last.name).to eq('news')
149
148
  end
@@ -158,7 +157,7 @@ module Alchemy
158
157
  end
159
158
 
160
159
  it "should insert the element at top of list" do
161
- xhr :post, :create, {element: {name: 'news', page_id: alchemy_page.id}}
160
+ alchemy_xhr :post, :create, {element: {name: 'news', page_id: alchemy_page.id}}
162
161
  expect(alchemy_page.elements.count).to eq(2)
163
162
  expect(alchemy_page.elements.first.name).to eq('news')
164
163
  end
@@ -184,14 +183,14 @@ module Alchemy
184
183
  end
185
184
 
186
185
  it "should put the element in the correct cell" do
187
- xhr :post, :create, {element: {name: "article#header", page_id: page.id}}
186
+ alchemy_xhr :post, :create, {element: {name: "article#header", page_id: page.id}}
188
187
  expect(cell.elements.first).to be_an_instance_of(Element)
189
188
  end
190
189
  end
191
190
 
192
191
  context "and no cell name in element name" do
193
192
  it "should put the element in the main cell" do
194
- xhr :post, :create, {element: {name: "article", page_id: page.id}}
193
+ alchemy_xhr :post, :create, {element: {name: "article", page_id: page.id}}
195
194
  expect(page.elements.not_in_cell.first).to be_an_instance_of(Element)
196
195
  end
197
196
  end
@@ -217,7 +216,7 @@ module Alchemy
217
216
  end
218
217
 
219
218
  it "should create the element in the correct cell" do
220
- xhr :post, :create, {element: {page_id: page.id}, paste_from_clipboard: "#{element_in_clipboard.id}##{cell.name}"}
219
+ alchemy_xhr :post, :create, {element: {page_id: page.id}, paste_from_clipboard: "#{element_in_clipboard.id}##{cell.name}"}
221
220
  expect(cell.elements.first).to be_an_instance_of(Element)
222
221
  end
223
222
 
@@ -227,7 +226,7 @@ module Alchemy
227
226
  end
228
227
 
229
228
  it "should set the correct position for the element" do
230
- xhr :post, :create, {element: {page_id: page.id}, paste_from_clipboard: "#{element_in_clipboard.id}##{cell.name}"}
229
+ alchemy_xhr :post, :create, {element: {page_id: page.id}, paste_from_clipboard: "#{element_in_clipboard.id}##{cell.name}"}
231
230
  expect(cell.elements.last.position).to eq(cell.elements.count)
232
231
  end
233
232
  end
@@ -235,7 +234,7 @@ module Alchemy
235
234
 
236
235
  context "and no cell name in element name" do
237
236
  it "should create the element in the nil cell" do
238
- xhr :post, :create, {element: {page_id: page.id}, paste_from_clipboard: "#{element_in_clipboard.id}"}
237
+ alchemy_xhr :post, :create, {element: {page_id: page.id}, paste_from_clipboard: "#{element_in_clipboard.id}"}
239
238
  expect(page.elements.first.cell).to eq(nil)
240
239
  end
241
240
  end
@@ -263,7 +262,7 @@ module Alchemy
263
262
  end
264
263
 
265
264
  it "should insert the element at top of list" do
266
- xhr :post, :create, {element: {name: 'news', page_id: alchemy_page.id}, paste_from_clipboard: "#{element_in_clipboard.id}##{cell.name}"}
265
+ alchemy_xhr :post, :create, {element: {name: 'news', page_id: alchemy_page.id}, paste_from_clipboard: "#{element_in_clipboard.id}##{cell.name}"}
267
266
  expect(cell.elements.count).to eq(2)
268
267
  expect(cell.elements.first.name).to eq('news')
269
268
  expect(cell.elements.first).not_to eq(element)
@@ -280,21 +279,21 @@ module Alchemy
280
279
  end
281
280
 
282
281
  it "should create an element from clipboard" do
283
- xhr :post, :create, {paste_from_clipboard: element_in_clipboard.id, element: {page_id: alchemy_page.id}}
282
+ alchemy_xhr :post, :create, {paste_from_clipboard: element_in_clipboard.id, element: {page_id: alchemy_page.id}}
284
283
  expect(response.status).to eq(200)
285
284
  expect(response.body).to match(/Successfully added new element/)
286
285
  end
287
286
 
288
287
  context "and with cut as action parameter" do
289
288
  it "should also remove the element id from clipboard" do
290
- xhr :post, :create, {paste_from_clipboard: element_in_clipboard.id, element: {page_id: alchemy_page.id}}
289
+ alchemy_xhr :post, :create, {paste_from_clipboard: element_in_clipboard.id, element: {page_id: alchemy_page.id}}
291
290
  expect(session[:alchemy_clipboard]['elements'].detect { |item| item['id'] == element_in_clipboard.id.to_s }).to be_nil
292
291
  end
293
292
  end
294
293
  end
295
294
 
296
295
  context 'if element could not be saved' do
297
- subject { post :create, {element: {page_id: alchemy_page.id}} }
296
+ subject { alchemy_post :create, {element: {page_id: alchemy_page.id}} }
298
297
 
299
298
  before do
300
299
  expect_any_instance_of(Element).to receive(:save).and_return false
@@ -376,20 +375,20 @@ module Alchemy
376
375
 
377
376
  it "updates all contents in element" do
378
377
  expect(element).to receive(:update_contents).with(contents_parameters)
379
- xhr :put, :update, {id: element.id}
378
+ alchemy_xhr :put, :update, {id: element.id}
380
379
  end
381
380
 
382
381
  it "updates the element" do
383
382
  expect(controller).to receive(:element_params).and_return(element_parameters)
384
383
  expect(element).to receive(:update_contents).and_return(true)
385
384
  expect(element).to receive(:update_attributes!).with(element_parameters).and_return(true)
386
- xhr :put, :update, {id: element.id}
385
+ alchemy_xhr :put, :update, {id: element.id}
387
386
  end
388
387
 
389
388
  context "failed validations" do
390
389
  it "displays validation failed notice" do
391
390
  expect(element).to receive(:update_contents).and_return(false)
392
- xhr :put, :update, {id: element.id}
391
+ alchemy_xhr :put, :update, {id: element.id}
393
392
  expect(assigns(:element_validated)).to be_falsey
394
393
  end
395
394
  end
@@ -430,7 +429,7 @@ module Alchemy
430
429
  end
431
430
 
432
431
  describe '#trash' do
433
- subject { xhr :delete, :trash, {id: element.id} }
432
+ subject { alchemy_xhr :delete, :trash, {id: element.id} }
434
433
 
435
434
  let(:element) { build_stubbed(:element) }
436
435
 
@@ -443,7 +442,7 @@ module Alchemy
443
442
  end
444
443
 
445
444
  describe '#fold' do
446
- subject { xhr :post, :fold, {id: element.id} }
445
+ subject { alchemy_xhr :post, :fold, {id: element.id} }
447
446
 
448
447
  let(:element) { build_stubbed(:element) }
449
448
 
@@ -18,12 +18,12 @@ module Alchemy
18
18
  end
19
19
 
20
20
  it "assigns @essence_file with the EssenceFile found by id" do
21
- get :edit, id: essence_file.id
21
+ alchemy_get :edit, id: essence_file.id
22
22
  expect(assigns(:essence_file)).to eq(essence_file)
23
23
  end
24
24
 
25
25
  it "should assign @content with essence_file's content" do
26
- get :edit, id: essence_file.id
26
+ alchemy_get :edit, id: essence_file.id
27
27
  expect(assigns(:content)).to eq(content)
28
28
  end
29
29
  end
@@ -36,7 +36,7 @@ module Alchemy
36
36
  end
37
37
 
38
38
  it "should update the attributes of essence_file" do
39
- xhr :put, :update, id: essence_file.id, essence_file: {title: 'new title', css_class: 'left'}
39
+ alchemy_xhr :put, :update, id: essence_file.id, essence_file: {title: 'new title', css_class: 'left'}
40
40
  expect(essence_file.title).to eq 'new title'
41
41
  expect(essence_file.css_class).to eq 'left'
42
42
  end
@@ -52,18 +52,18 @@ module Alchemy
52
52
  end
53
53
 
54
54
  it "should assign @attachment with the Attachment found by attachment_id" do
55
- xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
55
+ alchemy_xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
56
56
  expect(assigns(:attachment)).to eq(attachment)
57
57
  end
58
58
 
59
59
  it "should assign @content.essence.attachment with the attachment found by id" do
60
60
  expect(content.essence).to receive(:attachment=).with(attachment)
61
- xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
61
+ alchemy_xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
62
62
  end
63
63
 
64
64
  it "updates the @content.updated_at column" do
65
65
  expect {
66
- xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
66
+ alchemy_xhr :put, :assign, content_id: content.id, attachment_id: attachment.id
67
67
  }.to change(content, :updated_at)
68
68
  end
69
69
  end