ecrire 0.23.0 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +14 -46
  3. data/lib/ecrire/app/controllers/application_controller.rb +1 -1
  4. data/lib/ecrire/app/controllers/ecrire/{posts_controller.rb → theme_controller.rb} +1 -1
  5. data/lib/ecrire/app/controllers/sessions_controller.rb +1 -1
  6. data/lib/ecrire/app/controllers/static_controller.rb +1 -1
  7. data/lib/ecrire/app/helpers/posts_helper.rb +6 -0
  8. data/lib/ecrire/app/views/layouts/admin/application.html.erb +1 -1
  9. data/lib/ecrire/application.rb +26 -5
  10. data/lib/ecrire/commands/console.rb +0 -1
  11. data/lib/ecrire/commands/new.rb +1 -1
  12. data/lib/ecrire/config/environment.rb +1 -1
  13. data/lib/ecrire/onboarding/controllers/databases_controller.rb +63 -0
  14. data/lib/ecrire/{app → onboarding}/controllers/onboarding_controller.rb +2 -0
  15. data/lib/ecrire/onboarding/controllers/users_controller.rb +30 -0
  16. data/lib/ecrire/onboarding/engine.rb +73 -0
  17. data/lib/ecrire/onboarding/routes.rb +8 -0
  18. data/lib/ecrire/onboarding/views/{onboarding/databases → databases}/index.html.erb +1 -1
  19. data/lib/ecrire/onboarding/views/onboarding/welcome.html.erb +1 -1
  20. data/lib/ecrire/onboarding/views/{onboarding/users → users}/index.html.erb +1 -1
  21. data/lib/ecrire/routes.rb +29 -0
  22. data/lib/ecrire/theme/engine.rb +66 -0
  23. data/lib/ecrire/{template → theme/template}/Gemfile +2 -2
  24. data/lib/ecrire/{template → theme/template}/assets/stylesheets/code.css.scss +1 -0
  25. data/lib/ecrire/theme/template/controllers/posts_controller.rb +2 -0
  26. data/lib/ecrire/theme/template/routes.rb +14 -0
  27. data/lib/ecrire/{template → theme/template}/views/layouts/application.html.erb +1 -1
  28. data/lib/ecrire/version.rb +1 -1
  29. data/test/editor/controllers/sessions_controller_test.rb +5 -2
  30. data/test/editor/helpers/base_helper_test.rb +2 -0
  31. data/test/editor/models/image_test.rb +1 -0
  32. data/test/editor/models/post_test.rb +1 -0
  33. data/test/editor/models/title_test.rb +1 -1
  34. data/test/editor/models/user_test.rb +1 -0
  35. data/test/editor/test_helper.rb +25 -21
  36. data/test/editor/theme/routes.rb +8 -0
  37. data/test/{themes/template → editor/theme}/secrets.yml +2 -0
  38. data/test/initializations/{railtie_test.rb → engine_test.rb} +6 -8
  39. data/test/onboarding/controllers/databases_controller_test.rb +4 -0
  40. data/test/{editor/controllers/base_controller_test.rb → test_controller.rb} +9 -8
  41. data/test/test_helper.rb +31 -0
  42. data/test/test_task.rb +28 -0
  43. metadata +55 -54
  44. data/lib/ecrire/app/controllers/onboarding/databases_controller.rb +0 -67
  45. data/lib/ecrire/app/controllers/onboarding/users_controller.rb +0 -32
  46. data/lib/ecrire/config/onboarding_routes.rb +0 -11
  47. data/lib/ecrire/config/routes.rb +0 -32
  48. data/lib/ecrire/railtie/onboarding.rb +0 -63
  49. data/lib/ecrire/railtie/theme.rb +0 -69
  50. data/lib/ecrire/railtie.rb +0 -30
  51. data/lib/ecrire/tasks/routes.rake +0 -6
  52. data/lib/ecrire/template/controllers/posts_controller.rb +0 -2
  53. data/test/isolation.rb +0 -16
  54. data/test/themes/onboarding/.keep +0 -0
  55. /data/lib/ecrire/{template → theme/template}/Procfile +0 -0
  56. /data/lib/ecrire/{template → theme/template}/Rakefile +0 -0
  57. /data/lib/ecrire/{app/controllers/concerns → theme/template/assets/images}/.keep +0 -0
  58. /data/lib/ecrire/{template → theme/template}/assets/javascripts/base.js.coffee +0 -0
  59. /data/lib/ecrire/{template → theme/template}/assets/stylesheets/base.css.scss +0 -0
  60. /data/lib/ecrire/{template → theme/template}/assets/stylesheets/footer.css.scss +0 -0
  61. /data/lib/ecrire/{template → theme/template}/assets/stylesheets/header.css.scss +0 -0
  62. /data/lib/ecrire/{template → theme/template}/assets/stylesheets/home.css.scss +0 -0
  63. /data/lib/ecrire/{template → theme/template}/config.ru +0 -0
  64. /data/lib/ecrire/{template → theme/template}/helpers/blog_helper.rb +0 -0
  65. /data/lib/ecrire/{template → theme/template}/views/posts/_post.html.erb +0 -0
  66. /data/lib/ecrire/{template → theme/template}/views/posts/index.html.erb +0 -0
  67. /data/lib/ecrire/{template → theme/template}/views/posts/show.html.erb +0 -0
  68. /data/lib/ecrire/{template → theme/template}/views/static/about.html +0 -0
  69. /data/lib/ecrire/{template → theme/template}/views/static/customize/_helper.html +0 -0
  70. /data/lib/ecrire/{template → theme/template}/views/static/customize/_helper_used.html +0 -0
  71. /data/lib/ecrire/{template → theme/template}/views/static/customize/_image.html +0 -0
  72. /data/lib/ecrire/{template → theme/template}/views/static/customize/_index.html +0 -0
  73. /data/lib/ecrire/{template → theme/template}/views/static/customize/_javascript.html +0 -0
  74. /data/lib/ecrire/{template → theme/template}/views/static/customize/_layout.html.erb +0 -0
  75. /data/lib/ecrire/{template → theme/template}/views/static/customize/_post.html +0 -0
  76. /data/lib/ecrire/{template → theme/template}/views/static/customize.html +0 -0
  77. /data/test/{themes/template → editor/theme}/Gemfile +0 -0
  78. /data/test/{themes/template → editor/theme}/assets/javascripts/blog.js.coffee +0 -0
  79. /data/test/{themes/template → editor/theme}/assets/javascripts/post.js.coffee +0 -0
  80. /data/test/{themes/template → editor/theme}/assets/stylesheets/blog.css.scss +0 -0
  81. /data/test/{themes/template → editor/theme}/assets/stylesheets/post.css.scss +0 -0
  82. /data/test/{themes/template → editor/theme}/config.ru +0 -0
  83. /data/test/{themes/template → editor/theme}/views/layouts/application.html.erb +0 -0
  84. /data/test/{themes/template → editor/theme}/views/posts/index.html.erb +0 -0
  85. /data/{lib/ecrire/template/assets/images → test/onboarding/theme}/.keep +0 -0
