spontaneous 0.2.0.alpha7 → 0.2.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -4
- data/Readme.markdown +1 -1
- data/application/css/definitions.css.scss +5 -0
- data/application/css/dialogue.css.scss +62 -0
- data/application/js/content.js +1 -1
- data/application/js/dom.js +1 -1
- data/application/js/event_source.js +3 -0
- data/application/js/{field_types/date_field.js → field/date.js} +2 -2
- data/application/js/{field_types/file_field.js → field/file.js} +2 -2
- data/application/js/{field_types/image_field.js → field/image.js} +54 -20
- data/application/js/{field_types/long_string_field.js → field/long_string.js} +2 -2
- data/application/js/{field_types/markdown_field.js → field/markdown.js} +2 -2
- data/application/js/{field_types/select_field.js → field/select.js} +2 -2
- data/application/js/{field_types/string_field.js → field/string.js} +21 -7
- data/application/js/{field_types/webvideo_field.js → field/webvideo.js} +2 -2
- data/application/js/field.js +2 -2
- data/application/js/publish.js +99 -19
- data/application/js/spontaneous.js +8 -8
- data/application/js/top_bar.js +6 -4
- data/db/migrations/20130109125023_add_page_publish_lock.rb +17 -0
- data/db/migrations/20130111161934_convert_bcrypt_passwords.rb +22 -0
- data/db/migrations/20130114120000_create_revision_tables.rb +106 -0
- data/db/migrations/20130116220423_add_index_to_archive.rb +9 -0
- data/lib/spontaneous/box.rb +53 -18
- data/lib/spontaneous/box_style.rb +2 -3
- data/lib/spontaneous/change.rb +39 -13
- data/lib/spontaneous/cli/fields.rb +29 -0
- data/lib/spontaneous/cli/init.rb +2 -2
- data/lib/spontaneous/cli/migrate.rb +0 -1
- data/lib/spontaneous/cli/server.rb +14 -10
- data/lib/spontaneous/cli/site.rb +20 -9
- data/lib/spontaneous/cli.rb +8 -6
- data/lib/spontaneous/collections/box_set.rb +11 -0
- data/lib/spontaneous/collections/field_set.rb +24 -1
- data/lib/spontaneous/concern.rb +37 -0
- data/lib/spontaneous/config.rb +3 -4
- data/lib/spontaneous/crypt/version.rb +130 -0
- data/lib/spontaneous/crypt.rb +84 -0
- data/lib/spontaneous/data_mapper/content_model/associations.rb +199 -0
- data/lib/spontaneous/data_mapper/content_model/column_accessors.rb +52 -0
- data/lib/spontaneous/data_mapper/content_model/instance_hooks.rb +34 -0
- data/lib/spontaneous/data_mapper/content_model/serialization.rb +54 -0
- data/lib/spontaneous/data_mapper/content_model/timestamps.rb +39 -0
- data/lib/spontaneous/data_mapper/content_model.rb +343 -0
- data/lib/spontaneous/data_mapper/content_table.rb +103 -0
- data/lib/spontaneous/data_mapper/dataset.rb +194 -0
- data/lib/spontaneous/data_mapper/scope.rb +195 -0
- data/lib/spontaneous/data_mapper.rb +161 -0
- data/lib/spontaneous/facet.rb +2 -2
- data/lib/spontaneous/field/base.rb +418 -0
- data/lib/spontaneous/field/date.rb +54 -0
- data/lib/spontaneous/{field_version.rb → field/field_version.rb} +1 -1
- data/lib/spontaneous/field/file.rb +100 -0
- data/lib/spontaneous/{field_types/image_field.rb → field/image.rb} +33 -33
- data/lib/spontaneous/{field_types/location_field.rb → field/location.rb} +2 -2
- data/lib/spontaneous/{field_types/long_string_field.rb → field/long_string.rb} +3 -3
- data/lib/spontaneous/field/markdown.rb +36 -0
- data/lib/spontaneous/{field_types/select_field.rb → field/select.rb} +4 -5
- data/lib/spontaneous/field/string.rb +17 -0
- data/lib/spontaneous/field/update.rb +156 -0
- data/lib/spontaneous/field/webvideo.rb +310 -0
- data/lib/spontaneous/field.rb +80 -0
- data/lib/spontaneous/generators/site/Gemfile.tt +2 -2
- data/lib/spontaneous/generators/site/config/environments/development.rb.tt +1 -1
- data/lib/spontaneous/generators/site/config/environments/production.rb.tt +1 -1
- data/lib/spontaneous/generators/site/lib/content.rb.tt +6 -0
- data/lib/spontaneous/generators/site/schema/box.rb.tt +3 -2
- data/lib/spontaneous/generators/site/schema/page.rb.tt +3 -1
- data/lib/spontaneous/generators/site/schema/piece.rb.tt +3 -1
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +3 -1
- data/lib/spontaneous/generators/site.rb +4 -3
- data/lib/spontaneous/image_size.rb +8 -1
- data/lib/spontaneous/layout.rb +5 -1
- data/lib/spontaneous/loader.rb +2 -5
- data/lib/spontaneous/media/file.rb +11 -2
- data/lib/spontaneous/media/temp_file.rb +23 -0
- data/lib/spontaneous/media.rb +20 -39
- data/lib/spontaneous/{plugins → model/box}/allowed_types.rb +38 -17
- data/lib/spontaneous/model/box.rb +18 -0
- data/lib/spontaneous/{plugins → model/core}/aliases.rb +10 -14
- data/lib/spontaneous/{plugins → model/core}/boxes.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/content_groups.rb +2 -2
- data/lib/spontaneous/model/core/editor_class.rb +4 -0
- data/lib/spontaneous/{plugins → model/core}/entries.rb +19 -7
- data/lib/spontaneous/{plugins → model/core}/entry.rb +3 -3
- data/lib/spontaneous/{plugins → model/core}/fields.rb +38 -5
- data/lib/spontaneous/{plugins → model/core}/instance_code.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/media.rb +2 -12
- data/lib/spontaneous/{plugins → model/core}/modifications.rb +7 -6
- data/lib/spontaneous/model/core/page_search.rb +36 -0
- data/lib/spontaneous/{plugins → model/core}/permissions.rb +4 -4
- data/lib/spontaneous/{plugins → model/core}/prototypes.rb +4 -4
- data/lib/spontaneous/{plugins → model/core}/publishing.rb +93 -115
- data/lib/spontaneous/{plugins → model/core}/render.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/schema_hierarchy.rb +7 -11
- data/lib/spontaneous/model/core/schema_id.rb +65 -0
- data/lib/spontaneous/{plugins → model/core}/schema_title.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/serialisation.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/styles.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/supertype.rb +2 -2
- data/lib/spontaneous/{plugins → model/core}/visibility.rb +7 -48
- data/lib/spontaneous/model/core.rb +143 -0
- data/lib/spontaneous/{plugins → model/page}/controllers.rb +3 -3
- data/lib/spontaneous/{plugins → model}/page/formats.rb +2 -2
- data/lib/spontaneous/{plugins → model/page}/layouts.rb +2 -2
- data/lib/spontaneous/model/page/locks.rb +14 -0
- data/lib/spontaneous/{plugins → model/page}/page_tree.rb +3 -3
- data/lib/spontaneous/{plugins → model/page}/paths.rb +30 -12
- data/lib/spontaneous/{plugins → model}/page/request.rb +2 -2
- data/lib/spontaneous/{plugins → model/page}/site_map.rb +2 -2
- data/lib/spontaneous/model/page/site_timestamps.rb +44 -0
- data/lib/spontaneous/{page.rb → model/page.rb} +49 -28
- data/lib/spontaneous/{piece.rb → model/piece.rb} +7 -6
- data/lib/spontaneous/model.rb +97 -0
- data/lib/spontaneous/output/context.rb +1 -1
- data/lib/spontaneous/output/format.rb +4 -0
- data/lib/spontaneous/output/template/renderer.rb +2 -2
- data/lib/spontaneous/output.rb +2 -2
- data/lib/spontaneous/page_lock.rb +62 -0
- data/lib/spontaneous/page_piece.rb +1 -1
- data/lib/spontaneous/permissions/access_key.rb +9 -4
- data/lib/spontaneous/permissions/user.rb +19 -9
- data/lib/spontaneous/permissions.rb +2 -5
- data/lib/spontaneous/plugins/application/facets.rb +1 -2
- data/lib/spontaneous/plugins/application/features.rb +1 -1
- data/lib/spontaneous/plugins/application/paths.rb +1 -1
- data/lib/spontaneous/plugins/application/render.rb +1 -1
- data/lib/spontaneous/plugins/application/serialisation.rb +1 -1
- data/lib/spontaneous/plugins/application/state.rb +30 -1
- data/lib/spontaneous/plugins/application/system.rb +12 -12
- data/lib/spontaneous/prototypes/box_prototype.rb +1 -1
- data/lib/spontaneous/prototypes/field_prototype.rb +3 -6
- data/lib/spontaneous/prototypes/style_prototype.rb +1 -1
- data/lib/spontaneous/publishing/immediate.rb +77 -49
- data/lib/spontaneous/publishing/revision.rb +355 -0
- data/lib/spontaneous/publishing/simultaneous.rb +10 -49
- data/lib/spontaneous/publishing.rb +1 -0
- data/lib/spontaneous/rack/around_back.rb +1 -1
- data/lib/spontaneous/rack/around_front.rb +2 -4
- data/lib/spontaneous/rack/around_preview.rb +1 -1
- data/lib/spontaneous/rack/back.rb +80 -63
- data/lib/spontaneous/rack/cacheable_file.rb +2 -2
- data/lib/spontaneous/rack/cookie_authentication.rb +1 -1
- data/lib/spontaneous/rack/front.rb +1 -1
- data/lib/spontaneous/rack/helpers.rb +8 -9
- data/lib/spontaneous/{page_controller.rb → rack/page_controller.rb} +1 -1
- data/lib/spontaneous/rack/public.rb +3 -3
- data/lib/spontaneous/rack.rb +15 -15
- data/lib/spontaneous/schema/uid.rb +4 -1
- data/lib/spontaneous/schema.rb +57 -24
- data/lib/spontaneous/search/database.rb +12 -1
- data/lib/spontaneous/search/index.rb +34 -6
- data/lib/spontaneous/search/results.rb +1 -1
- data/lib/spontaneous/server.rb +3 -3
- data/lib/spontaneous/simultaneous.rb +53 -0
- data/lib/spontaneous/{plugins/site → site}/features.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/helpers.rb +2 -3
- data/lib/spontaneous/{plugins/site → site}/hooks.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/instance.rb +4 -6
- data/lib/spontaneous/{plugins/site → site}/level.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/map.rb +4 -4
- data/lib/spontaneous/{plugins/site → site}/paths.rb +2 -2
- data/lib/spontaneous/site/publishing.rb +89 -0
- data/lib/spontaneous/{plugins/site → site}/schema.rb +4 -4
- data/lib/spontaneous/{plugins/site → site}/search.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/selectors.rb +15 -7
- data/lib/spontaneous/{plugins/site → site}/state.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/storage.rb +2 -2
- data/lib/spontaneous/{plugins/site → site}/url.rb +2 -2
- data/lib/spontaneous/site.rb +31 -14
- data/lib/spontaneous/state.rb +5 -6
- data/lib/spontaneous/style.rb +3 -2
- data/lib/spontaneous/utils/database/mysql_dumper.rb +13 -0
- data/lib/spontaneous/utils/database/postgres_dumper.rb +5 -0
- data/lib/spontaneous/version.rb +1 -1
- data/lib/spontaneous.rb +34 -89
- data/spontaneous.gemspec +112 -114
- data/test/experimental/test_crypt.rb +158 -0
- data/test/experimental/test_features.rb +3 -3
- data/test/fixtures/example_application/config/environments/development.rb +1 -1
- data/test/fixtures/example_application/lib/content.rb +5 -0
- data/test/fixtures/example_application/schema/page.rb +2 -1
- data/test/fixtures/example_application/schema/piece.rb +3 -2
- data/test/fixtures/serialisation/class_hash.yaml.erb +5 -5
- data/test/fixtures/serialisation/root_hash.yaml.erb +8 -0
- data/test/functional/test_application.rb +12 -1
- data/test/functional/test_back.rb +80 -48
- data/test/functional/test_front.rb +39 -46
- data/test/functional/test_user_manager.rb +3 -9
- data/test/javascript/test_markdown.rb +2 -2
- data/test/test_helper.rb +78 -23
- data/test/unit/test_alias.rb +21 -15
- data/test/unit/test_asset_bundler.rb +3 -3
- data/test/unit/test_assets.rb +2 -2
- data/test/unit/test_async.rb +7 -6
- data/test/unit/test_authentication.rb +43 -37
- data/test/unit/test_boxes.rb +46 -21
- data/test/unit/test_changesets.rb +65 -20
- data/test/unit/test_config.rb +9 -9
- data/test/unit/test_content.rb +50 -51
- data/test/unit/test_content_inheritance.rb +6 -20
- data/test/unit/test_datamapper.rb +1330 -0
- data/test/unit/test_datamapper_content.rb +214 -0
- data/test/unit/test_fields.rb +543 -54
- data/test/unit/test_formats.rb +2 -3
- data/test/unit/test_generators.rb +6 -6
- data/test/unit/test_helpers.rb +1 -1
- data/test/unit/test_image_size.rb +10 -5
- data/test/unit/test_images.rb +17 -18
- data/test/unit/test_layouts.rb +18 -3
- data/test/unit/test_media.rb +74 -49
- data/test/unit/test_modifications.rb +43 -43
- data/test/unit/test_page.rb +7 -10
- data/test/unit/test_permissions.rb +3 -10
- data/test/unit/test_piece.rb +5 -6
- data/test/unit/test_plugins.rb +7 -14
- data/test/unit/test_prototypes.rb +3 -3
- data/test/unit/test_publishing.rb +49 -27
- data/test/unit/test_render.rb +46 -15
- data/test/unit/test_revisions.rb +124 -127
- data/test/unit/test_schema.rb +53 -58
- data/test/unit/test_search.rb +64 -16
- data/test/unit/test_serialisation.rb +4 -11
- data/test/unit/test_site.rb +11 -12
- data/test/unit/test_structure.rb +2 -5
- data/test/unit/test_styles.rb +22 -24
- data/test/unit/test_type_hierarchy.rb +7 -5
- data/test/unit/test_visibility.rb +79 -55
- metadata +128 -102
- data/lib/sequel/plugins/content_table_inheritance.rb +0 -203
- data/lib/sequel/plugins/scoped_table_name.rb +0 -54
- data/lib/spontaneous/content.rb +0 -129
- data/lib/spontaneous/field_types/date_field.rb +0 -56
- data/lib/spontaneous/field_types/field.rb +0 -302
- data/lib/spontaneous/field_types/file_field.rb +0 -68
- data/lib/spontaneous/field_types/markdown_field.rb +0 -38
- data/lib/spontaneous/field_types/string_field.rb +0 -19
- data/lib/spontaneous/field_types/webvideo_field.rb +0 -313
- data/lib/spontaneous/field_types.rb +0 -38
- data/lib/spontaneous/generators/site/lib/site.rb.tt +0 -4
- data/lib/spontaneous/plugins/field/editor_class.rb +0 -13
- data/lib/spontaneous/plugins/page/site_timestamps.rb +0 -28
- data/lib/spontaneous/plugins/page_search.rb +0 -63
- data/lib/spontaneous/plugins/schema_id.rb +0 -68
- data/lib/spontaneous/plugins/site/publishing.rb +0 -75
- data/lib/spontaneous/rack/fiber_pool.rb +0 -26
- data/test/unit/test_table_scoping.rb +0 -80
data/test/test_helper.rb
CHANGED
@@ -18,7 +18,6 @@ $:.unshift(spot_path) if File.directory?(spot_path) && !$:.include?(spot_path)
|
|
18
18
|
|
19
19
|
require 'rack'
|
20
20
|
require 'logger'
|
21
|
-
require 'pg'
|
22
21
|
|
23
22
|
|
24
23
|
Sequel.extension :migration
|
@@ -26,14 +25,37 @@ Sequel.extension :migration
|
|
26
25
|
# for future integration with travis
|
27
26
|
ENV["SPOT_ADAPTER"] ||= "postgres"
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
jruby = case RUBY_PLATFORM
|
29
|
+
when "java"
|
30
|
+
true
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
connection_string = \
|
37
|
+
case ENV["SPOT_ADAPTER"]
|
38
|
+
when "postgres"
|
39
|
+
if jruby
|
40
|
+
require 'jdbc/postgres'
|
41
|
+
Jdbc::Postgres.load_driver
|
42
|
+
"jdbc:postgresql:///spontaneous2_test"
|
43
|
+
else
|
44
|
+
require 'pg'
|
45
|
+
"postgres:///spontaneous2_test"
|
46
|
+
end
|
47
|
+
when "mysql"
|
48
|
+
if jruby
|
49
|
+
require 'jdbc/mysql'
|
50
|
+
Jdbc::MySQL.load_driver
|
51
|
+
"jdbc:mysql://localhost/spontaneous2_test?user=root"
|
52
|
+
else
|
53
|
+
require 'mysql2'
|
54
|
+
"mysql2://root@localhost/spontaneous2_test"
|
55
|
+
end
|
56
|
+
end
|
35
57
|
|
36
|
-
|
58
|
+
puts "DB Connection: #{connection_string}"
|
37
59
|
DB = Sequel.connect(connection_string) unless defined?(DB)
|
38
60
|
# DB.logger = Logger.new($stdout)
|
39
61
|
|
@@ -49,7 +71,7 @@ require 'rack/test'
|
|
49
71
|
require 'matchy'
|
50
72
|
require 'shoulda'
|
51
73
|
require 'timecop'
|
52
|
-
require 'mocha'
|
74
|
+
require 'mocha/setup'
|
53
75
|
require 'pp'
|
54
76
|
require 'tmpdir'
|
55
77
|
require 'json'
|
@@ -80,7 +102,7 @@ class MiniTestWithHooks < MiniTest::Unit
|
|
80
102
|
|
81
103
|
def _run_suites(suites, type)
|
82
104
|
names = suites.reject { |s| exclude?(s) }.map { |s| s.to_s.gsub(/Test$/, '') }
|
83
|
-
@max_name_length = names.
|
105
|
+
@max_name_length = names.map(&:length).max
|
84
106
|
begin
|
85
107
|
before_suites
|
86
108
|
super(suites, type)
|
@@ -119,23 +141,42 @@ def silence_logger(&block)
|
|
119
141
|
end
|
120
142
|
|
121
143
|
class MiniTest::Spec
|
122
|
-
include Spontaneous
|
123
144
|
include CustomMatchers
|
124
145
|
|
125
146
|
attr_accessor :template_root
|
126
147
|
alias :silence_stdout :silence_logger
|
127
148
|
|
128
|
-
def self.setup_site(root = nil)
|
149
|
+
def self.setup_site(root = nil, define_models = true)
|
129
150
|
root ||= Dir.mktmpdir
|
130
151
|
instance = Spontaneous::Site.instantiate(root, :test, :back)
|
131
152
|
instance.schema_loader_class = Spontaneous::Schema::TransientMap
|
132
153
|
instance.logger.silent!
|
133
154
|
instance.database = DB
|
155
|
+
Spontaneous::Site.background_mode = :immediate
|
156
|
+
unless Object.const_defined?(:Content)
|
157
|
+
content_class = Class.new(Spontaneous::Model(:content, DB, instance.schema))
|
158
|
+
Object.const_set :Content, content_class
|
159
|
+
if define_models
|
160
|
+
Object.const_set :Page, Class.new(::Content::Page)
|
161
|
+
Object.const_set :Piece, Class.new(::Content::Piece)
|
162
|
+
Object.const_set :Box, Class.new(::Content::Box)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
Object.const_set :Site, Spontaneous.site!(::Content)
|
166
|
+
# Use the fast version of the password hashing algorithm
|
167
|
+
Spontaneous::Crypt.force_version(0)
|
134
168
|
instance
|
135
169
|
end
|
136
170
|
|
137
|
-
def self.teardown_site
|
138
|
-
|
171
|
+
def self.teardown_site(clear_disk = true, clear_const = true)
|
172
|
+
if clear_disk
|
173
|
+
FileUtils.rm_r(Spontaneous.instance.root) rescue nil
|
174
|
+
end
|
175
|
+
return unless clear_const
|
176
|
+
%w(Piece Page Box Content Site).each do |klass|
|
177
|
+
Object.send :remove_const, klass if Object.const_defined?(klass)
|
178
|
+
end
|
179
|
+
Spontaneous.send :remove_const, :Content rescue nil
|
139
180
|
end
|
140
181
|
|
141
182
|
def self.stub_time(time)
|
@@ -146,9 +187,9 @@ class MiniTest::Spec
|
|
146
187
|
self.class.stub_time(time)
|
147
188
|
end
|
148
189
|
|
149
|
-
def assert_content_equal(result, compare)
|
190
|
+
def assert_content_equal(result, compare, *ignore_columns)
|
150
191
|
serialised_columns = [:field_store, :entry_store]
|
151
|
-
columns = Content.columns - serialised_columns
|
192
|
+
columns = Content.columns - serialised_columns - ignore_columns
|
152
193
|
columns.each do |col|
|
153
194
|
assert_equal(result[col], compare[col], "Column '#{col}' should be equal")
|
154
195
|
end
|
@@ -157,19 +198,33 @@ class MiniTest::Spec
|
|
157
198
|
end
|
158
199
|
end
|
159
200
|
|
201
|
+
def assert_content_unequal(result, compare, *ignore_columns)
|
202
|
+
serialised_columns = [:field_store, :entry_store]
|
203
|
+
columns = Content.columns - serialised_columns - ignore_columns
|
204
|
+
columns.each do |col|
|
205
|
+
return true unless result[col] == compare[col]
|
206
|
+
end
|
207
|
+
serialised_columns.each do |col|
|
208
|
+
return true unless result.send(col) == compare.send(col)
|
209
|
+
end
|
210
|
+
flunk("#{result} & #{compare} are equal")
|
211
|
+
end
|
212
|
+
|
213
|
+
|
160
214
|
def log_sql(&block)
|
161
|
-
logger =
|
162
|
-
|
215
|
+
logger = ::Content.mapper.logger
|
216
|
+
::Content.mapper.logger = ::Logger.new($stdout)
|
163
217
|
yield
|
164
218
|
ensure
|
165
|
-
|
219
|
+
::Content.mapper.logger = logger
|
166
220
|
end
|
167
|
-
|
168
|
-
|
221
|
+
|
222
|
+
def setup_site(root = nil, define_models = true)
|
223
|
+
self.class.setup_site(root, define_models)
|
169
224
|
end
|
170
225
|
|
171
|
-
def teardown_site
|
172
|
-
self.class.teardown_site
|
226
|
+
def teardown_site(clear_disk = true, clear_const = true)
|
227
|
+
self.class.teardown_site(clear_disk, clear_const)
|
173
228
|
end
|
174
229
|
|
175
230
|
def assert_correct_template(content, expected_path, format = :html)
|
data/test/unit/test_alias.rb
CHANGED
@@ -5,13 +5,13 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
5
5
|
class AliasTest < MiniTest::Spec
|
6
6
|
|
7
7
|
def assert_same_content(c1, c2)
|
8
|
-
assert_equal
|
8
|
+
assert_equal c2.length, c1.length
|
9
9
|
c1 = c1.dup.sort { |a, b| a.id <=> b.id }
|
10
10
|
c2 = c2.dup.sort { |a, b| a.id <=> b.id }
|
11
11
|
c1.each_with_index do |a, i|
|
12
12
|
b = c2[i]
|
13
|
-
assert_equal
|
14
|
-
assert_equal
|
13
|
+
assert_equal b.id, a.id
|
14
|
+
assert_equal b.class, a.class
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -25,13 +25,13 @@ class AliasTest < MiniTest::Spec
|
|
25
25
|
|
26
26
|
Content.delete
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
28
|
+
Page.field :title
|
29
|
+
Page.box :box1
|
30
|
+
Page.box :box2
|
31
|
+
# class ::Page < Spontaneous::Page
|
32
|
+
# end
|
33
33
|
|
34
|
-
class ::Piece < Spontaneous::Piece; end
|
34
|
+
# class ::Piece < Spontaneous::Piece; end
|
35
35
|
|
36
36
|
class ::A < ::Piece
|
37
37
|
field :a_field1
|
@@ -98,7 +98,7 @@ class AliasTest < MiniTest::Spec
|
|
98
98
|
end
|
99
99
|
|
100
100
|
class ::ProcAlias < ::Piece
|
101
|
-
alias_of proc {
|
101
|
+
alias_of proc { Content.root.children }
|
102
102
|
end
|
103
103
|
|
104
104
|
@root = ::Page.create
|
@@ -116,11 +116,11 @@ class AliasTest < MiniTest::Spec
|
|
116
116
|
end
|
117
117
|
|
118
118
|
teardown do
|
119
|
-
[:
|
119
|
+
[:A, :AA, :AAA, :B, :BB, :AAlias, :AAAlias, :AAAAlias, :BBAlias, :BAlias, :MultipleAlias, :ProcAlias].each do |c|
|
120
120
|
Object.send(:remove_const, c) rescue nil
|
121
121
|
end
|
122
122
|
Content.delete
|
123
|
-
|
123
|
+
teardown_site
|
124
124
|
end
|
125
125
|
|
126
126
|
context "All alias" do
|
@@ -159,7 +159,7 @@ class AliasTest < MiniTest::Spec
|
|
159
159
|
@page.box2 << A.new
|
160
160
|
@page.box2 << AA.new
|
161
161
|
}
|
162
|
-
@page.save.reload
|
162
|
+
@page = @page.save.reload
|
163
163
|
end
|
164
164
|
|
165
165
|
teardown do
|
@@ -175,8 +175,13 @@ class AliasTest < MiniTest::Spec
|
|
175
175
|
class ::XX < ::Piece
|
176
176
|
alias_of :AA, :container => Proc.new { S::Site['#thepage'].box1 }
|
177
177
|
end
|
178
|
-
|
179
|
-
|
178
|
+
targets = lambda { |a, target|
|
179
|
+
[(a.targets), @page.box1.select { |p| target === p }].map { |a| Set.new(a) }
|
180
|
+
}
|
181
|
+
expected, actual = targets.call(X, A)
|
182
|
+
actual.should == expected
|
183
|
+
expected, actual = targets.call(XX, AA)
|
184
|
+
actual.should == expected
|
180
185
|
end
|
181
186
|
|
182
187
|
should "allow for selecting only content from a range of boxes" do
|
@@ -322,6 +327,7 @@ class AliasTest < MiniTest::Spec
|
|
322
327
|
@a_alias.destroy
|
323
328
|
Content[@a.id].should == @a
|
324
329
|
end
|
330
|
+
|
325
331
|
should "be deleted when target deleted" do
|
326
332
|
@a.destroy
|
327
333
|
Content[@a_alias.id].should be_nil
|
@@ -74,7 +74,7 @@ class AssetBundler < MiniTest::Spec
|
|
74
74
|
|
75
75
|
context "Development mode editing app" do
|
76
76
|
setup do
|
77
|
-
@page =
|
77
|
+
@page = Content.create
|
78
78
|
end
|
79
79
|
|
80
80
|
teardown do
|
@@ -122,7 +122,7 @@ class AssetBundler < MiniTest::Spec
|
|
122
122
|
setup do
|
123
123
|
@compiler = Spontaneous::Asset::AppCompiler.new(fixture_dir, @site.root)
|
124
124
|
@compiler.compile
|
125
|
-
@page =
|
125
|
+
@page = Content.create
|
126
126
|
end
|
127
127
|
|
128
128
|
teardown do
|
@@ -169,7 +169,7 @@ class AssetBundler < MiniTest::Spec
|
|
169
169
|
config.stubs(:reload_classes).returns(false)
|
170
170
|
config.stubs(:auto_login).returns('test')
|
171
171
|
config.stubs(:default_charset).returns('utf-8')
|
172
|
-
config.stubs(:
|
172
|
+
config.stubs(:background_mode).returns(:immediate)
|
173
173
|
config.stubs(:services).returns(nil)
|
174
174
|
config.stubs(:site_domain).returns('example.org')
|
175
175
|
config.stubs(:site_id).returns('example_org')
|
data/test/unit/test_assets.rb
CHANGED
@@ -29,11 +29,11 @@ class AssetTest < MiniTest::Spec
|
|
29
29
|
@site = setup_site
|
30
30
|
@fixture_root = File.expand_path("../../fixtures/assets", __FILE__)
|
31
31
|
@site.paths.add :public, @fixture_root / "public1", @fixture_root / "public2"
|
32
|
-
@page =
|
32
|
+
@page = Page.create
|
33
33
|
end
|
34
34
|
|
35
35
|
def teardown
|
36
|
-
|
36
|
+
Content.delete
|
37
37
|
teardown_site
|
38
38
|
end
|
39
39
|
|
data/test/unit/test_async.rb
CHANGED
@@ -28,10 +28,9 @@ class AsyncTest < MiniTest::Spec
|
|
28
28
|
|
29
29
|
should "use fibers to simulate sync code if running in a fiber" do
|
30
30
|
EM.run do
|
31
|
-
|
32
|
-
result = Spontaneous.system("touch #{@filepath}")
|
31
|
+
result = Spontaneous.system("touch #{@filepath}") {
|
33
32
|
File.exist?(@filepath).should be_true
|
34
|
-
}
|
33
|
+
}
|
35
34
|
EM.stop
|
36
35
|
end
|
37
36
|
end
|
@@ -47,9 +46,11 @@ class AsyncTest < MiniTest::Spec
|
|
47
46
|
|
48
47
|
|
49
48
|
should "run synchronously outside of EM reactor" do
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
Spontaneous.system("touch #{@filepath}") { |result|
|
50
|
+
File.exist?(@filepath).should be_true
|
51
|
+
result.should be_true
|
52
|
+
|
53
|
+
}
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
@@ -8,6 +8,7 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
8
8
|
class AuthenticationTest < MiniTest::Spec
|
9
9
|
include ::Rack::Test::Methods
|
10
10
|
|
11
|
+
Permissions = Spontaneous::Permissions
|
11
12
|
|
12
13
|
def create_user(name, level)
|
13
14
|
user = Permissions::User.create({
|
@@ -104,12 +105,12 @@ class AuthenticationTest < MiniTest::Spec
|
|
104
105
|
setup do
|
105
106
|
# Spontaneous::Schema.reset!
|
106
107
|
|
107
|
-
class C <
|
108
|
+
class C < Piece
|
108
109
|
field :photo, :image, :write_level => :root
|
109
110
|
end
|
110
|
-
class D <
|
111
|
+
class D < Piece; end
|
111
112
|
|
112
|
-
class SitePage <
|
113
|
+
class SitePage < Page
|
113
114
|
# page_style :default
|
114
115
|
field :editor_level, :user_level => :editor
|
115
116
|
field :admin_level, :user_level => :admin
|
@@ -178,23 +179,25 @@ class AuthenticationTest < MiniTest::Spec
|
|
178
179
|
Permissions::UserLevel.reset!
|
179
180
|
Permissions::UserLevel.stubs(:level_file).returns(File.expand_path('../../fixtures/permissions', __FILE__) / 'config/user_levels.yml')
|
180
181
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
182
|
+
::Content.scope do
|
183
|
+
@root = SitePage.create
|
184
|
+
@root.save
|
185
|
+
|
186
|
+
@about = SitePage.create(:uid => 'about', :slug => "about")
|
187
|
+
@root.pages << @about
|
188
|
+
piece = C.new
|
189
|
+
@root.boxes[:root_level] << piece
|
190
|
+
piece = C.new
|
191
|
+
@root.boxes[:root_level] << piece
|
192
|
+
@root.save
|
193
|
+
|
194
|
+
@root_user = create_user('root', Permissions::UserLevel.root)
|
195
|
+
@admin_user = create_user('admin', Permissions::UserLevel.admin)
|
196
|
+
@editor_user = create_user('editor', Permissions::UserLevel.editor)
|
197
|
+
@guest_user = create_user('guest', Permissions::UserLevel.none)
|
198
|
+
@disabled_user = create_user('disabled', Permissions::UserLevel.admin)
|
199
|
+
@disabled_user.update(:disabled => true)
|
200
|
+
end
|
198
201
|
end
|
199
202
|
|
200
203
|
teardown do
|
@@ -389,7 +392,7 @@ class AuthenticationTest < MiniTest::Spec
|
|
389
392
|
|
390
393
|
should "be able to update root level fields" do
|
391
394
|
field = root.fields.root_level
|
392
|
-
auth_post "/@spontaneous/save/#{root.id}", "field[#{field.schema_id}]
|
395
|
+
auth_post "/@spontaneous/save/#{root.id}", "field[#{field.schema_id}]" => "Updated"
|
393
396
|
assert last_response.ok?
|
394
397
|
root.reload.fields[:root_level].value.should == "Updated"
|
395
398
|
end
|
@@ -410,18 +413,28 @@ class AuthenticationTest < MiniTest::Spec
|
|
410
413
|
clear_cookies
|
411
414
|
end
|
412
415
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
416
|
+
# DISABLED: The ui should ensure that forbidden fields don't appear
|
417
|
+
# the async update system simply ignores fields that the user can't
|
418
|
+
# modify (see test_fields.rb).
|
419
|
+
# should "not be able to update root level fields" do
|
420
|
+
# value = "Updated #{version}"
|
421
|
+
# field = root.fields[:root_level]
|
422
|
+
# auth_post "/@spontaneous/save/#{root.id}", "field[#{field.schema_id}]" => value
|
423
|
+
# assert last_response.status == 403, "Should have a permissions error 403 not #{last_response.status}"
|
424
|
+
# root.reload.fields[:root_level].value.should == @root_copy.root_level.value
|
425
|
+
# end
|
426
|
+
|
427
|
+
# should "not be able to update root level fields from admin level box" do
|
428
|
+
# value = "Updated #{version}"
|
429
|
+
# field = root.boxes[:admin_level].fields[:root_level]
|
430
|
+
# auth_post "/@spontaneous/savebox/#{root.id}/#{root.boxes[:admin_level].schema_id}", "field[#{field.schema_id}]" => value
|
431
|
+
# assert last_response.status == 403, "Should have a permissions error 403 not #{last_response.status}"
|
432
|
+
# end
|
420
433
|
|
421
434
|
should "be able to update admin level fields" do
|
422
435
|
value = "Updated #{version}"
|
423
436
|
field = root.fields[:admin_level]
|
424
|
-
auth_post "/@spontaneous/save/#{root.id}", "field[#{field.schema_id}]
|
437
|
+
auth_post "/@spontaneous/save/#{root.id}", "field[#{field.schema_id}]" => value
|
425
438
|
assert last_response.ok?
|
426
439
|
root.reload.fields[:admin_level].value.should == value
|
427
440
|
end
|
@@ -445,14 +458,7 @@ class AuthenticationTest < MiniTest::Spec
|
|
445
458
|
should "not be able to update fields from root level box" do
|
446
459
|
value = "Updated #{version}"
|
447
460
|
field = root.fields[:editor_level]
|
448
|
-
auth_post "/@spontaneous/savebox/#{root.id}/#{root.boxes[:root_level].schema_id}", "field[#{field.schema_id}]
|
449
|
-
assert last_response.status == 403, "Should have a permissions error 403 not #{last_response.status}"
|
450
|
-
end
|
451
|
-
|
452
|
-
should "not be able to update root level fields from admin level box" do
|
453
|
-
value = "Updated #{version}"
|
454
|
-
field = root.boxes[:admin_level].fields[:root_level]
|
455
|
-
auth_post "/@spontaneous/savebox/#{root.id}/#{root.boxes[:admin_level].schema_id}", "field[#{field.schema_id}][unprocessed_value]" => value
|
461
|
+
auth_post "/@spontaneous/savebox/#{root.id}/#{root.boxes[:root_level].schema_id}", "field[#{field.schema_id}]" => value
|
456
462
|
assert last_response.status == 403, "Should have a permissions error 403 not #{last_response.status}"
|
457
463
|
end
|
458
464
|
|
data/test/unit/test_boxes.rb
CHANGED
@@ -16,7 +16,6 @@ class BoxesTest < MiniTest::Spec
|
|
16
16
|
context "Box definitions" do
|
17
17
|
setup do
|
18
18
|
|
19
|
-
class ::Piece < Spontaneous::Piece; end
|
20
19
|
class ::MyBoxClass < Box; end
|
21
20
|
class ::MyContentClass < Piece; end
|
22
21
|
class ::MyContentClass2 < MyContentClass; end
|
@@ -24,10 +23,9 @@ class BoxesTest < MiniTest::Spec
|
|
24
23
|
end
|
25
24
|
|
26
25
|
teardown do
|
27
|
-
Object.send(:remove_const, :
|
28
|
-
Object.send(:remove_const, :
|
29
|
-
Object.send(:remove_const, :
|
30
|
-
Object.send(:remove_const, :MyBoxClass)
|
26
|
+
Object.send(:remove_const, :MyContentClass2) rescue nil
|
27
|
+
Object.send(:remove_const, :MyContentClass) rescue nil
|
28
|
+
Object.send(:remove_const, :MyBoxClass) rescue nil
|
31
29
|
end
|
32
30
|
|
33
31
|
should "start empty" do
|
@@ -155,6 +153,12 @@ class BoxesTest < MiniTest::Spec
|
|
155
153
|
instance.box1.container.should == instance
|
156
154
|
instance.box1.container.should == instance
|
157
155
|
end
|
156
|
+
|
157
|
+
should "return their owner as content_instance" do
|
158
|
+
MyContentClass.box :box1
|
159
|
+
instance = MyContentClass.new
|
160
|
+
instance.box1.content_instance.should == instance
|
161
|
+
end
|
158
162
|
end
|
159
163
|
|
160
164
|
context "ranges" do
|
@@ -234,7 +238,6 @@ class BoxesTest < MiniTest::Spec
|
|
234
238
|
context "Box classes" do
|
235
239
|
setup do
|
236
240
|
@site.stubs(:template_root).returns(File.expand_path('../../fixtures/templates/boxes', __FILE__))
|
237
|
-
class ::Piece < Spontaneous::Piece; end
|
238
241
|
class ::MyContentClass < ::Piece; end
|
239
242
|
class ::MyBoxClass < Box; end
|
240
243
|
MyBoxClass.field :title, :string
|
@@ -247,9 +250,8 @@ class BoxesTest < MiniTest::Spec
|
|
247
250
|
end
|
248
251
|
|
249
252
|
teardown do
|
250
|
-
Object.send(:remove_const, :
|
251
|
-
Object.send(:remove_const, :
|
252
|
-
Object.send(:remove_const, :MyBoxClass)
|
253
|
+
Object.send(:remove_const, :MyContentClass) rescue nil
|
254
|
+
Object.send(:remove_const, :MyBoxClass) rescue nil
|
253
255
|
end
|
254
256
|
|
255
257
|
should "have fields" do
|
@@ -282,7 +284,7 @@ class BoxesTest < MiniTest::Spec
|
|
282
284
|
field :description, :string
|
283
285
|
end
|
284
286
|
instance = MyContentClass.new
|
285
|
-
assert instance.partners.name.class < Spontaneous::
|
287
|
+
assert instance.partners.name.class < Spontaneous::Field::String
|
286
288
|
instance.partners.name = "Howard"
|
287
289
|
instance.partners.description = "Here is Howard"
|
288
290
|
instance.save
|
@@ -297,7 +299,6 @@ class BoxesTest < MiniTest::Spec
|
|
297
299
|
|
298
300
|
context "Box content" do
|
299
301
|
setup do
|
300
|
-
class ::Piece < Spontaneous::Piece; end
|
301
302
|
class ::BlankContent < ::Piece; end
|
302
303
|
class ::StyledContent < ::Piece; end
|
303
304
|
|
@@ -319,9 +320,8 @@ class BoxesTest < MiniTest::Spec
|
|
319
320
|
end
|
320
321
|
|
321
322
|
teardown do
|
322
|
-
Object.send(:remove_const, :
|
323
|
-
Object.send(:remove_const, :
|
324
|
-
Object.send(:remove_const, :StyledContent)
|
323
|
+
Object.send(:remove_const, :BlankContent) rescue nil
|
324
|
+
Object.send(:remove_const, :StyledContent) rescue nil
|
325
325
|
end
|
326
326
|
|
327
327
|
should "be addable" do
|
@@ -358,7 +358,7 @@ class BoxesTest < MiniTest::Spec
|
|
358
358
|
styled.one << child1
|
359
359
|
styled.two << child2
|
360
360
|
styled.save
|
361
|
-
styled = Content.
|
361
|
+
styled = Content.get styled.id
|
362
362
|
|
363
363
|
styled.one.contents.first.style.name.should == :blank2
|
364
364
|
styled.two.contents.first.style.name.should == :blank3
|
@@ -492,8 +492,8 @@ class BoxesTest < MiniTest::Spec
|
|
492
492
|
box = AChild2.boxes.parents
|
493
493
|
box.title.should == "Things"
|
494
494
|
box.allowed_types(nil).should == [Allowed1, Allowed2, Allowed3, Allowed11, Allowed111]
|
495
|
-
Object.send(:remove_const, :AChild)
|
496
|
-
Object.send(:remove_const, :AChild2)
|
495
|
+
Object.send(:remove_const, :AChild) rescue nil
|
496
|
+
Object.send(:remove_const, :AChild2) rescue nil
|
497
497
|
end
|
498
498
|
|
499
499
|
should "include a subtype's allowed list as well as the supertype's" do
|
@@ -509,11 +509,36 @@ class BoxesTest < MiniTest::Spec
|
|
509
509
|
should "correctly allow addition of subclasses" do
|
510
510
|
Mixed.allowed_types.should == [Allowed11, Allowed111]
|
511
511
|
end
|
512
|
+
|
513
|
+
should "create inline classes if passed a definition block" do
|
514
|
+
allowed = ChildClass.allow :InlineType do
|
515
|
+
field :title
|
516
|
+
end
|
517
|
+
inline_type = allowed.instance_class
|
518
|
+
inline_type.fields.length.should == 1
|
519
|
+
inline_type.fields.first.name.should == :title
|
520
|
+
inline_type.name.should == "ChildClass::InlineType"
|
521
|
+
end
|
522
|
+
|
523
|
+
should "use the given supertype for inline classes" do
|
524
|
+
allowed = ChildClass.allow :InlineType, :supertype => :Allowed1 do
|
525
|
+
field :title
|
526
|
+
end
|
527
|
+
inline_type = allowed.instance_class
|
528
|
+
inline_type.ancestors[0..1].should == [ChildClass::InlineType, Allowed1]
|
529
|
+
end
|
530
|
+
|
531
|
+
should "add the created class to the schema immediately" do
|
532
|
+
allowed = ChildClass.allow :InlineType, :supertype => :Allowed1 do
|
533
|
+
field :title
|
534
|
+
end
|
535
|
+
assert @site.schema.classes.map(&:to_s).include?("ChildClass::InlineType"), "#{@site.schema.classes} does not include ChildClass::InlineType"
|
536
|
+
end
|
512
537
|
end
|
513
538
|
|
514
539
|
context "Box groups" do
|
515
540
|
setup do
|
516
|
-
class ::A <
|
541
|
+
class ::A < ::Piece
|
517
542
|
box_group :inner do
|
518
543
|
box :a
|
519
544
|
box :b
|
@@ -549,9 +574,9 @@ class BoxesTest < MiniTest::Spec
|
|
549
574
|
end
|
550
575
|
|
551
576
|
teardown do
|
552
|
-
Object.send(:remove_const, :A)
|
553
|
-
Object.send(:remove_const, :B)
|
554
|
-
Object.send(:remove_const, :C)
|
577
|
+
Object.send(:remove_const, :A) rescue nil
|
578
|
+
Object.send(:remove_const, :B) rescue nil
|
579
|
+
Object.send(:remove_const, :C) rescue nil
|
555
580
|
end
|
556
581
|
|
557
582
|
should "successfully allocate boxes" do
|