alchemy_cms 3.1.0.beta6 → 3.1.0.rc1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee349e3c1603a85fa273cfbb168e88190db26c8f
4
- data.tar.gz: c3288e7a9f128291320f6646dd41ab78f65f23ea
3
+ metadata.gz: 90a343fa98a444500a06cfbaa172e6bb8c6b4856
4
+ data.tar.gz: fc1c96763f1a10a0938f54057b5bdc04f81dc002
5
5
  SHA512:
6
- metadata.gz: a4b86afe18307827a65c0ecff2894ac39df62a39430d8c9da38d455a49ace528caf9a94b0b91b7e93477a2188ea407c21c700f161ac067e11b26411481f6e5f1
7
- data.tar.gz: 52dcf130529e8494da6e49babc0ab1bed1ce6e752aea27aaadce37081dee615892f62c4f5ff4cccd3ae00bf32de1ea4e7b001beb848ca08f6d022428a91a1d44
6
+ metadata.gz: 910b2641a2a94dfd31289b4f3d41f13e5b02f2ae1e543a1f4dc30627c9451500c9e34510058be064fa53de2c576b9bd770ed07f479bc69c0323b479e97c5fa92
7
+ data.tar.gz: f05aac4f401eb397193dbb5a07a22e279fdb2cae66165b8ca7033e0f2415074f42d0d91e12588c2e44d8f7b2108fa25e1f3fbc62d7e7ce696cff23097778688c
@@ -269,7 +269,8 @@ module Alchemy
269
269
  def update_contents(contents_attributes)
270
270
  return true if contents_attributes.nil?
271
271
  contents.each do |content|
272
- content.update_essence(contents_attributes["#{content.id}"]) || errors.add(:base, :essence_validation_failed)
272
+ content_hash = contents_attributes["#{content.id}"] || next
273
+ content.update_essence(content_hash) || errors.add(:base, :essence_validation_failed)
273
274
  end
274
275
  errors.blank?
275
276
  end
@@ -1,3 +1,5 @@
1
+ require 'rails'
2
+
1
3
  module Alchemy
2
4
 
3
5
  # Utilities for Alchemy's mount point in the host rails app.
@@ -34,7 +36,11 @@ module Alchemy
34
36
  private
35
37
 
36
38
  def routes_file_path
37
- Rails.root.join('config/routes.rb')
39
+ if Rails.root
40
+ Rails.root.join('config/routes.rb')
41
+ else
42
+ 'config/routes.rb'
43
+ end
38
44
  end
39
45
  end
40
46
  end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
- VERSION = "3.1.0.beta6"
2
+ VERSION = "3.1.0.rc1"
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -411,11 +411,12 @@ module Alchemy
411
411
  describe '#update_contents' do
412
412
  subject { element.update_contents(params) }
413
413
 
414
- let(:page) { build_stubbed(:page) }
415
- let(:element) { build_stubbed(:element, page: page) }
416
- let(:content) { double(:content, id: 1) }
414
+ let(:page) { build_stubbed(:page) }
415
+ let(:element) { build_stubbed(:element, page: page) }
416
+ let(:content1) { double(:content, id: 1) }
417
+ let(:content2) { double(:content, id: 2) }
417
418
 
418
- before { allow(element).to receive(:contents).and_return([content]) }
419
+ before { allow(element).to receive(:contents).and_return([content1]) }
419
420
 
420
421
  context "with attributes hash is nil" do
421
422
  let(:params) { nil }
@@ -423,19 +424,36 @@ module Alchemy
423
424
  end
424
425
 
425
426
  context "with valid attributes hash" do
426
- let(:params) { {"#{content.id}" => {body: 'Title'}} }
427
+ let(:params) { {"#{content1.id}" => {body: 'Title'}} }
428
+
429
+ context 'when certain content is not part of the attributes hash (cause it was not filled by the user)' do
430
+ before do
431
+ allow(element).to receive(:contents).and_return([content1, content2])
432
+ end
433
+
434
+ it 'does not try to update that content' do
435
+ expect(content1).to receive(:update_essence).with({body: 'Title'}).and_return(true)
436
+ expect(content2).to_not receive(:update_essence)
437
+ subject
438
+ end
439
+ end
427
440
 
428
441
  context 'with passing validations' do
429
442
  before do
430
- expect(content).to receive(:update_essence).with({body: 'Title'}).and_return(true)
443
+ expect(content1).to receive(:update_essence).with({body: 'Title'}).and_return(true)
431
444
  end
432
445
 
433
446
  it { is_expected.to be_truthy }
447
+
448
+ it "does not add errors" do
449
+ subject
450
+ expect(element.errors).to be_empty
451
+ end
434
452
  end
435
453
 
436
454
  context 'with failing validations' do
437
455
  it "adds error and returns false" do
438
- expect(content).to receive(:update_essence).with({body: 'Title'}).and_return(false)
456
+ expect(content1).to receive(:update_essence).with({body: 'Title'}).and_return(false)
439
457
  is_expected.to be_falsey
440
458
  expect(element.errors).not_to be_empty
441
459
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.beta6
4
+ version: 3.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-01-08 00:00:00.000000000 Z
15
+ date: 2015-01-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: actionpack-page_caching