@@ -1,30 +1,34 @@
1
- require 'rails/all'
2
- require 'ecrire'
3
- require 'rails/test_help'
4
-
5
1
  class ActiveSupport::TestCase
6
- ActiveSupport.test_order = :sorted
7
- self.fixture_path = "#{Dir.pwd}/test/fixtures"
8
- fixtures :all
9
-
10
- # Need to quick boot an instance of Ecrire to check if a user
11
- # exists. It creates a new user if none exists so the editor can be launched
12
- pid = fork do
13
- Dir.chdir Dir.pwd + '/test/themes/template' do
14
- Ecrire::Application.initialize!
15
- ::User.first_or_create!(email: 'test@test.ca', password: 123456)
2
+ begin
3
+ # ActiveRecord's configuration assignation is done at the same time as the connection is tried
4
+ # If it fails, the configurations aren't set in AR::Base.
5
+ # This is why this is set here
6
+ ActiveRecord::Base.configurations = Rails.application.config.database_configuration
16
7
 
8
+ path = Rails.application.paths['db/migrate'].existent
9
+ ActiveRecord::Migrator.migrations_paths = path
10
+ if ActiveRecord::Migrator.needs_migration?
11
+ ActiveRecord::Migrator.migrate(path)
17
12
  end
18
- exit!
13
+ rescue ActiveRecord::NoDatabaseError
14
+ puts 'Database does not exist. Creating...'
15
+ ActiveRecord::Tasks::DatabaseTasks.create_current
16
+ puts 'Database created, migrating now...'
17
+ ActiveRecord::Migrator.migrate(path)
18
+ puts "Migration completed."
19
+ ensure
20
+ ActiveRecord::Migration.maintain_test_schema!
21
+ include ActiveRecord::TestFixtures
22
+ self.fixture_path = "#{Dir.pwd}/test/fixtures/"
23
+ fixtures :all
24
+ Post.reset_column_information
19
25
  end
