lanes 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -0
  3. data/Gemfile +2 -3
  4. data/client/lanes/boot.jsx +1 -1
  5. data/client/lanes/index.js +0 -11
  6. data/client/lanes/jest/matchers.js +14 -0
  7. data/{lib/js/jest/mocks.js → client/lanes/jest/mocks/fetch.js} +1 -1
  8. data/client/lanes/models/base.js +0 -32
  9. data/client/lanes/screens/definition.js +7 -8
  10. data/client/lanes/screens/index.js +24 -240
  11. data/client/lanes/workspace/menu.jsx +3 -34
  12. data/client/lanes/workspace/screen.jsx +3 -3
  13. data/config/routes.rb +2 -0
  14. data/config/screens.rb +2 -2
  15. data/lanes.gemspec +10 -7
  16. data/lib/lanes/access/authentication_provider.rb +4 -4
  17. data/lib/lanes/api.rb +1 -0
  18. data/lib/lanes/api/default_routes.rb +1 -1
  19. data/lib/lanes/api/handlers/screens.rb +26 -0
  20. data/lib/lanes/api/helper_methods.rb +5 -4
  21. data/lib/lanes/cli.rb +7 -0
  22. data/lib/lanes/command/app.rb +4 -6
  23. data/lib/lanes/command/client_config.rb +59 -0
  24. data/lib/lanes/command/generate_model.rb +4 -4
  25. data/lib/lanes/command/jest.rb +14 -29
  26. data/lib/lanes/command/model_attribute.rb +6 -1
  27. data/lib/lanes/command/named_command.rb +1 -0
  28. data/lib/lanes/command/puma.rb +56 -0
  29. data/lib/lanes/command/server.rb +21 -18
  30. data/lib/lanes/command/webpack.rb +54 -0
  31. data/lib/lanes/extension.rb +0 -7
  32. data/lib/lanes/guard_tasks.rb +21 -20
  33. data/lib/lanes/rake_tasks.rb +13 -0
  34. data/lib/lanes/reloadable_sinatra.rb +24 -0
  35. data/lib/lanes/screen.rb +15 -6
  36. data/lib/lanes/spec_helper.rb +70 -136
  37. data/lib/lanes/version.rb +1 -1
  38. data/package.json +1 -1
  39. data/spec/server/api/controller_base_spec.rb +61 -53
  40. data/spec/server/spec_helper.rb +37 -45
  41. data/templates/client/models/model.js +17 -0
  42. data/templates/config/database.yml +2 -1
  43. data/templates/config/jest.config.json +14 -0
  44. data/templates/config/jest/babel-transform.js +47 -0
  45. data/templates/config/routes.rb +3 -2
  46. data/templates/config/webpack.config.js +1 -1
  47. data/templates/js/jest.config.json +2 -10
  48. data/templates/spec/client/models/model.spec.js +10 -0
  49. data/templates/spec/client/setup.js +9 -0
  50. data/templates/spec/server/spec_helper.rb +3 -11
  51. metadata +40 -41
  52. data/lib/js/jest.config.json +0 -14
  53. data/lib/js/jest/fileMock.js +0 -1
  54. data/lib/js/jest/setup.js +0 -26
  55. data/lib/js/jest/stubs/screen-definitions.js +0 -0
  56. data/lib/js/jest/styleMock.js +0 -1
  57. data/lib/js/webpack.config.js +0 -93
  58. data/lib/lanes/hot_reload_plugin.rb +0 -47
  59. data/lib/lanes/webpack.rb +0 -73
  60. data/spec/server/api/coffeescript_processor_spec.rb +0 -116
  61. data/templates/client/models/Model.coffee +0 -17
  62. data/templates/spec/client/models/ModelSpec.coffee +0 -5
@@ -1,5 +1,5 @@
1
1
  module Lanes
2
2
 
3
- VERSION = "0.8.2"
3
+ VERSION = "0.8.3"
4
4
 
5
5
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lanes-framework",
3
- "version": "0.6.3",
3
+ "version": "0.7.0",
4
4
  "description": "Lanes",
5
5
  "main": "index.js",
6
6
  "repository": "https://github.com/argosity/lanes",
@@ -1,77 +1,85 @@
1
1
  require_relative "../spec_helper"
2
2
  require 'lanes/access/user'
