spontaneous 0.2.0.beta5 → 0.2.0.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +39 -0
- data/Gemfile +2 -0
- data/Readme.markdown +4 -4
- data/application/css/core.css.scss +144 -43
- data/application/css/definitions.css.scss +50 -16
- data/application/css/dialogue.css.scss +5 -2
- data/application/css/editing.css.scss +7 -7
- data/application/css/font.css.scss +1 -1
- data/application/css/meta.css.scss +6 -6
- data/application/css/popover.css.scss +6 -6
- data/application/css/top.css.scss +8 -1
- data/application/js/add_alias_dialogue.js +137 -36
- data/application/js/add_home_dialogue.js +10 -10
- data/application/js/ajax.js +26 -26
- data/application/js/authentication.js +2 -2
- data/application/js/box.js +21 -10
- data/application/js/box_container.js +13 -7
- data/application/js/compatibility.js +19 -17
- data/application/js/conflicted_field_dialogue.js +5 -5
- data/application/js/content.js +22 -16
- data/application/js/content_area.js +62 -33
- data/application/js/dialogue.js +16 -16
- data/application/js/dom.js +9 -10
- data/application/js/edit_panel.js +25 -20
- data/application/js/editing.js +21 -8
- data/application/js/entry.js +1 -1
- data/application/js/extensions.js +11 -11
- data/application/js/field/boolean.js +6 -6
- data/application/js/field/date.js +1 -1
- data/application/js/field/file.js +17 -17
- data/application/js/field/image.js +27 -27
- data/application/js/field/markdown.js +72 -71
- data/application/js/field/select.js +9 -9
- data/application/js/field/string.js +3 -3
- data/application/js/field/webvideo.js +2 -2
- data/application/js/field_preview.js +3 -0
- data/application/js/init.js +3 -2
- data/application/js/jquery-selection-position.js +13 -13
- data/application/js/location.js +17 -12
- data/application/js/login.js +2 -2
- data/application/js/meta_view/user_admin.js +101 -101
- data/application/js/metadata.js +1 -1
- data/application/js/page.js +2 -2
- data/application/js/page_browser.js +13 -13
- data/application/js/page_entry.js +1 -1
- data/application/js/panel/root_menu.js +10 -10
- data/application/js/popover.js +6 -5
- data/application/js/popover_view.js +5 -5
- data/application/js/preview.js +10 -4
- data/application/js/progress.js +6 -6
- data/application/js/properties.js +35 -6
- data/application/js/publish.js +43 -43
- data/application/js/require.js +14 -14
- data/application/js/services.js +3 -3
- data/application/js/sharded_upload.js +9 -8
- data/application/js/side_bar.js +5 -5
- data/application/js/state.js +2 -2
- data/application/js/status_bar.js +6 -6
- data/application/js/top_bar.js +97 -65
- data/application/js/types.js +9 -6
- data/application/js/upload.js +4 -4
- data/application/js/upload_manager.js +21 -21
- data/application/js/user.js +1 -1
- data/application/js/vendor/jquery.velocity.min.js +7 -0
- data/application/js/views.js +32 -8
- data/application/js/views/box_view.js +51 -31
- data/application/js/views/page_piece_view.js +17 -15
- data/application/js/views/page_view.js +54 -43
- data/application/js/views/piece_view.js +44 -37
- data/application/static/font/fontawesome-webfont-4f0022f25672c7f501c339cbf98d9117.ttf +0 -0
- data/application/views/index.erb +1 -0
- data/db/migrations/20130114120000_create_revision_tables.rb +2 -1
- data/db/migrations/20130813111009_increase_path_length.rb +11 -2
- data/db/migrations/20140506171823_add_index_to_target_id.rb +11 -0
- data/db/migrations/20140514090204_add_content_hash.rb +59 -0
- data/db/migrations/20140519150253_add_content_hash_timestamp.rb +20 -0
- data/lib/spontaneous.rb +0 -1
- data/lib/spontaneous/asset/environment.rb +77 -15
- data/lib/spontaneous/box.rb +21 -0
- data/lib/spontaneous/capistrano/deploy.rb +1 -1
- data/lib/spontaneous/capistrano/sync.rb +8 -7
- data/lib/spontaneous/change.rb +4 -2
- data/lib/spontaneous/cli/fields.rb +7 -3
- data/lib/spontaneous/cli/generate.rb +2 -0
- data/lib/spontaneous/cli/init.rb +24 -93
- data/lib/spontaneous/cli/init/db.rb +94 -0
- data/lib/spontaneous/cli/init/mysql.rb +17 -0
- data/lib/spontaneous/cli/init/postgresql.rb +33 -0
- data/lib/spontaneous/cli/init/sqlite.rb +14 -0
- data/lib/spontaneous/cli/site.rb +45 -20
- data/lib/spontaneous/collections/box_set.rb +3 -0
- data/lib/spontaneous/collections/entry_set.rb +43 -4
- data/lib/spontaneous/collections/field_set.rb +14 -2
- data/lib/spontaneous/data_mapper.rb +40 -7
- data/lib/spontaneous/data_mapper/content_model.rb +1 -1
- data/lib/spontaneous/data_mapper/content_model/associations.rb +63 -12
- data/lib/spontaneous/data_mapper/content_model/timestamps.rb +9 -14
- data/lib/spontaneous/data_mapper/content_table.rb +4 -2
- data/lib/spontaneous/data_mapper/dataset.rb +31 -2
- data/lib/spontaneous/data_mapper/scope.rb +37 -20
- data/lib/spontaneous/errors.rb +6 -0
- data/lib/spontaneous/facet.rb +20 -10
- data/lib/spontaneous/field/base.rb +8 -1
- data/lib/spontaneous/field/file.rb +28 -3
- data/lib/spontaneous/field/image.rb +2 -0
- data/lib/spontaneous/field/update.rb +6 -0
- data/lib/spontaneous/field/webvideo/vimeo.rb +6 -1
- data/lib/spontaneous/field/webvideo/vine.rb +1 -1
- data/lib/spontaneous/field/webvideo/youtube.rb +1 -1
- data/lib/spontaneous/generators/site.rb +6 -4
- data/lib/spontaneous/generators/site/.gitignore +1 -0
- data/lib/spontaneous/generators/site/Gemfile.tt +3 -3
- data/lib/spontaneous/generators/site/config/{indexes.rb.tt → initializers/indexes.rb.tt} +0 -0
- data/lib/spontaneous/generators/site/config/initializers/publishing.rb.tt +78 -0
- data/lib/spontaneous/generators/site/{config/database.yml.tt → db/mysql2.yml.tt} +7 -6
- data/lib/spontaneous/generators/site/db/postgres.yml.tt +25 -0
- data/lib/spontaneous/generators/site/db/sqlite3.yml.tt +18 -0
- data/lib/spontaneous/generators/site/public/humans.txt.tt +14 -0
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +51 -0
- data/lib/spontaneous/loader.rb +1 -1
- data/lib/spontaneous/logger.rb +1 -1
- data/lib/spontaneous/media/image/optimizer.rb +1 -1
- data/lib/spontaneous/media/image/processor.rb +11 -2
- data/lib/spontaneous/media/image/renderable.rb +2 -0
- data/lib/spontaneous/model.rb +3 -0
- data/lib/spontaneous/model/box/allowed_types.rb +17 -4
- data/lib/spontaneous/model/core.rb +36 -3
- data/lib/spontaneous/model/core/aliases.rb +5 -2
- data/lib/spontaneous/model/core/boxes.rb +6 -0
- data/lib/spontaneous/model/core/cascading_change.rb +38 -0
- data/lib/spontaneous/model/core/content_hash.rb +171 -0
- data/lib/spontaneous/model/core/entries.rb +0 -19
- data/lib/spontaneous/model/core/fields.rb +11 -0
- data/lib/spontaneous/model/core/modifications.rb +22 -21
- data/lib/spontaneous/model/core/render.rb +3 -0
- data/lib/spontaneous/model/core/serialisation.rb +18 -17
- data/lib/spontaneous/model/page.rb +35 -8
- data/lib/spontaneous/model/page/page_tree.rb +20 -8
- data/lib/spontaneous/model/page/paths.rb +79 -50
- data/lib/spontaneous/model/page/singleton.rb +71 -0
- data/lib/spontaneous/model/page/site_map.rb +2 -1
- data/lib/spontaneous/model/page/site_timestamps.rb +2 -2
- data/lib/spontaneous/model/piece.rb +10 -0
- data/lib/spontaneous/output/context.rb +13 -6
- data/lib/spontaneous/output/format.rb +30 -5
- data/lib/spontaneous/output/helpers/script_helper.rb +8 -0
- data/lib/spontaneous/output/helpers/stylesheet_helper.rb +7 -0
- data/lib/spontaneous/output/renderable.rb +16 -0
- data/lib/spontaneous/output/store.rb +1 -1
- data/lib/spontaneous/output/template/renderer.rb +2 -2
- data/lib/spontaneous/page_piece.rb +25 -1
- data/lib/spontaneous/prototypes/box_prototype.rb +13 -0
- data/lib/spontaneous/prototypes/field_prototype.rb +7 -4
- data/lib/spontaneous/publishing.rb +10 -5
- data/lib/spontaneous/publishing/immediate.rb +32 -349
- data/lib/spontaneous/publishing/pipeline.rb +43 -0
- data/lib/spontaneous/publishing/progress.rb +186 -0
- data/lib/spontaneous/publishing/publish.rb +107 -0
- data/lib/spontaneous/publishing/rerender.rb +17 -0
- data/lib/spontaneous/publishing/revision.rb +53 -18
- data/lib/spontaneous/publishing/simultaneous.rb +1 -1
- data/lib/spontaneous/publishing/steps.rb +154 -0
- data/lib/spontaneous/publishing/steps/activate_revision.rb +45 -0
- data/lib/spontaneous/publishing/steps/archive_old_revisions.rb +22 -0
- data/lib/spontaneous/publishing/steps/base_step.rb +49 -0
- data/lib/spontaneous/publishing/steps/copy_static_files.rb +74 -0
- data/lib/spontaneous/publishing/steps/create_revision_directory.rb +24 -0
- data/lib/spontaneous/publishing/steps/generate_rackup_file.rb +51 -0
- data/lib/spontaneous/publishing/steps/generate_search_indexes.rb +24 -0
- data/lib/spontaneous/publishing/steps/render_revision.rb +69 -0
- data/lib/spontaneous/publishing/steps/write_revision_file.rb +43 -0
- data/lib/spontaneous/rack/back.rb +3 -1
- data/lib/spontaneous/rack/back/alias.rb +9 -8
- data/lib/spontaneous/rack/front.rb +1 -1
- data/lib/spontaneous/rack/middleware.rb +7 -4
- data/lib/spontaneous/rack/middleware/transaction.rb +14 -0
- data/lib/spontaneous/rack/page_controller.rb +23 -8
- data/lib/spontaneous/revision.rb +5 -10
- data/lib/spontaneous/schema.rb +5 -0
- data/lib/spontaneous/server.rb +3 -1
- data/lib/spontaneous/site.rb +17 -10
- data/lib/spontaneous/site/publishing.rb +25 -3
- data/lib/spontaneous/site/state.rb +7 -3
- data/lib/spontaneous/tasks/database.rake +5 -10
- data/lib/spontaneous/utils/database/mysql_dumper.rb +5 -1
- data/lib/spontaneous/version.rb +1 -1
- data/spontaneous.gemspec +4 -3
- data/test/fixtures/example_application/config/initializers/initializer1.rb +1 -0
- data/test/fixtures/example_application/config/initializers/initializer2.rb +1 -0
- data/test/fixtures/example_application/config/initializers/publishing.rb +13 -0
- data/test/fixtures/search/config/{indexes.rb → initializers/indexes.rb} +0 -0
- data/test/fixtures/serialisation/root_hash.yaml.erb +10 -4
- data/test/functional/test_application.rb +10 -0
- data/test/functional/test_back.rb +23 -5
- data/test/functional/test_cli.rb +98 -34
- data/test/functional/test_front.rb +7 -3
- data/test/test_helper.rb +35 -28
- data/test/unit/test_alias.rb +20 -3
- data/test/unit/test_assets.rb +58 -30
- data/test/unit/test_changesets.rb +20 -12
- data/test/unit/test_content_hash.rb +496 -0
- data/test/unit/test_context.rb +28 -1
- data/test/unit/test_controllers.rb +96 -61
- data/test/unit/test_crypt.rb +1 -8
- data/test/unit/test_datamapper.rb +95 -19
- data/test/unit/test_features.rb +1 -4
- data/test/unit/test_fields.rb +61 -12
- data/test/unit/test_generators.rb +39 -2
- data/test/unit/test_images.rb +3 -1
- data/test/unit/test_modifications.rb +224 -219
- data/test/unit/test_output_store.rb +10 -0
- data/test/unit/{test_formats.rb → test_outputs.rb} +75 -6
- data/test/unit/test_page.rb +61 -15
- data/test/unit/test_plugins.rb +2 -42
- data/test/unit/test_publishing_pipeline.rb +1050 -0
- data/test/unit/test_render.rb +30 -0
- data/test/unit/test_revisions.rb +110 -2
- data/test/unit/test_schema.rb +4 -0
- data/test/unit/test_search.rb +1 -1
- data/test/unit/test_serialisation.rb +6 -1
- data/test/unit/test_singletons.rb +159 -0
- data/test/unit/test_site.rb +71 -44
- metadata +140 -86
- data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
- data/test/unit/test_publishing.rb +0 -330
@@ -11,25 +11,20 @@ end
|
|
11
11
|
namespace :db do
|
12
12
|
desc "Make a dump of the current database"
|
13
13
|
task :dump do
|
14
|
-
dumpfilename = ENV['dumpfile']
|
15
|
-
if dumpfilename.nil?
|
16
|
-
dumpfilename = "#{Time.now.to_i}.mysql.gz"
|
17
|
-
end
|
18
|
-
dump_file = "tmp/#{dumpfilename}"
|
19
14
|
dumper = Spontaneous::Utils::Database.dumper_for_database
|
20
|
-
|
21
|
-
|
15
|
+
dumpfilename = ENV['dumpfile'] || dumper.dumpfilename
|
16
|
+
dumpfile = "tmp/#{dumpfilename}"
|
17
|
+
dumper.dump(dumpfile)
|
22
18
|
end
|
23
19
|
|
24
20
|
desc "Load a database dump into the local database"
|
25
21
|
task :load do
|
26
22
|
dumpfile = ENV['dumpfile']
|
23
|
+
dumper = Spontaneous::Utils::Database.dumper_for_database
|
27
24
|
if dumpfile.nil?
|
28
|
-
$stderr.puts "Usage: rake spot:database:load dumpfile=/path/to/dump.
|
25
|
+
$stderr.puts "Usage: rake spot:database:load dumpfile=/path/to/dump.#{dumper.name}.gz"
|
29
26
|
exit 1
|
30
27
|
end
|
31
|
-
dumper = Spontaneous::Utils::Database.dumper_for_database
|
32
|
-
# dumper = Spontaneous::Cli::Site::MySQL.new(Spontaneous.database)
|
33
28
|
dumper.load(dumpfile)
|
34
29
|
end
|
35
30
|
end
|
@@ -72,10 +72,14 @@ module Spontaneous
|
|
72
72
|
[database_name, revision_archive_table].join(".")
|
73
73
|
end
|
74
74
|
|
75
|
+
def dumpfilename(time = Time.now)
|
76
|
+
"#{time.strftime('%Y%m%d%H%M%S')}.#{name}.gz"
|
77
|
+
end
|
78
|
+
|
75
79
|
# The whole point of this table's existance is to reduce the
|
76
80
|
# size of the db dump for syncing
|
77
81
|
def revision_archive_table
|
78
|
-
Spontaneous::
|
82
|
+
Spontaneous::instance.model.archive_dataset.first_source.to_s
|
79
83
|
end
|
80
84
|
|
81
85
|
def option(option, add_if_nil=false)
|
data/lib/spontaneous/version.rb
CHANGED
data/spontaneous.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require 'spontaneous/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.required_ruby_version = '>=
|
6
|
+
s.required_ruby_version = '>= 2.0.0'
|
7
7
|
|
8
8
|
s.name = 'spontaneous'
|
9
9
|
s.version = Spontaneous::VERSION
|
@@ -28,8 +28,8 @@ Gem::Specification.new do |s|
|
|
28
28
|
|
29
29
|
s.add_dependency('activesupport', ['~> 4.0'])
|
30
30
|
s.add_dependency('coffee-script', ['~> 2.2'])
|
31
|
-
s.add_dependency('bcrypt
|
32
|
-
s.add_dependency('bundler', ['
|
31
|
+
s.add_dependency('bcrypt', ['~> 3.1'])
|
32
|
+
s.add_dependency('bundler', ['~> 1.5'])
|
33
33
|
s.add_dependency('cutaneous', ['~> 0.2'])
|
34
34
|
s.add_dependency('erubis', ['~> 2.6'])
|
35
35
|
s.add_dependency('fog', ['~> 1.17'])
|
@@ -57,6 +57,7 @@ Gem::Specification.new do |s|
|
|
57
57
|
|
58
58
|
s.add_development_dependency('minitest', ['~> 4.7.0'])
|
59
59
|
s.add_development_dependency('minitest-colorize', ['~> 0.0.5'])
|
60
|
+
s.add_development_dependency('timecop', ['~> 0.7'])
|
60
61
|
s.add_development_dependency('mocha', ['~> 0.13.2'])
|
61
62
|
s.add_development_dependency('rack-test', ['~> 0.5'])
|
62
63
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
INITIALIZER1_RUN=true
|
@@ -0,0 +1 @@
|
|
1
|
+
INITIALIZER2_RUN=true
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
Site.output_store(:File, dir: Site.revision_root)
|
3
|
+
|
4
|
+
Site.publish do
|
5
|
+
run :create_revision_directory
|
6
|
+
run :render_revision
|
7
|
+
run :generate_search_indexes
|
8
|
+
run :copy_static_files
|
9
|
+
run :generate_rackup_file
|
10
|
+
run :activate_revision
|
11
|
+
run :write_revision_file
|
12
|
+
run :archive_old_revisions
|
13
|
+
end
|
File without changes
|
@@ -6,7 +6,9 @@
|
|
6
6
|
:uid: home
|
7
7
|
:path: /
|
8
8
|
:hidden: false
|
9
|
+
:private: false
|
9
10
|
:is_page: true
|
11
|
+
:page_id: <%= @root.id %>
|
10
12
|
:slug: ""
|
11
13
|
:type_id: <%= SerialisedPage.schema_id.to_s %>
|
12
14
|
:fields:
|
@@ -22,7 +24,7 @@
|
|
22
24
|
:id: <%= SerialisedPage.field_prototypes[:direction].schema_id.to_s %>
|
23
25
|
:name: direction
|
24
26
|
|
25
|
-
- :unprocessed_value: /images/home.jpg
|
27
|
+
- :unprocessed_value: "[\"/images/home.jpg\",\"\"]"
|
26
28
|
:version: 1
|
27
29
|
:id: <%= SerialisedPage.field_prototypes[:thumbnail].schema_id.to_s %>
|
28
30
|
:name: thumbnail
|
@@ -65,7 +67,7 @@
|
|
65
67
|
:id: <%= SerialisedPiece.field_prototypes[:date].schema_id.to_s %>
|
66
68
|
:name: date
|
67
69
|
|
68
|
-
- :unprocessed_value: ""
|
70
|
+
- :unprocessed_value: "[\"\",\"\"]"
|
69
71
|
:version: 0
|
70
72
|
:id: <%= SerialisedPiece.field_prototypes[:image].schema_id.to_s %>
|
71
73
|
:name: image
|
@@ -100,9 +102,11 @@
|
|
100
102
|
:uid: about
|
101
103
|
:style: <%= @sitting_style.to_s %>
|
102
104
|
:hidden: true
|
105
|
+
:private: false
|
103
106
|
:is_page: true
|
104
107
|
:slug: about
|
105
108
|
:id: <%= @child.id %>
|
109
|
+
:page_id: <%= @child.id %>
|
106
110
|
:type_id: <%= SerialisedPage.schema_id.to_s %>
|
107
111
|
:path: /about
|
108
112
|
:depth: 2
|
@@ -123,7 +127,7 @@
|
|
123
127
|
:id: <%= SerialisedPage.field_prototypes[:direction].schema_id.to_s %>
|
124
128
|
:name: direction
|
125
129
|
|
126
|
-
- :unprocessed_value: /images/thumb.jpg
|
130
|
+
- :unprocessed_value: "[\"/images/thumb.jpg\",\"\"]"
|
127
131
|
:version: 1
|
128
132
|
:id: <%= SerialisedPage.field_prototypes[:thumbnail].schema_id.to_s %>
|
129
133
|
:name: thumbnail
|
@@ -135,6 +139,7 @@
|
|
135
139
|
|
136
140
|
:is_page: false
|
137
141
|
:id: <%= @piece1.id %>
|
142
|
+
:page_id: <%= @root.id %>
|
138
143
|
- :type: SerialisedPiece
|
139
144
|
:type_id: <%= SerialisedPiece.schema_id.to_s %>
|
140
145
|
:label: label2
|
@@ -162,7 +167,7 @@
|
|
162
167
|
:id: <%= SerialisedPiece.field_prototypes[:date].schema_id.to_s %>
|
163
168
|
:name: date
|
164
169
|
|
165
|
-
- :unprocessed_value: ""
|
170
|
+
- :unprocessed_value: "[\"\",\"\"]"
|
166
171
|
:version: 0
|
167
172
|
:id: <%= SerialisedPiece.field_prototypes[:image].schema_id.to_s %>
|
168
173
|
:name: image
|
@@ -183,6 +188,7 @@
|
|
183
188
|
:hidden: false
|
184
189
|
:is_page: false
|
185
190
|
:id: <%= @piece2.id %>
|
191
|
+
:page_id: <%= @root.id %>
|
186
192
|
:boxes:
|
187
193
|
- :entries: []
|
188
194
|
|
@@ -56,6 +56,16 @@ describe "Application" do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
|
60
|
+
describe "initializers" do
|
61
|
+
it "all run" do
|
62
|
+
defined?(INITIALIZER1_RUN).must_equal "constant"
|
63
|
+
INITIALIZER1_RUN.must_equal true
|
64
|
+
defined?(INITIALIZER2_RUN).must_equal "constant"
|
65
|
+
INITIALIZER2_RUN.must_equal true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
59
69
|
describe "back, development" do
|
60
70
|
|
61
71
|
before do
|
@@ -896,7 +896,7 @@ describe "Back" do
|
|
896
896
|
|
897
897
|
it "adds an alias to a box" do
|
898
898
|
home.featured_jobs.contents.length.must_equal 0
|
899
|
-
auth_post "/@spontaneous/alias/#{home.id}/#{HomePage.boxes[:featured_jobs].schema_id.to_s}", 'alias_id' => LinkedJob.schema_id.to_s, '
|
899
|
+
auth_post "/@spontaneous/alias/#{home.id}/#{HomePage.boxes[:featured_jobs].schema_id.to_s}", 'alias_id' => LinkedJob.schema_id.to_s, 'target_ids' => Job.first.id, "position" => 0
|
900
900
|
assert last_response.ok?, "Recieved #{last_response.status} not 200"
|
901
901
|
last_response.content_type.must_equal "application/json;charset=utf-8"
|
902
902
|
home.reload
|
@@ -908,7 +908,25 @@ describe "Back" do
|
|
908
908
|
:position => 0,
|
909
909
|
:entry => home.featured_jobs.contents.first.export(user)
|
910
910
|
}
|
911
|
-
Spot::JSON.parse(last_response.body).must_equal required_response
|
911
|
+
Spot::JSON.parse(last_response.body).first.must_equal required_response
|
912
|
+
end
|
913
|
+
|
914
|
+
it "allows for adding multiple aliases to a box" do
|
915
|
+
home.featured_jobs.contents.length.must_equal 0
|
916
|
+
jobs = Job.all[0..1]
|
917
|
+
auth_post "/@spontaneous/alias/#{home.id}/#{HomePage.boxes[:featured_jobs].schema_id.to_s}", 'alias_id' => LinkedJob.schema_id.to_s, 'target_ids' => jobs.map(&:id), "position" => 0
|
918
|
+
assert last_response.ok?, "Recieved #{last_response.status} not 200"
|
919
|
+
home.reload
|
920
|
+
home.featured_jobs.contents.length.must_equal 2
|
921
|
+
home.featured_jobs.each_with_index do |a, i|
|
922
|
+
assert a.alias?
|
923
|
+
a.target.must_equal jobs[i]
|
924
|
+
end
|
925
|
+
response = Spot::JSON.parse(last_response.body)
|
926
|
+
response[0][:position].must_equal 0
|
927
|
+
response[1][:position].must_equal 1
|
928
|
+
response[0][:entry].must_equal home.featured_jobs[0].export(user)
|
929
|
+
response[1][:entry].must_equal home.featured_jobs[1].export(user)
|
912
930
|
end
|
913
931
|
|
914
932
|
it "adds an alias to a box at any position" do
|
@@ -917,7 +935,7 @@ describe "Back" do
|
|
917
935
|
home.featured_jobs << Job.new
|
918
936
|
home.save.reload
|
919
937
|
home.featured_jobs.contents.length.must_equal 3
|
920
|
-
auth_post "/@spontaneous/alias/#{home.id}/#{HomePage.boxes[:featured_jobs].schema_id.to_s}", 'alias_id' => LinkedJob.schema_id.to_s, '
|
938
|
+
auth_post "/@spontaneous/alias/#{home.id}/#{HomePage.boxes[:featured_jobs].schema_id.to_s}", 'alias_id' => LinkedJob.schema_id.to_s, 'target_ids' => Job.first.id, "position" => 2
|
921
939
|
assert last_response.ok?, "Recieved #{last_response.status} not 200"
|
922
940
|
last_response.content_type.must_equal "application/json;charset=utf-8"
|
923
941
|
home.reload
|
@@ -929,7 +947,7 @@ describe "Back" do
|
|
929
947
|
:position => 2,
|
930
948
|
:entry => home.featured_jobs[2].export(user)
|
931
949
|
}
|
932
|
-
Spot::JSON.parse(last_response.body).must_equal required_response
|
950
|
+
Spot::JSON.parse(last_response.body).first.must_equal required_response
|
933
951
|
end
|
934
952
|
|
935
953
|
|
@@ -951,7 +969,7 @@ describe "Back" do
|
|
951
969
|
end
|
952
970
|
box = home.boxes[:featured_jobs]
|
953
971
|
box._prototype.allow LinkedSomething
|
954
|
-
auth_post "/@spontaneous/alias/#{home.id}/#{box.schema_id.to_s}", 'alias_id' => LinkedSomething.schema_id.to_s, '
|
972
|
+
auth_post "/@spontaneous/alias/#{home.id}/#{box.schema_id.to_s}", 'alias_id' => LinkedSomething.schema_id.to_s, 'target_ids' => @target_id, "position" => 0
|
955
973
|
assert last_response.status == 200, "Expected a 200 but got #{last_response.status}"
|
956
974
|
home.reload
|
957
975
|
a = home.featured_jobs[0]
|
data/test/functional/test_cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'foreman/engine/cli'
|
2
|
+
require 'thor'
|
2
3
|
|
3
4
|
|
4
5
|
|
@@ -9,15 +10,35 @@ describe "CLI" do
|
|
9
10
|
let(:cli) { Spontaneous::Cli }
|
10
11
|
let(:root) { cli::Root }
|
11
12
|
|
13
|
+
def run_command(cmd)
|
14
|
+
quietly do
|
15
|
+
root.start(cmd)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_expectation(method, cmd = cmd)
|
20
|
+
quietly do
|
21
|
+
cmd.any_instance.expects(method)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "Init" do
|
26
|
+
let(:cmd) { cli::Init }
|
27
|
+
it "maps 'spot init' to Init#init" do
|
28
|
+
set_expectation(:initialize_size)
|
29
|
+
run_command(["init"])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
12
33
|
describe "Console" do
|
13
34
|
let(:cmd) { cli::Console }
|
14
35
|
it "maps 'spot console' to Console#open" do
|
15
|
-
|
16
|
-
|
36
|
+
set_expectation(:open_console)
|
37
|
+
run_command(["console"])
|
17
38
|
end
|
18
39
|
it "maps 'spot c' to Console#open" do
|
19
|
-
|
20
|
-
|
40
|
+
set_expectation(:open_console)
|
41
|
+
run_command(["c"])
|
21
42
|
end
|
22
43
|
end
|
23
44
|
|
@@ -34,59 +55,59 @@ describe "CLI" do
|
|
34
55
|
end
|
35
56
|
|
36
57
|
it "maps 'spot server' to Server#start" do
|
37
|
-
|
38
|
-
|
58
|
+
set_expectation(:start)
|
59
|
+
run_command(["server"])
|
39
60
|
end
|
40
61
|
|
41
62
|
it "'spot server' launches front & back" do
|
42
63
|
expect_subcommand_launch
|
43
|
-
|
64
|
+
run_command(["server"])
|
44
65
|
end
|
45
66
|
|
46
67
|
it "'spot s' launches front & back" do
|
47
68
|
expect_subcommand_launch
|
48
|
-
|
69
|
+
run_command(["s"])
|
49
70
|
end
|
50
71
|
|
51
72
|
it "maps 'spot server back' to Server#back" do
|
52
73
|
silence_logger do
|
53
|
-
|
54
|
-
|
74
|
+
set_expectation(:start_server).with(:back)
|
75
|
+
run_command(["server", "back"])
|
55
76
|
end
|
56
77
|
end
|
57
78
|
|
58
79
|
it "maps 'spot s back' to Server#back" do
|
59
80
|
silence_logger do
|
60
|
-
|
61
|
-
|
81
|
+
set_expectation(:start_server).with(:back)
|
82
|
+
run_command(["s", "back"])
|
62
83
|
end
|
63
84
|
end
|
64
85
|
|
65
86
|
it "maps 'spot server front' to Server#front" do
|
66
87
|
silence_logger do
|
67
|
-
|
68
|
-
|
88
|
+
set_expectation(:start_server).with(:front)
|
89
|
+
run_command(["server", "front"])
|
69
90
|
end
|
70
91
|
end
|
71
92
|
|
72
93
|
it "maps 'spot s front' to Server#front" do
|
73
94
|
silence_logger do
|
74
|
-
|
75
|
-
|
95
|
+
set_expectation(:start_server).with(:front)
|
96
|
+
run_command(["s", "front"])
|
76
97
|
end
|
77
98
|
end
|
78
99
|
|
79
100
|
it "maps 'spot server tasks' to Server#tasks" do
|
80
101
|
silence_logger do
|
81
|
-
|
82
|
-
|
102
|
+
set_expectation(:start_simultaneous)
|
103
|
+
run_command(["server", "tasks"])
|
83
104
|
end
|
84
105
|
end
|
85
106
|
|
86
107
|
it "maps 'spot s tasks' to Server#tasks" do
|
87
108
|
silence_logger do
|
88
|
-
|
89
|
-
|
109
|
+
set_expectation(:start_simultaneous)
|
110
|
+
run_command(["s", "tasks"])
|
90
111
|
end
|
91
112
|
end
|
92
113
|
end
|
@@ -94,36 +115,37 @@ describe "CLI" do
|
|
94
115
|
describe "User" do
|
95
116
|
let(:cmd) { cli::User }
|
96
117
|
it "maps 'spot user' to User#add" do
|
97
|
-
|
98
|
-
|
118
|
+
set_expectation(:add_user)
|
119
|
+
run_command(["user"])
|
99
120
|
end
|
100
121
|
|
101
122
|
it "maps 'spot user add' to User#add" do
|
102
|
-
|
103
|
-
|
123
|
+
set_expectation(:add_user)
|
124
|
+
run_command(["user", "add"])
|
104
125
|
end
|
105
126
|
|
106
127
|
it "maps 'spot user list' to User#list" do
|
107
|
-
|
108
|
-
|
128
|
+
set_expectation(:list_users)
|
129
|
+
run_command(["user", "list"])
|
109
130
|
end
|
110
131
|
|
111
132
|
it "maps 'spot user authenticate' to User#authenticate" do
|
112
|
-
|
113
|
-
|
133
|
+
set_expectation(:authenticate_user).with("garry", "fishingrod")
|
134
|
+
run_command(["user", "authenticate", "garry", "fishingrod"])
|
114
135
|
end
|
115
136
|
end
|
137
|
+
|
116
138
|
describe "Generate" do
|
117
139
|
let(:cmd) { cli::Generate }
|
118
140
|
let(:generator) { ::Spontaneous::Generators::Site }
|
119
141
|
it "maps 'generate site' to Generate#site" do
|
120
142
|
generator.expects(:start).with([])
|
121
|
-
|
143
|
+
run_command(["generate", "site"])
|
122
144
|
end
|
123
145
|
|
124
146
|
it "maps 'generate example.com' to Generate#site" do
|
125
147
|
generator.expects(:start).with(['example.com'])
|
126
|
-
|
148
|
+
run_command(["generate", "example.com"])
|
127
149
|
end
|
128
150
|
|
129
151
|
end
|
@@ -131,16 +153,58 @@ describe "CLI" do
|
|
131
153
|
describe "Assets" do
|
132
154
|
let(:cmd) { cli::Assets }
|
133
155
|
it "maps 'spot assets compile' to Assets#compile" do
|
134
|
-
|
135
|
-
|
156
|
+
set_expectation(:compile_assets)
|
157
|
+
run_command(["assets", "compile", "--destination=/tmp/destination"])
|
136
158
|
end
|
137
159
|
end
|
138
160
|
|
139
161
|
describe "Content" do
|
140
162
|
let(:cmd) { cli::Content }
|
141
163
|
it "maps 'spot content clean' to Content#clean" do
|
142
|
-
|
143
|
-
|
164
|
+
set_expectation(:clean_content)
|
165
|
+
run_command(["content", "clean"])
|
144
166
|
end
|
145
167
|
end
|
168
|
+
|
169
|
+
describe "Fields" do
|
170
|
+
let(:cmd) { cli::Fields }
|
171
|
+
it "maps 'spot fields update' to Fields#update" do
|
172
|
+
set_expectation(:update_fields)
|
173
|
+
run_command(["fields", "update"])
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "Site" do
|
178
|
+
let(:cmd) { cli::Site }
|
179
|
+
it "maps 'spot site dump' to Site#dump" do
|
180
|
+
set_expectation(:dump_site_data)
|
181
|
+
run_command(["site", "dump"])
|
182
|
+
end
|
183
|
+
|
184
|
+
it "maps 'spot site load' to Site#load" do
|
185
|
+
set_expectation(:load_site_data)
|
186
|
+
run_command(["site", "load"])
|
187
|
+
end
|
188
|
+
|
189
|
+
it "maps 'spot site publish' to Site#publish" do
|
190
|
+
set_expectation(:publish_site)
|
191
|
+
run_command(["site", "publish"])
|
192
|
+
end
|
193
|
+
|
194
|
+
it "maps 'spot site render' to Site#render" do
|
195
|
+
set_expectation(:render_site)
|
196
|
+
run_command(["site", "render"])
|
197
|
+
end
|
198
|
+
|
199
|
+
it "maps 'spot site revision' to Site#revision" do
|
200
|
+
set_expectation(:show_site_revision)
|
201
|
+
run_command(["site", "revision"])
|
202
|
+
end
|
203
|
+
|
204
|
+
it "maps 'spot site browse' to Site#browse" do
|
205
|
+
set_expectation(:browse_site)
|
206
|
+
run_command(["site", "browse"])
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
146
210
|
end
|