20
26
 
21
- Process.wait2(pid)
22
27
 
23
- Dir.chdir Dir.pwd + '/test/themes/template' do
24
- Ecrire::Application.initialize!
25
- Rails.application.secrets['s3'] ||= {}
26
- end
28
+ end
27
29
 
28
- include Warden::Test::Helpers
30
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
29
31
 
32
+ def create_fixtures(*fixture_set_names, &block)
33
+ FixtureSet.create_fixtures(ActiveSupport::TestCase.fixture_path, fixture_set_names, {}, &block)
30
34
  end
@@ -0,0 +1,8 @@
1
+ Ecrire::Theme::Engine.routes.draw do
2
+ get '/:year/:month/:id', controller: :posts, action: :show, constraints: { year: /\d+/, month: /\d+/ }, as: "post"
3
+ get '/feed', controller: :posts, action: :index, defaults: { format: :rss }
4
+
5
+ resources :posts, only: [:index]
6
+
7
+ root 'posts#index'
8
+ end
@@ -4,3 +4,5 @@ test:
4
4
  user: postgres
5
5
  secret_key: "2370 128u3o2ujwoi12jw122e12e"
6
6
  secret_key_base: "'Mlkasj alskjkdsla jsdkaljsadlkjasd'"
7
+ s3:
8
+ path: 'yada'
@@ -1,5 +1,3 @@
1
- require "isolation"
2
-
3
1
  class RailtieTest < ActiveSupport::TestCase
4
2
  include ActiveSupport::Testing::Isolation
5
3
 
@@ -10,8 +8,8 @@ class RailtieTest < ActiveSupport::TestCase
10
8
  test 'Ecrire onboards by default' do
11
9
  require 'ecrire'
12
10
  Ecrire::Application.initialize!
13
- assert Ecrire::Railtie.include?(Ecrire::Railtie::Onboarding)
14
- assert !Ecrire::Railtie.include?(Ecrire::Railtie::Theme)
11
+ assert defined?(Ecrire::Onboarding::Engine)
12
+ assert !defined?(Ecrire::Theme::Engine)
15
13
  end
16
14
 
17
15
  test 'load the normal railtie if a secrets.yml can be found' do
@@ -20,8 +18,8 @@ class RailtieTest < ActiveSupport::TestCase
20
18
  require 'ecrire'
21
19
  Ecrire::Application.initialize!
22
20
 
23
- assert Ecrire::Railtie.include?(Ecrire::Railtie::Onboarding)
24
- assert !Ecrire::Railtie.include?(Ecrire::Railtie::Theme)
21
+ assert defined?(Ecrire::Onboarding::Engine)
22
+ assert !defined?(Ecrire::Theme::Engine)
25
23
  end
26
24
  end
27
25
 
@@ -37,8 +35,8 @@ class RailtieTest < ActiveSupport::TestCase
37
35
  require 'ecrire'
38
36
  Ecrire::Application.initialize!
39
37
 
40
- assert !Ecrire::Railtie.include?(Ecrire::Railtie::Onboarding)
41
- assert Ecrire::Railtie.include?(Ecrire::Railtie::Theme)
38
+ assert !defined?(Ecrire::Onboarding::Engine)
39
+ assert defined?(Ecrire::Theme::Engine)
42
40
  # Need to destroy the user here because parallelization is fubar'ed
43
41
  # and it's the most stable way I found it.
44
42
  # All other options seemed to introduce racing conditions.
@@ -0,0 +1,4 @@
1
+ require 'test_controller'
2
+
3
+ class DatabasesControllerTest < TestController
4
+ end
@@ -1,8 +1,12 @@
1
- require 'editor/test_helper'
2
- require 'byebug'
1
+ require 'test_helper'
2
+ require 'warden'
3
3
 
