mongoid_acts_as_page 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/acts_as_page.rb +3 -0
- data/lib/acts_as_page/version.rb +1 -1
- data/spec/dummy/log/test.log +6 -0
- data/spec/unit/acts_as_page_spec.rb +12 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84a378af763c8a6640996c70be1ece069461ac20
|
4
|
+
data.tar.gz: 098f6cb8953afcabd4aac10c0408a5d50539e3eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b82e29e2102eb626f8d4caf8ac83a8cd6c01a23d25a6d58bca5927a1a750722e7d9bf81f75ab3e6503b052905b3dd343ae6948439b312e891640cb911a4c6b63
|
7
|
+
data.tar.gz: c49febca9d363858a562671032b1e558f1876c5af239ed51b7ae6413cf1cc5678734991898538fdafa1a02beac2fca857ba171f30fe45a334d5a869419ca3a1c
|
data/lib/acts_as_page.rb
CHANGED
@@ -8,6 +8,7 @@ module ActsAsPage
|
|
8
8
|
include Mongoid::Slug
|
9
9
|
|
10
10
|
field :name
|
11
|
+
field :text, default: ''
|
11
12
|
embeds_one :seo, class_name: 'ActsAsPage::Seo', as: :page
|
12
13
|
|
13
14
|
accepts_nested_attributes_for :seo
|
@@ -15,6 +16,8 @@ module ActsAsPage
|
|
15
16
|
after_initialize do |o|
|
16
17
|
o.build_seo(title: name) if o.seo.nil?
|
17
18
|
end
|
19
|
+
|
20
|
+
validates :name, presence: true, uniqueness: true
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
data/lib/acts_as_page/version.rb
CHANGED
data/spec/dummy/log/test.log
CHANGED
@@ -0,0 +1,6 @@
|
|
1
|
+
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} runtime: 41.1716ms
|
2
|
+
MOPED: 127.0.0.1:27017 QUERY database=mongoid_test collection=pages selector={"name"=>nil} flags=[] limit=-1 skip=0 batch_size=nil fields={:_id=>1} runtime: 90.3708ms
|
3
|
+
MOPED: 127.0.0.1:27017 QUERY database=mongoid_test collection=pages selector={"name"=>"new"} flags=[] limit=-1 skip=0 batch_size=nil fields={:_id=>1} runtime: 0.6724ms
|
4
|
+
MOPED: 127.0.0.1:27017 INSERT database=mongoid_test collection=pages documents=[{"_id"=>BSON::ObjectId('53b389b86d6178397d000000'), "text"=>"", "name"=>"new", "seo"=>{"_id"=>BSON::ObjectId('53b389b86d6178397d010000'), "title"=>"new", "description"=>"", "keywords"=>""}}] flags=[]
|
5
|
+
COMMAND database=mongoid_test command={:getlasterror=>1, :w=>1} runtime: 404.1425ms
|
6
|
+
MOPED: 127.0.0.1:27017 QUERY database=mongoid_test collection=pages selector={"name"=>"new"} flags=[] limit=-1 skip=0 batch_size=nil fields={:_id=>1} runtime: 73.4301ms
|
@@ -6,8 +6,18 @@ class Page
|
|
6
6
|
end
|
7
7
|
|
8
8
|
|
9
|
-
describe '
|
9
|
+
describe 'Page' do
|
10
10
|
let(:page) {Page.new name: 'new'}
|
11
|
+
|
12
|
+
specify 'should name be present' do
|
13
|
+
expect((Page.new).valid?).to be_falsey
|
14
|
+
end
|
15
|
+
|
16
|
+
specify 'should name be unique' do
|
17
|
+
page.save!
|
18
|
+
expect((Page.new name: 'new').valid?).to be_falsey
|
19
|
+
end
|
20
|
+
|
11
21
|
describe '#seo' do
|
12
22
|
it 'return instance of class Seo' do
|
13
23
|
expect(page.seo).to be_a(ActsAsPage::Seo)
|
@@ -17,4 +27,5 @@ describe 'ActsAsPage' do
|
|
17
27
|
expect(page.seo.title).to eq(page.name)
|
18
28
|
end
|
19
29
|
end
|
30
|
+
|
20
31
|
end
|