content_blocks 0.3.0 → 0.3.1
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.
- data/VERSION +1 -1
- data/content_blocks.gemspec +2 -2
- data/lib/content_blocks/models/snippet.rb +2 -1
- data/spec/snippet_spec.rb +28 -0
- metadata +4 -4
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.1
|
data/content_blocks.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{content_blocks}
|
|
8
|
-
s.version = "0.3.
|
|
8
|
+
s.version = "0.3.1"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Pawe\305\202 Pacana"]
|
|
12
|
-
s.date = %q{2010-12-
|
|
12
|
+
s.date = %q{2010-12-24}
|
|
13
13
|
s.description = %q{Content blocks are commonly used models representing editable page partials.}
|
|
14
14
|
s.email = %q{pawel.pacana@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -34,7 +34,8 @@ module ContentBlocks
|
|
|
34
34
|
:uniqueness => { :scope => :status, :if => :published? }
|
|
35
35
|
|
|
36
36
|
def self.[](label)
|
|
37
|
-
|
|
37
|
+
snippet = published.find_by_label(label)
|
|
38
|
+
snippet ? snippet : find_or_create_by_label(label)
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
def content
|
data/spec/snippet_spec.rb
CHANGED
|
@@ -70,4 +70,32 @@ describe ContentBlocks::Models::Snippet do
|
|
|
70
70
|
@snippet.content.should == "<h1>Sidebar links</h1>"
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
|
+
|
|
74
|
+
context "[]" do
|
|
75
|
+
it "should create if label doesnt exist" do
|
|
76
|
+
lambda {
|
|
77
|
+
ContentBlocks::Models::Snippet[:some_label]
|
|
78
|
+
}.should change(ContentBlocks::Models::Snippet, :count).by(1)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should not create if label exists" do
|
|
82
|
+
@snippet.save!
|
|
83
|
+
lambda {
|
|
84
|
+
ContentBlocks::Models::Snippet[@snippet.label]
|
|
85
|
+
}.should_not change(ContentBlocks::Models::Snippet, :count)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should return published if more with same label exist" do
|
|
89
|
+
@snippet.save!
|
|
90
|
+
ContentBlocks::Models::Snippet[@snippet.label].content.should == @snippet.content
|
|
91
|
+
new_snippet = @snippet.clone
|
|
92
|
+
new_snippet.content = "another snippet"
|
|
93
|
+
new_snippet.save!
|
|
94
|
+
new_snippet.publish!
|
|
95
|
+
ContentBlocks::Models::Snippet[@snippet.label].content.should == new_snippet.content
|
|
96
|
+
new_snippet.preview!
|
|
97
|
+
@snippet.publish!
|
|
98
|
+
ContentBlocks::Models::Snippet[@snippet.label].content.should == @snippet.content
|
|
99
|
+
end
|
|
100
|
+
end
|
|
73
101
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: content_blocks
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 17
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 3
|
|
9
|
-
-
|
|
10
|
-
version: 0.3.
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.3.1
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- "Pawe\xC5\x82 Pacana"
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-12-
|
|
18
|
+
date: 2010-12-24 00:00:00 +01:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|