4
- class BaseControllerTest < ActionController::TestCase
5
- include Warden::Test::Helpers
4
+ class TestController < ActionController::TestCase
5
+
6
+ def setup
7
+ @routes = Rails.application.routes
8
+ @controller.env['warden'] = @request.env['warden'] = Warden::Proxy.new(@request.env, self.class.manager)
9
+ end
6
10
 
7
11
  def self.manager
8
12
  @manager ||= Warden::Manager.new(self,
@@ -12,10 +16,6 @@ class BaseControllerTest < ActionController::TestCase
12
16
  })
13
17
  end
14
18
 
15
- def setup
16
- @controller.env['warden'] = @request.env['warden'] = Warden::Proxy.new(@request.env, self.class.manager)
17
- end
18
-
19
19
  def teardown
20
20
  Warden.test_reset!
21
21
  end
@@ -25,3 +25,4 @@ class BaseControllerTest < ActionController::TestCase
25
25
  end
26
26
 
27
27
  end
28
+
@@ -0,0 +1,31 @@
1
+ require 'ecrire'
2
+ require 'rails/all'
3
+
4
+ require 'active_support/testing/autorun'
5
+ require 'active_support/test_case'
6
+ require 'action_controller'
7
+ require 'action_controller/test_case'
8
+ require 'action_dispatch/testing/integration'
9
+ require 'rails/generators/test_case'
10
+
11
+ require 'warden'
12
+ require 'byebug'
13
+
14
+ Dir.chdir ARGV.pop do
15
+ Ecrire::Application.initialize!
16
+ end
17
+
18
+
19
+ class ActiveSupport::TestCase
20
+ ActiveSupport.test_order = :sorted
21
+ end
22
+
23
+ class ActionController::TestCase
24
+ include Warden::Test::Helpers
25
+
26
+ setup do
27
+ @routes = Rails.application.routes
28
+ end
29
+ end
30
+
31
+
data/test/test_task.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'rake/testtask'
2
+
3
+ class Ecrire::TestTask < Rake::TestTask
4
+ attr_accessor :theme
5
+
6
+ def define
7
+ desc @description
8
+ task @name do
9
+ Rake::FileUtilsExt.verbose(@verbose) do
10
+ args =
11
+ "#{ruby_opts_string} #{run_code} " +
12
+ "#{file_list_string} #{option_list}" +
13
+ "#{theme}"
14
+
15
+ ruby args do |ok, status|
16
+ if !ok && status.respond_to?(:signaled?) && status.signaled?
17
+ raise SignalException.new(status.termsig)
18
+ elsif !ok
19
+ fail "Command failed with status (#{status.exitstatus}): " +
20
+ "[ruby #{args}]"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ self
26
+ end
27
+
28
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecrire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pier-Olivier Thibault
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-27 00:00:00.000000000 Z
11
+ date: 2015-03-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Blog engine on Rails
14
14
  email: pothibo@gmail.com
@@ -90,12 +90,8 @@ files:
90
90
  - lib/ecrire/app/controllers/admin/tags_controller.rb
91
91
  - lib/ecrire/app/controllers/admin/titles_controller.rb
92
92
  - lib/ecrire/app/controllers/application_controller.rb
93
- - lib/ecrire/app/controllers/concerns/.keep
94
- - lib/ecrire/app/controllers/ecrire/posts_controller.rb
93
+ - lib/ecrire/app/controllers/ecrire/theme_controller.rb
95
94
  - lib/ecrire/app/controllers/images_controller.rb
96
- - lib/ecrire/app/controllers/onboarding/databases_controller.rb
97
- - lib/ecrire/app/controllers/onboarding/users_controller.rb
98
- - lib/ecrire/app/controllers/onboarding_controller.rb
99
95
  - lib/ecrire/app/controllers/partials_controller.rb
100
96
  - lib/ecrire/app/controllers/sessions_controller.rb
101
97
  - lib/ecrire/app/controllers/static_controller.rb
@@ -175,8 +171,6 @@ files:
175
171
  - lib/ecrire/config/environment/development.rb
176
172
  - lib/ecrire/config/environment/production.rb
177
173
  - lib/ecrire/config/environment/test.rb