3
3
 
4
- class ControllerBaseSpec < Lanes::TestCase
5
-
4
+ describe "ControllerBase" do # < Lanes::TestCase
6
5
  include TestingModels
7
6
 
8
- def test_record_retrieval
7
+
8
+ it "can retrieve" do
9
9
  1.upto(10){|i| TestModel.create!(id: i, name:'test') }
10
10
  controller = Lanes::API::ControllerBase.new(TestModel,
11
11
  Lanes::API::AuthenticationProvider.new({}),
12
12
  {id: 1})
13
- assert_equal(controller.send(:perform_retrieval), {
13
+ expect(controller.send(:perform_retrieval)).to eq({
14
14
  :success=>true, :message=>"Retrieve succeeded",
15
15
  :data=>{"id"=>1, "bt_id"=>nil, "name"=>"test", "number"=>nil}
16
16
  })
17
17
  end
18
18
 
19
- def test_single_update
20
- TestModel.create!(id: 1, name:'Joe')
21
- controller = Lanes::API::ControllerBase.new(TestModel,
22
- Lanes::API::AuthenticationProvider.new({}),
23
- {id: 1}, {name:'Bob'})
24
- assert_equal(controller.send(:perform_single_update), {
25
- :success=>true, :message=>"Update succeeded",
26
- :data=>{"id"=>1, "bt_id"=>nil, "name"=>"Bob", "number"=>nil}
27
- })
28
- assert_equal TestModel.where(id: 1).first.name, 'Bob'
19
+ let(:person) do
20
+ stub_model Person, id: 1, name: 'joe'
29
21
  end
30
22
 
31
- def test_multiple_updates
32
- TestModel.create!(id: 1, name:'Joe')
33
- TestModel.create!(id: 2, name:'Bob')
34
- def TestModel.access_limits_for_query(query, user, params)
35
- query.where(name:'Joe')
36
- end
37
- controller = Lanes::API::ControllerBase.new(TestModel,
38
- Lanes::API::AuthenticationProvider.new({}),
39
- {},
40
- [{'id'=>1}, {'id'=>2}])
23
+ fit "can make a single update" do
24
+ Person.new
41
25
 
42
- assert_equal( controller.send(:perform_multiple_updates), {
43
- :success=>true,
44
- :message=>"Update succeeded",
45
- :data=>[{"id"=>1, "bt_id"=>nil, "name"=>"Joe", "number"=>nil}]
46
- })
26
+ # TestModel.create!(id: 1, name:'Joe')
27
+ # controller = Lanes::API::ControllerBase.new(TestModel,
28
+ # Lanes::API::AuthenticationProvider.new({}),
29
+ # {id: 1}, {name:'Bob'})
30
+ # expect(controller.send(:perform_single_update)).to(
31
+ # eq({
32
+ # :success=>true, :message=>"Update succeeded",
33
+ # :data=>{"id"=>1, "bt_id"=>nil, "name"=>"Bob", "number"=>nil}
34
+ # })
35
+ # )
36
+ # expect(TestModel.where(id: 1).first.name).to eq('Bob')
47
37
  end
48
38
 
49
- def test_single_destroy
50
- TestModel.create!(id: 1, name:'Joe')
51
- controller = Lanes::API::ControllerBase.new(TestModel,
52
- Lanes::API::AuthenticationProvider.new({}),
53
- {id: 1}, {})
54
- assert_equal( controller.send(:perform_single_destroy), {
55
- :success=>true, :message=>"Destroy succeeded", :data=>[]
56
- })
57
- assert_empty TestModel.where(id: 1).to_a
58
- end
39
+ # def test_multiple_updates
40
+ # TestModel.create!(id: 1, name:'Joe')
41
+ # TestModel.create!(id: 2, name:'Bob')
42
+ # def TestModel.access_limits_for_query(query, user, params)
43
+ # query.where(name:'Joe')
44
+ # end
45
+ # controller = Lanes::API::ControllerBase.new(TestModel,
46
+ # Lanes::API::AuthenticationProvider.new({}),
47
+ # {},
48
+ # [{'id'=>1}, {'id'=>2}])
59
49
 
50
+ # assert_equal( controller.send(:perform_multiple_updates), {
51
+ # :success=>true,
52
+ # :message=>"Update succeeded",
53
+ # :data=>[{"id"=>1, "bt_id"=>nil, "name"=>"Joe", "number"=>nil}]
54
+ # })
55
+ # end
60
56
 
61
- def test_multiple_destroy
62
- TestModel.create!(id: 1, name:'Joe')
63
- TestModel.create!(id: 2, name:'Bob')
57
+ # def test_single_destroy
58
+ # TestModel.create!(id: 1, name:'Joe')
59
+ # controller = Lanes::API::ControllerBase.new(TestModel,
60
+ # Lanes::API::AuthenticationProvider.new({}),
61
+ # {id: 1}, {})
62
+ # assert_equal( controller.send(:perform_single_destroy), {
63
+ # :success=>true, :message=>"Destroy succeeded", :data=>[]
64
+ # })
65
+ # assert_empty TestModel.where(id: 1).to_a
66
+ # end
64
67
 
65
- controller = Lanes::API::ControllerBase.new(TestModel,
66
- Lanes::API::AuthenticationProvider.new({}),
67
- {},
68
- [{'id'=>1}, {'id'=>2}])
69
- assert_equal( controller.send(:perform_multiple_destroy), {
70
- :success=>true,
71
- :message=>"Destroy succeeded",
72
- :data=>[]
73
- })
74
- assert_empty TestModel.all.to_a
75
- end
68
+
69
+ # def test_multiple_destroy
70
+ # TestModel.create!(id: 1, name:'Joe')
71
+ # TestModel.create!(id: 2, name:'Bob')
72
+
73
+ # controller = Lanes::API::ControllerBase.new(TestModel,
74
+ # Lanes::API::AuthenticationProvider.new({}),
75
+ # {},
76
+ # [{'id'=>1}, {'id'=>2}])
77
+ # assert_equal( controller.send(:perform_multiple_destroy), {
78
+ # :success=>true,
79
+ # :message=>"Destroy succeeded",
80
+ # :data=>[]
81
+ # })
82
+ # assert_empty TestModel.all.to_a
83
+ # end
76
84
 
77
85
  end
@@ -1,15 +1,9 @@
1
1
  require "lanes/spec_helper"
2
2
  require_relative "minitest_assertions"
3
- require "active_record_mocks"
4
-
5
3
  require 'lanes/command'
6
-
7
- require 'mocha/mini_test'
8
-
4
+ require "temping"
9
5
  require "shrine/storage/memory"
10
6
 
11
- # Shrine.storages = {
12
- # }
13
7
  require "shrine"
14
8
  require "shrine/storage/file_system"
15
9
 
@@ -18,44 +12,41 @@ Lanes::Concerns::AssetUploader.storages = {
18
12
  store: Shrine::Storage::Memory.new,
19
13
  }
20
14
 
15
+ RSpec.configure do |config|
16
+ config.after do
17
+ Temping.teardown
18
+ end
19
+ end
21
20
 
22
21
  module TestingModels
23
- include ActiveRecordMocks::IncludeMe
24
-
25
- def around(&block)
26
- self.with_testing_models(&block)
27
-
28
- # cw_root = CarrierWave.root
29
- # begin
30
- # Dir.mktmpdir('lanes-cw-root') do | dir |
31
- # # CarrierWave.root = dir
32
- # self.with_testing_models(&block)
33
- # end
34
- # ensure
35
- # # CarrierWave.root = cw_root
36
- # end
37
- end
38
22
 
39
- def with_testing_models
23
+ # around(:each) do |example|
24
+ # self.with_testing_models do
25
+ # example.run
26
+ # end
27
+ # end
28
+ # def around(&block)
29
+ # self.with_testing_models(&block)
30
+ # end
40
31
 
41
- with_mocked_tables do |m|
42
- [:test_models, :tmbts, :tmhms].each do | table |
43
- if ActiveRecord::Base.connection.data_source_exists? table
44
- ActiveRecord::Base.connection.drop_table table
45
- end
46
- end
32
+ def with_testing_models
47
33
 
48
- m.create_table do |t|
49
- t.model_name :TestModel
50
- t.parent_class "Lanes::Model"
51
- t.belongs_to :bt, class_name: 'Tmbt'
52
- t.has_many :hm, class_name: 'Tmhm'
53
- t.layout do |l|
54
- l.integer :bt_id
55
- l.string :name, :number
56
- end
34
+ # [:test_models, :tmbts, :tmhms].each do | table |
35
+ # if ActiveRecord::Base.connection.data_source_exists? table
36
+ # ActiveRecord::Base.connection.drop_table table
37
+ # end
38
+ # end
39
+ Temping.create :test_model do
40
+
41
+ t.parent_class "Lanes::Model"
42
+ t.belongs_to :bt, class_name: 'Tmbt'
43
+ t.has_many :hm, class_name: 'Tmhm'
44
+ t.layout do |l|
45
+ l.integer :bt_id
46
+ l.string :name, :number
57
47
  end
58
- TestModel.export_associations( :bt, :hm, writable: true )
48
+ end
49
+ TestModel.export_associations( :bt, :hm, writable: true )
59
50
 
60
51
  m.create_table do |t|
61
52
  t.model_name :Tmbt
@@ -78,17 +69,18 @@ module TestingModels
78
69
  yield
79
70
 
80
71
  TestModel.blacklisted_attributes.clear if TestModel.blacklisted_attributes
81
-
72
+ Temping.teardown
82
73
  end
83
74
  end
84
75
 
85
76
 
86
77
  end
87
78
 
88
- class Lanes::TestCase
89
79
 
90
- def fixtures_path
91
- Pathname.new(__FILE__).dirname.join("..","fixtures").expand_path
92
- end
80
+ # class Lanes::TestCase
93
81
 
94
- end
82
+ # def fixtures_path
83
+ # Pathname.new(__FILE__).dirname.join("..","fixtures").expand_path
84
+ # end
85
+
86
+ # end
@@ -0,0 +1,17 @@
1
+ import {
2
+ BaseModel, identifiedBy, identifier, belongsTo, hasMany, field, computed
3
+ } from './base';
4
+
5
+ @identifiedBy('<%= identifier %>/<%= file_name %>')
6
+ export default class <%= class_name %> extends BaseModel {
7
+
8
+ <% fields.each do |field| -%>
9
+ @<%= sprintf("%-11s%s;", field.decorator, field.column_name ) %>
10
+ <% end -%>
11
+
12
+ <% if reference_fields.any? -%>
13
+ <% reference_fields.each do |field| -%>
14
+ @<%= field.belongs_to? ? 'belongsTo' : 'hasMany' -%>({ model: '<%= identifier %>/<%= field.name %>' }) <%= field.name %>;
15
+ <% end -%>
16
+ <% end -%>
17
+ }
@@ -2,9 +2,10 @@ development:
2
2
  adapter: postgresql
3
3
  database: <%= name %>_dev
4
4
  host: /tmp
5
- pool: <%%= ENV["DB_POOL"] || 12 %>
5
+ pool: 5
6
6
 
7
7
  test:
8
8
  adapter: postgresql
9
9
  database: <%= name %>_test
10
10
  host: /tmp
11
+ pool: 5
@@ -0,0 +1,14 @@
1
+ {
2
+ "rootDir": "/Users/nas/code/show-maker",
3
+ "verbose": true,
4
+ "notify": false,
5
+ "testMatch": [ "**/?(*.)(spec|test).js?(x)" ],
6
+ "moduleFileExtensions": [ "js", "jsx", "json" ],
7
+ "setupTestFrameworkScriptFile": "<rootDir>/spec/client/setup.js",
8
+ "moduleNameMapper": {
9
+ "\\.(css|less|scss)$": "identity-obj-proxy"
10
+ },
11
+ "transform": {
12
+ "^.+\\.jsx?$": "<rootDir>/config/jest/babel-transform.js"
13
+ }
14
+ }
@@ -0,0 +1,47 @@
1
+ const babelOptions = {
2
+ plugins: [
3
+ 'react-hot-loader/babel',
4
+ 'babel-plugin-transform-decorators-legacy',
5
+ 'babel-plugin-transform-class-properties',
6
+ 'babel-plugin-transform-function-bind',
7
+ 'babel-plugin-transform-react-jsx',
8
+ 'babel-plugin-transform-runtime',
9
+ ].map(require.resolve),
10
+ presets: [
11
+ require.resolve('babel-preset-es2015'),
12
+ require.resolve('babel-preset-react'),
13
+ require.resolve('babel-preset-stage-1'),
14
+ ],
15
+ };
16
+
17
+ const crypto = require('crypto');
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+ const jestPreset = require('babel-preset-jest');
21
+ const babel = require('babel-core');
22
+
23
+ const createTransformer = (options) => {
24
+ options = Object.assign({}, options, {
25
+ plugins: (options && options.plugins) || [],
26
+ presets: ((options && options.presets) || []).concat([jestPreset]),
27
+ retainLines: true,
28
+ });
29
+ delete options.cacheDirectory;
30
+ delete options.filename;
31
+
32
+ return {
33
+ canInstrument: false,
34
+ getCacheKey(fileData) {
35
+ return crypto.createHash('md5').update(fileData).digest('hex');
36
+ },
37
+ process(src, filename) {
38
+ if (!babel.util.canCompile(filename)) {
39
+ return src;
40
+ }
41
+ const theseOptions = Object.assign({ filename }, options);
42
+ return babel.transform(src, theseOptions).code;
43
+ },
44
+ };
45
+ };
46
+
47
+ module.exports = createTransformer(babelOptions);
@@ -1,4 +1,5 @@
1
1
  Lanes::API.routes.draw do
2
- # Set default view for the site root. Adjust to fit your needs
3
- root_view :lanes_root_view
2
+
3
+
4
+
4
5
  end
@@ -78,7 +78,7 @@ const config = {
78
78
  historyApiFallback: true,
79
79
  proxy: [{
80
80
  context: '/api',
81
- target: 'http://localhost:4567',
81
+ target: 'http://localhost:9292',
82
82
  }],
83
83
  stats: {
84
84
  colors: true,
@@ -1,19 +1,11 @@
1
1
  {
2
- "preset": "<%= lanes_root_path %>/lib/js/jest.config.json",
2
+ "preset": "<%= extension_path %>/config/jest.config.json",
3
3
  "roots": [
4
4
  "<%= extension_path %>/client",
5
5
  "<%= extension_path %>/spec"
6
6
  ],
7
- "setupTestFrameworkScriptFile": "<%= lanes_root_path %>/lib/js/jest/setup.js",
8
- "transform": {
9
- "^.+\\.jsx?$": "babel-jest"
10
- },
11
7
  "modulePaths": [
12
8
  <%= module_paths.map{|mod| "\"#{mod}\"" }.join(", ") %>,
13
9
  "<%= lanes_root_path %>/lib/js/jest/stubs"
14
- ],
15
- "moduleNameMapper": {
16
- "\\.(css|less|scss)$": "<rootDir>/lib/js/jest/styleMock.js",
17
- "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/lib/js/jest/fileMock.js"
18
- }
10
+ ]
19
11
  }
@@ -0,0 +1,10 @@
1
+ import <%= class_name %> from '<%= identifier %>/models/<%= file_name %>';
2
+
3
+ describe('Model <%= class_name %>', () => {
4
+
5
+ it('can be instantiated', () => {
6
+ model = new <%= class_name %>();
7
+ expect(model).toBeInstanceOf(<%= class_name %>);
8
+ });
9
+
10
+ });
@@ -1,2 +1,11 @@
1
1
  // Code included here will be ran to setup your specs.
2
2
  // it's a usefull spot to setup globals or custom matchers
3
+ const matchers = require('lanes/jest/matchers');
4
+ const { shallow, mount } = require('enzyme');
5
+
6
+ global.expect.extend(matchers);
7
+
8
+ global.shallow = shallow;
9
+ global.mount = mount;
10
+ global.fetch = require('lanes/jest/mocks/fetch');
11
+ global.React = require('React');
@@ -1,16 +1,8 @@
1
- require_relative '../../lib/<%= namespace %>'
1
+ require_relative '../../lib/<%= identifier %>'
2
2
  require 'lanes/spec_helper'
3
3
 
4
- module <%= namespace %>
5
4
 
6
- # Add more helper methods to be used by all tests here...
7
-
8
- class TestCase < Lanes::TestCase
9
- include <%= namespace %>
10
- end
11
-
12
- class ApiTestCase < Lanes::ApiTestCase
13
- include <%= namespace %>
14
- end
5
+ # Configure RSpec to your liking
6
+ RSpec.configure do |config|
15
7
 
16
8
  end