page_parts 0.0.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/MIT-LICENSE +20 -0
- data/README.rdoc +30 -0
- data/Rakefile +34 -0
- data/app/models/page_part.rb +8 -0
- data/db/migrate/20111226144515_create_page_parts.rb +20 -0
- data/lib/page_parts/active_record_extension.rb +67 -0
- data/lib/page_parts/engine.rb +7 -0
- data/lib/page_parts/version.rb +3 -0
- data/lib/page_parts.rb +6 -0
- data/lib/tasks/page_parts_tasks.rake +4 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +7 -0
- data/test/dummy/app/assets/stylesheets/application.css +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/category.rb +7 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +30 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20111226131910_create_categories.rb +9 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +425 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/categories.yml +7 -0
- data/test/dummy/test/unit/category_test.rb +7 -0
- data/test/models/category_test.rb +45 -0
- data/test/models/page_part_test.rb +33 -0
- data/test/page_parts_test.rb +11 -0
- data/test/test_helper.rb +14 -0
- metadata +153 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CategoryTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@category = Category.new :title => 'Test category'
|
7
|
+
end
|
8
|
+
|
9
|
+
test "truth" do
|
10
|
+
assert_kind_of Class, Category
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'should has page_parts_definitions' do
|
14
|
+
assert Category.respond_to?(:page_parts_definitions)
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should save page parts with new_record" do
|
18
|
+
value = "Sidebar content"
|
19
|
+
@category.sidebar = value
|
20
|
+
|
21
|
+
assert_equal @category.page_part(:sidebar).content, value
|
22
|
+
assert_equal @category.page_part(:content).content, nil
|
23
|
+
|
24
|
+
assert_difference('PagePart.count', 2) do
|
25
|
+
@category.save
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
test "should load page parts into record" do
|
30
|
+
@category.sidebar = "Sidebar"
|
31
|
+
@category.content = "Main"
|
32
|
+
@category.save
|
33
|
+
|
34
|
+
@category.reload
|
35
|
+
|
36
|
+
assert_equal @category.sidebar, "Sidebar"
|
37
|
+
assert_equal @category.content, "Main"
|
38
|
+
end
|
39
|
+
|
40
|
+
test "should raise error on not registered page part" do
|
41
|
+
assert_raise(NoMethodError) do
|
42
|
+
@category.wrong_method
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PagePartTest < ActiveSupport::TestCase
|
4
|
+
# called before every single test
|
5
|
+
def setup
|
6
|
+
@page = PagePart.new(:key => 'somekey')
|
7
|
+
@page.partable_type = 'Category'
|
8
|
+
@page.partable_id = 1
|
9
|
+
end
|
10
|
+
|
11
|
+
test "truth" do
|
12
|
+
assert_kind_of Class, PagePart
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'should create new record with valid attributes' do
|
16
|
+
@page.save!
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'should not be valid with empty key' do
|
20
|
+
@page.key = nil
|
21
|
+
assert !@page.valid?
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'should not be valid with not uniq key' do
|
25
|
+
@page.update_attribute(:key, 'test')
|
26
|
+
|
27
|
+
@part = PagePart.new(:key => 'test')
|
28
|
+
@part.partable_type = 'Category'
|
29
|
+
@part.partable_id = 1
|
30
|
+
|
31
|
+
assert !@part.valid?
|
32
|
+
end
|
33
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Run any available migration
|
10
|
+
ActiveRecord::Migrator.migrate File.expand_path("../../db/migrate/", __FILE__)
|
11
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
12
|
+
|
13
|
+
# Load support files
|
14
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: page_parts
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Igor Galeta
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activerecord
|
16
|
+
requirement: &77333070 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.3
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *77333070
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: sqlite3
|
27
|
+
requirement: &77332620 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *77332620
|
36
|
+
description: Aimbulance CMS
|
37
|
+
email:
|
38
|
+
- galeta.igor@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- app/models/page_part.rb
|
44
|
+
- db/migrate/20111226144515_create_page_parts.rb
|
45
|
+
- lib/page_parts.rb
|
46
|
+
- lib/tasks/page_parts_tasks.rake
|
47
|
+
- lib/page_parts/engine.rb
|
48
|
+
- lib/page_parts/version.rb
|
49
|
+
- lib/page_parts/active_record_extension.rb
|
50
|
+
- MIT-LICENSE
|
51
|
+
- Rakefile
|
52
|
+
- README.rdoc
|
53
|
+
- test/models/category_test.rb
|
54
|
+
- test/models/page_part_test.rb
|
55
|
+
- test/dummy/public/500.html
|
56
|
+
- test/dummy/public/404.html
|
57
|
+
- test/dummy/public/favicon.ico
|
58
|
+
- test/dummy/public/422.html
|
59
|
+
- test/dummy/app/views/layouts/application.html.erb
|
60
|
+
- test/dummy/app/helpers/application_helper.rb
|
61
|
+
- test/dummy/app/models/category.rb
|
62
|
+
- test/dummy/app/assets/stylesheets/application.css
|
63
|
+
- test/dummy/app/assets/javascripts/application.js
|
64
|
+
- test/dummy/app/controllers/application_controller.rb
|
65
|
+
- test/dummy/log/test.log
|
66
|
+
- test/dummy/log/development.log
|
67
|
+
- test/dummy/Rakefile
|
68
|
+
- test/dummy/test/unit/category_test.rb
|
69
|
+
- test/dummy/test/fixtures/categories.yml
|
70
|
+
- test/dummy/script/rails
|
71
|
+
- test/dummy/config/routes.rb
|
72
|
+
- test/dummy/config/environments/production.rb
|
73
|
+
- test/dummy/config/environments/test.rb
|
74
|
+
- test/dummy/config/environments/development.rb
|
75
|
+
- test/dummy/config/boot.rb
|
76
|
+
- test/dummy/config/application.rb
|
77
|
+
- test/dummy/config/database.yml
|
78
|
+
- test/dummy/config/initializers/session_store.rb
|
79
|
+
- test/dummy/config/initializers/inflections.rb
|
80
|
+
- test/dummy/config/initializers/mime_types.rb
|
81
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
82
|
+
- test/dummy/config/initializers/secret_token.rb
|
83
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
84
|
+
- test/dummy/config/environment.rb
|
85
|
+
- test/dummy/config/locales/en.yml
|
86
|
+
- test/dummy/db/migrate/20111226131910_create_categories.rb
|
87
|
+
- test/dummy/db/test.sqlite3
|
88
|
+
- test/dummy/config.ru
|
89
|
+
- test/page_parts_test.rb
|
90
|
+
- test/test_helper.rb
|
91
|
+
homepage: https://github.com/galetahub/page_parts
|
92
|
+
licenses: []
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 1.8.10
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Easy way to setup and use different page parts.
|
115
|
+
test_files:
|
116
|
+
- test/models/category_test.rb
|
117
|
+
- test/models/page_part_test.rb
|
118
|
+
- test/dummy/public/500.html
|
119
|
+
- test/dummy/public/404.html
|
120
|
+
- test/dummy/public/favicon.ico
|
121
|
+
- test/dummy/public/422.html
|
122
|
+
- test/dummy/app/views/layouts/application.html.erb
|
123
|
+
- test/dummy/app/helpers/application_helper.rb
|
124
|
+
- test/dummy/app/models/category.rb
|
125
|
+
- test/dummy/app/assets/stylesheets/application.css
|
126
|
+
- test/dummy/app/assets/javascripts/application.js
|
127
|
+
- test/dummy/app/controllers/application_controller.rb
|
128
|
+
- test/dummy/log/test.log
|
129
|
+
- test/dummy/log/development.log
|
130
|
+
- test/dummy/Rakefile
|
131
|
+
- test/dummy/test/unit/category_test.rb
|
132
|
+
- test/dummy/test/fixtures/categories.yml
|
133
|
+
- test/dummy/script/rails
|
134
|
+
- test/dummy/config/routes.rb
|
135
|
+
- test/dummy/config/environments/production.rb
|
136
|
+
- test/dummy/config/environments/test.rb
|
137
|
+
- test/dummy/config/environments/development.rb
|
138
|
+
- test/dummy/config/boot.rb
|
139
|
+
- test/dummy/config/application.rb
|
140
|
+
- test/dummy/config/database.yml
|
141
|
+
- test/dummy/config/initializers/session_store.rb
|
142
|
+
- test/dummy/config/initializers/inflections.rb
|
143
|
+
- test/dummy/config/initializers/mime_types.rb
|
144
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
145
|
+
- test/dummy/config/initializers/secret_token.rb
|
146
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
147
|
+
- test/dummy/config/environment.rb
|
148
|
+
- test/dummy/config/locales/en.yml
|
149
|
+
- test/dummy/db/migrate/20111226131910_create_categories.rb
|
150
|
+
- test/dummy/db/test.sqlite3
|
151
|
+
- test/dummy/config.ru
|
152
|
+
- test/page_parts_test.rb
|
153
|
+
- test/test_helper.rb
|