178
- - lib/ecrire/config/onboarding_routes.rb
179
- - lib/ecrire/config/routes.rb
180
174
  - lib/ecrire/db/migrate/20131111222709_create_posts.rb
181
175
  - lib/ecrire/db/migrate/20131113200949_create_users.rb
182
176
  - lib/ecrire/db/migrate/20131114205041_add_excerpt_to_post.rb
@@ -213,45 +207,48 @@ files:
213
207
  - lib/ecrire/onboarding/assets/stylesheets/terminal.css.scss
214
208
  - lib/ecrire/onboarding/assets/stylesheets/variables.css.scss
215
209
  - lib/ecrire/onboarding/assets/stylesheets/welcome.css.scss
210
+ - lib/ecrire/onboarding/controllers/databases_controller.rb
211
+ - lib/ecrire/onboarding/controllers/onboarding_controller.rb
212
+ - lib/ecrire/onboarding/controllers/users_controller.rb
213
+ - lib/ecrire/onboarding/engine.rb
214
+ - lib/ecrire/onboarding/routes.rb
215
+ - lib/ecrire/onboarding/views/databases/index.html.erb
216
216
  - lib/ecrire/onboarding/views/layouts/application.html.erb
217
217
  - lib/ecrire/onboarding/views/onboarding/complete.html.erb
218
- - lib/ecrire/onboarding/views/onboarding/databases/index.html.erb
219
- - lib/ecrire/onboarding/views/onboarding/users/index.html.erb
220
218
  - lib/ecrire/onboarding/views/onboarding/welcome.html.erb
221
- - lib/ecrire/railtie.rb
222
- - lib/ecrire/railtie/onboarding.rb
223
- - lib/ecrire/railtie/theme.rb
219
+ - lib/ecrire/onboarding/views/users/index.html.erb
220
+ - lib/ecrire/routes.rb
224
221
  - lib/ecrire/tasks/assets.rake
225
222
  - lib/ecrire/tasks/database.rake
226
- - lib/ecrire/tasks/routes.rake
227
- - lib/ecrire/template/Gemfile
228
- - lib/ecrire/template/Procfile
229
- - lib/ecrire/template/Rakefile
230
- - lib/ecrire/template/assets/images/.keep
231
- - lib/ecrire/template/assets/javascripts/base.js.coffee
232
- - lib/ecrire/template/assets/stylesheets/base.css.scss
233
- - lib/ecrire/template/assets/stylesheets/code.css.scss
234
- - lib/ecrire/template/assets/stylesheets/footer.css.scss
235
- - lib/ecrire/template/assets/stylesheets/header.css.scss
236
- - lib/ecrire/template/assets/stylesheets/home.css.scss
237
- - lib/ecrire/template/config.ru
238
- - lib/ecrire/template/controllers/posts_controller.rb
239
- - lib/ecrire/template/helpers/blog_helper.rb
240
- - lib/ecrire/template/views/layouts/application.html.erb
241
- - lib/ecrire/template/views/posts/_post.html.erb
242
- - lib/ecrire/template/views/posts/index.html.erb
243
- - lib/ecrire/template/views/posts/show.html.erb
244
- - lib/ecrire/template/views/static/about.html
245
- - lib/ecrire/template/views/static/customize.html
246
- - lib/ecrire/template/views/static/customize/_helper.html
247
- - lib/ecrire/template/views/static/customize/_helper_used.html
248
- - lib/ecrire/template/views/static/customize/_image.html
249
- - lib/ecrire/template/views/static/customize/_index.html
250
- - lib/ecrire/template/views/static/customize/_javascript.html
251
- - lib/ecrire/template/views/static/customize/_layout.html.erb
252
- - lib/ecrire/template/views/static/customize/_post.html
223
+ - lib/ecrire/theme/engine.rb
224
+ - lib/ecrire/theme/template/Gemfile
225
+ - lib/ecrire/theme/template/Procfile
226
+ - lib/ecrire/theme/template/Rakefile
227
+ - lib/ecrire/theme/template/assets/images/.keep
228
+ - lib/ecrire/theme/template/assets/javascripts/base.js.coffee
229
+ - lib/ecrire/theme/template/assets/stylesheets/base.css.scss
230
+ - lib/ecrire/theme/template/assets/stylesheets/code.css.scss
231
+ - lib/ecrire/theme/template/assets/stylesheets/footer.css.scss
232
+ - lib/ecrire/theme/template/assets/stylesheets/header.css.scss
233
+ - lib/ecrire/theme/template/assets/stylesheets/home.css.scss
234
+ - lib/ecrire/theme/template/config.ru
235
+ - lib/ecrire/theme/template/controllers/posts_controller.rb
236
+ - lib/ecrire/theme/template/helpers/blog_helper.rb
237
+ - lib/ecrire/theme/template/routes.rb
238
+ - lib/ecrire/theme/template/views/layouts/application.html.erb
239
+ - lib/ecrire/theme/template/views/posts/_post.html.erb
240
+ - lib/ecrire/theme/template/views/posts/index.html.erb
241
+ - lib/ecrire/theme/template/views/posts/show.html.erb
242
+ - lib/ecrire/theme/template/views/static/about.html
243
+ - lib/ecrire/theme/template/views/static/customize.html
244
+ - lib/ecrire/theme/template/views/static/customize/_helper.html
245
+ - lib/ecrire/theme/template/views/static/customize/_helper_used.html
246
+ - lib/ecrire/theme/template/views/static/customize/_image.html
247
+ - lib/ecrire/theme/template/views/static/customize/_index.html
248
+ - lib/ecrire/theme/template/views/static/customize/_javascript.html
249
+ - lib/ecrire/theme/template/views/static/customize/_layout.html.erb
250
+ - lib/ecrire/theme/template/views/static/customize/_post.html
253
251
  - lib/ecrire/version.rb
254
- - test/editor/controllers/base_controller_test.rb
255
252
  - test/editor/controllers/sessions_controller_test.rb
256
253
  - test/editor/helpers/base_helper_test.rb
257
254
  - test/editor/models/image_test.rb
@@ -259,23 +256,27 @@ files:
259
256
  - test/editor/models/title_test.rb
260
257
  - test/editor/models/user_test.rb
261
258
  - test/editor/test_helper.rb
259
+ - test/editor/theme/Gemfile
260
+ - test/editor/theme/assets/javascripts/blog.js.coffee
261
+ - test/editor/theme/assets/javascripts/post.js.coffee
262
+ - test/editor/theme/assets/stylesheets/blog.css.scss
263
+ - test/editor/theme/assets/stylesheets/post.css.scss
264
+ - test/editor/theme/config.ru
265
+ - test/editor/theme/routes.rb
266
+ - test/editor/theme/secrets.yml
267
+ - test/editor/theme/views/layouts/application.html.erb
268
+ - test/editor/theme/views/posts/index.html.erb
262
269
  - test/fixtures/images.yml
263
270
  - test/fixtures/posts.yml
264
271
  - test/fixtures/tags.yml
265
272
  - test/fixtures/titles.yml
266
273
  - test/fixtures/users.yml
267
- - test/initializations/railtie_test.rb
268
- - test/isolation.rb
269
- - test/themes/onboarding/.keep
270
- - test/themes/template/Gemfile
271
- - test/themes/template/assets/javascripts/blog.js.coffee
272
- - test/themes/template/assets/javascripts/post.js.coffee
273
- - test/themes/template/assets/stylesheets/blog.css.scss
274
- - test/themes/template/assets/stylesheets/post.css.scss
275
- - test/themes/template/config.ru
276
- - test/themes/template/secrets.yml
277
- - test/themes/template/views/layouts/application.html.erb
278
- - test/themes/template/views/posts/index.html.erb
274
+ - test/initializations/engine_test.rb
275
+ - test/onboarding/controllers/databases_controller_test.rb
276
+ - test/onboarding/theme/.keep
277
+ - test/test_controller.rb
278
+ - test/test_helper.rb
279
+ - test/test_task.rb
279
280
  homepage: http://pothibo.com
280
281
  licenses:
281
282
  - MIT
@@ -1,67 +0,0 @@
1
- require_relative '../onboarding_controller'
2
-
3
- module Onboarding
4
- class DatabasesController < OnboardingController
5
-
6
- helper_method :user, :password, :database
7
-
8
- def index; end;
9
-
10
- def create
11
- info ||= {
12
- 'adapter' => 'postgresql',
13
- 'database' => database,
14
- 'user' => user,
15
- 'password' => password,
16
- 'encoding' => 'utf8'
17
- }
18
- begin
19
- ActiveRecord::Base.configurations = {
20
- 'development' => info,
21
- 'production' => info
22
- }
23
- ActiveRecord::Base.establish_connection
24
- ActiveRecord::Base.connection
25
- migrate!
26
- rescue Exception => e
27
- @exception = e
28
- ActiveRecord::Base.clear_all_connections!
29
- render 'index' and return
30
- end
31
-
32
- redirect_to :onboarding_users
33
- end
34
-
35
- protected
36
-
37
- private
38
-
39
- def migrate!
40
- ActiveRecord::Tasks::DatabaseTasks.database_configuration = ActiveRecord::Base.configurations
41
- ActiveRecord::Migrator.migrations_paths = ActiveRecord::Tasks::DatabaseTasks.migrations_paths
42
- ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
43
- ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) do |migration|
44
- ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope)
45
- end
46
- end
47
-
48
- def db_params
49
- params.fetch(:database, {})
50
- end
51
-
52
- def user
53
- @user ||= "ecrire#{SecureRandom.hex(2)}"
54
- db_params.fetch(:user, @user)
55
- end
56
-
57
- def password
58
- @password ||= SecureRandom.hex(16)
59
- db_params.fetch(:password, @password)
60
- end
61
-
62
- def database
63
- @database ||= "ecrire"
64
- db_params.fetch(:name, @database)
65
- end
66
- end
67
- end
@@ -1,32 +0,0 @@
1
- module Onboarding
2
- class UsersController < OnboardingController
3
-
4
- helper_method :user
5
-
6
- def index;end;
7
-
8
- def create
9
- @user = User.find_or_initialize_by(email: user_params[:email])
10
- @user.update(user_params)
11
-
12
- if user.errors.blank?
13
- save_configurations!
14
- redirect_to :root
15
- else
16
- render 'index'
17
- end
18
- end
19
-
20
- protected
21
-
22
-
23
- def user_params
24
- params.require(:user).permit(:email, :password, :password_confirmation)
25
- end
26
-
27
- def user
28
- @user ||= User.new
29
- end
30
-
31
- end
32
- end
@@ -1,11 +0,0 @@
1
- Ecrire::Application.routes.draw do
2
-
3
- root 'onboarding#index'
4
-
5
- namespace :onboarding, only: :index do
6
- resources :databases, only: [:index, :create]
7
- resources :users, only: [:index, :create]
8
- end
9
- end
10
-
11
-
@@ -1,32 +0,0 @@
1
- Ecrire::Application.routes.draw do
2
- root 'posts#index'
3
-
4
- get '/:year/:month/:id', controller: :posts, action: :show, constraints: { year: /\d+/, month: /\d+/ }, as: "post"
5
- get '/feed', controller: :posts, action: :index, defaults: { format: :rss }
6
-
7
- resources :posts, only: [:index]
8
-
9
- resource :session, only: [:new, :create, :destroy]
10
-
11
- resources :partials, only: [:show]
12
-
13
- namespace :admin do
14
- root 'posts#index'
15
- resources :posts do
16
- collection do
17
- get 'help', controller: :posts, action: :help
18
- end
19
- resources :tags, only: [:index, :create, :update], module: 'posts'
20
- resources :titles, shallow: true
21
- resource :image, shallow: true
22
- resource :properties, only: [:create, :destroy]
23
- end
24
-
25
- namespace :configurations do
26
- resource :images, only: [:show, :create]
27
- end
28
- end
29
-
30
- get '/:view', to: 'static#show'
31
-
32
- end
@@ -1,63 +0,0 @@
1
- class Ecrire::Railtie
2
- module Onboarding
3
- extend ActiveSupport::Concern
4
- included do
5
- Rails.application.config.active_record.migration_error = :none
6
- ActiveRecord::Base.configurations = {}
7
-
8
- initializer 'ecrire.onboarding.dynamic_settings' do |app|
9
- app.config.secret_key_base = SecureRandom.hex(16)
10
- end
11
-
12
- initializer 'ecrire.onboarding.routes' do |app|
13
- app.routes.clear!
14
-
15
- app.paths.add 'config/routes.rb', with: 'config/onboarding_routes.rb'
16
-
17
- paths = app.paths['config/routes.rb'].existent
18
- app.routes_reloader.paths.clear.unshift(*paths)
19
- app.routes_reloader.route_sets << app.routes
20
- end
21
-
22
- initializer 'ecrire.view_paths' do |app|
23
- ActionController::Base.prepend_view_path paths['onboarding:views'].existent
24
- end
25
-
26
- initializer 'ecrire.assets' do |app|
27
- app.config.assets.paths.concat paths['onboarding:assets'].existent
28
- end
29
-
30
- def paths
31
- @paths ||= begin
32
- paths = Rails::Paths::Root.new(root_path)
33
- paths.add 'onboarding:views', with: 'views'
34
- paths.add 'onboarding:assets', with: 'assets', glob: '*'
35
- paths
36
- end
37
- end
38
-
39
- def root_path
40
- Pathname.new(__FILE__).dirname + '../onboarding/'
41
- end
42
-
43
- # This hack is done because ActiveRecord raise an error that makes
44
- # Ecrire exit which makes it impossible to have an instance working without a
45
- # database. By doing this, it becomes possible to Ecrire to load the server and
46
- # serve the onboarding theme for the user.
47
- ActiveRecord::Railtie.initializers.select do |initializer|
48
- initializer.name.eql? 'active_record.initialize_database'
49
- end.first.instance_variable_set :@block, Proc.new { |app|
50
- ActiveSupport.on_load(:active_record) do
51
- begin
52
- establish_connection
53
- rescue ActiveRecord::NoDatabaseError, ActiveRecord::AdapterNotSpecified => e
54
- app.config.middleware.delete 'ActiveRecord::QueryCache'
55
- app.config.middleware.delete 'ActiveRecord::ConnectionAdapters::ConnectionManagement'
56
- end
57
- end
58
- }
59
-
60
-
61
- end
62
- end
63
- end
@@ -1,69 +0,0 @@
1
- class Ecrire::Railtie
2
- module Theme
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
-
7
- initializer 'ecrire.logs', before: :initialize_logger do |app|
8
- unless Rails.env.test?
9
- app.paths.add "log", with: "log/#{Rails.env}.log"
10
- end
11
- end
12
-
13
- initializer 'ecrire.locales' do |app|
14
- config.i18n.railties_load_path.concat(paths['user:locales'].existent)
15
- end
16
-
17
- initializer 'ecrire.controllers' do |app|
18
- if paths['user:controllers'].existent.any?
19
- app.paths['app/controllers'].concat paths['user:controllers'].existent
20
- end
21
- end
22
-
23
- initializer 'ecrire.helpers' do |app|
24
- if paths['user:helpers'].existent.any?
25
- app.paths['app/helpers'].concat paths['user:helpers'].existent
26
- end
27
- end
28
-
29
- initializer 'ecrire.view_paths' do |app|
30
- ActionController::Base.prepend_view_path paths['user:views'].existent
31
- end
32
-
33
- initializer 'ecrire.assets' do |app|
34
- app.config.assets.paths.concat paths['user:assets'].existent
35
- end
36
-
37
- def paths
38
- @paths ||= begin
39
- paths = Rails::Paths::Root.new(root_path)
40
- paths.add 'user:views', with: 'views'
41
- paths.add 'user:controllers', with: 'controllers', eager_load: true
42
- paths.add 'user:assets', with: 'assets', glob: '*'
43
- paths.add 'user:locales', with: 'locales', glob: '**/*.{rb,yml}'
44
- paths.add 'user:helpers', with: 'helpers', eager_load: true
45
- paths.add 'public', with: 'tmp/public'
46
- paths
47
- end
48
- end
49
-
50
- def root_path(file = 'config.ru')
51
- begin
52
- pathname = Pathname.pwd
53
-
54
- while !(pathname + file).exist? do
55
- pathname = pathname.parent
56
- if pathname.root?
57
- raise "Could not find #{file}. Type 'ecrire new blog_name' to create a new blog"
58
- break
59
- end
60
- end
61
-
62
- pathname
63
- end
64
- end
65
-
66
-
67
- end
68
- end
69
- end