Compare commits
10 Commits
adc02128e4
...
7ee8caf4f8
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ee8caf4f8 | |||
| 91ce3b6829 | |||
| 0b25eefb38 | |||
| d3e176ac55 | |||
| 848e39d6d4 | |||
| 1d578d17b8 | |||
| bc636294c6 | |||
| 1428d0ce1b | |||
| 67161330b7 | |||
| c2a1c61f82 |
@@ -1,5 +1,10 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
git_source(:gitlab) do |repo_name|
|
||||
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
|
||||
"https://gitlab.com/#{repo_name}.git"
|
||||
end
|
||||
|
||||
# Declare your gem's dependencies in dunlop-ember.gemspec.
|
||||
# Bundler will treat runtime dependencies like base dependencies, and
|
||||
# development dependencies will be added by default to the :development group.
|
||||
@@ -17,9 +22,10 @@ group :development, :test do
|
||||
gem 'rspec-rails'
|
||||
gem 'cancancan'
|
||||
gem 'slim-rails'
|
||||
gem 'dunlop-core', github: 'companytools/dunlop-core', branch: 'master'
|
||||
gem 'paperclip', '~> 5.3'
|
||||
gem 'dunlop-core', gitlab: 'benja-2/dunlop-core', branch: 'master'
|
||||
#gem 'dunlop-core', path: '~/development/rails/components/dunlop-core'
|
||||
gem 'factory_girl_rails'
|
||||
gem 'factory_bot_rails'
|
||||
gem 'active_model_serializers'
|
||||
gem 'database_cleaner'
|
||||
end
|
||||
|
||||
+155
-143
@@ -1,11 +1,10 @@
|
||||
GIT
|
||||
remote: git://github.com/companytools/dunlop-core.git
|
||||
revision: a7b86d3c17309d9de29bc2b4aa9a7dff842d619f
|
||||
remote: https://gitlab.com/benja-2/dunlop-core.git
|
||||
revision: 064ab4fa280d3dc79bc9671891e46b5b72e06fac
|
||||
branch: master
|
||||
specs:
|
||||
dunlop-core (1.4.0)
|
||||
cancancan
|
||||
carrierwave
|
||||
coffee-rails (~> 4.1)
|
||||
devise
|
||||
devise-token_authenticatable
|
||||
@@ -39,70 +38,71 @@ PATH
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
actioncable (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activejob (= 5.1.4)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activejob (= 5.2.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
actionpack (5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
actionview (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
active_attr (0.10.2)
|
||||
activemodel (>= 3.0.2, < 5.2)
|
||||
activesupport (>= 3.0.2, < 5.2)
|
||||
active_model_serializers (0.10.6)
|
||||
active_attr (0.12.0)
|
||||
activemodel (>= 3.0.2, < 6.0)
|
||||
activesupport (>= 3.0.2, < 6.0)
|
||||
active_model_serializers (0.10.7)
|
||||
actionpack (>= 4.1, < 6)
|
||||
activemodel (>= 4.1, < 6)
|
||||
case_transform (>= 0.2)
|
||||
jsonapi-renderer (>= 0.1.1.beta1, < 0.2)
|
||||
activejob (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
||||
activejob (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
activerecord (5.1.4)
|
||||
activemodel (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
arel (~> 8.0)
|
||||
activesupport (5.1.4)
|
||||
activemodel (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
activerecord (5.2.1)
|
||||
activemodel (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
activerecord (= 5.2.1)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.5.2)
|
||||
public_suffix (>= 2.0.2, < 4.0)
|
||||
arel (8.0.0)
|
||||
bcrypt (3.1.11)
|
||||
arel (9.0.0)
|
||||
bcrypt (3.1.12)
|
||||
builder (3.2.3)
|
||||
cancancan (2.0.0)
|
||||
capybara (2.15.2)
|
||||
cancancan (2.2.0)
|
||||
capybara (3.6.0)
|
||||
addressable
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (~> 2.0)
|
||||
carrierwave (1.2.1)
|
||||
activemodel (>= 4.0.0)
|
||||
activesupport (>= 4.0.0)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (~> 1.8)
|
||||
rack (>= 1.6.0)
|
||||
rack-test (>= 0.6.3)
|
||||
xpath (~> 3.1)
|
||||
case_transform (0.2)
|
||||
activesupport
|
||||
climate_control (0.2.0)
|
||||
coderay (1.1.2)
|
||||
coffee-rails (4.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
@@ -112,117 +112,125 @@ GEM
|
||||
execjs
|
||||
coffee-script-source (1.12.2)
|
||||
concurrent-ruby (1.0.5)
|
||||
crass (1.0.2)
|
||||
database_cleaner (1.6.1)
|
||||
devise (4.3.0)
|
||||
crass (1.0.4)
|
||||
database_cleaner (1.7.0)
|
||||
devise (4.4.3)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0, < 5.2)
|
||||
railties (>= 4.1.0, < 6.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
devise-token_authenticatable (1.0.0)
|
||||
devise (>= 4.0.0, < 4.4.0)
|
||||
devise-token_authenticatable (1.0.1)
|
||||
devise (>= 4.0.0, < 4.5.0)
|
||||
diff-lcs (1.3)
|
||||
erubi (1.6.1)
|
||||
erubi (1.7.1)
|
||||
exception_notification (4.2.2)
|
||||
actionmailer (>= 4.0, < 6)
|
||||
activesupport (>= 4.0, < 6)
|
||||
execjs (2.7.0)
|
||||
facets (3.1.0)
|
||||
factory_girl (4.8.1)
|
||||
factory_bot (4.11.0)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (4.8.0)
|
||||
factory_girl (~> 4.8.0)
|
||||
factory_bot_rails (4.11.0)
|
||||
factory_bot (~> 4.11.0)
|
||||
railties (>= 3.0.0)
|
||||
ffi (1.9.18)
|
||||
font-awesome-rails (4.7.0.2)
|
||||
railties (>= 3.2, < 5.2)
|
||||
globalid (0.4.0)
|
||||
ffi (1.9.25)
|
||||
font-awesome-rails (4.7.0.4)
|
||||
railties (>= 3.2, < 6.0)
|
||||
globalid (0.4.1)
|
||||
activesupport (>= 4.2.0)
|
||||
i18n (0.8.6)
|
||||
js-routes (1.4.2)
|
||||
i18n (1.1.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
js-routes (1.4.4)
|
||||
railties (>= 3.2)
|
||||
sprockets-rails
|
||||
jsonapi-renderer (0.1.3)
|
||||
kaminari (1.0.1)
|
||||
jsonapi-renderer (0.2.0)
|
||||
kaminari (1.1.1)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.0.1)
|
||||
kaminari-activerecord (= 1.0.1)
|
||||
kaminari-core (= 1.0.1)
|
||||
kaminari-actionview (1.0.1)
|
||||
kaminari-actionview (= 1.1.1)
|
||||
kaminari-activerecord (= 1.1.1)
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-actionview (1.1.1)
|
||||
actionview
|
||||
kaminari-core (= 1.0.1)
|
||||
kaminari-activerecord (1.0.1)
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-activerecord (1.1.1)
|
||||
activerecord
|
||||
kaminari-core (= 1.0.1)
|
||||
kaminari-core (1.0.1)
|
||||
loofah (2.1.1)
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-core (1.1.1)
|
||||
loofah (2.2.2)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.6)
|
||||
mime-types (>= 1.16, < 4)
|
||||
mail (2.7.0)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.2)
|
||||
mimemagic (~> 0.3.2)
|
||||
memoist (0.16.0)
|
||||
method_source (0.9.0)
|
||||
mime-types (3.1)
|
||||
mime-types (3.2.2)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_mime (0.1.4)
|
||||
mime-types-data (3.2018.0812)
|
||||
mimemagic (0.3.2)
|
||||
mini_mime (1.0.1)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.10.3)
|
||||
momentjs-rails (2.17.1)
|
||||
minitest (5.11.3)
|
||||
momentjs-rails (2.20.1)
|
||||
railties (>= 3.1)
|
||||
nio4r (2.1.0)
|
||||
nokogiri (1.8.1)
|
||||
nio4r (2.3.1)
|
||||
nokogiri (1.8.4)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
orm_adapter (0.5.0)
|
||||
paperclip (5.3.0)
|
||||
activemodel (>= 4.2.0)
|
||||
activesupport (>= 4.2.0)
|
||||
mime-types
|
||||
mimemagic (~> 0.3.0)
|
||||
terrapin (~> 0.6.0)
|
||||
pickadate-rails (3.5.5.0)
|
||||
railties (>= 3.1.0)
|
||||
polyamorous (1.3.1)
|
||||
activerecord (>= 3.0)
|
||||
pry (0.11.1)
|
||||
pry (0.11.3)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.9.0)
|
||||
pry-doc (0.11.1)
|
||||
pry (~> 0.9)
|
||||
yard (~> 0.9)
|
||||
pry-doc (0.13.4)
|
||||
pry (~> 0.11)
|
||||
yard (~> 0.9.11)
|
||||
pry-rails (0.3.6)
|
||||
pry (>= 0.10.4)
|
||||
public_suffix (3.0.0)
|
||||
rack (2.0.3)
|
||||
rack-cors (1.0.1)
|
||||
rack-test (0.7.0)
|
||||
public_suffix (3.0.3)
|
||||
rack (2.0.5)
|
||||
rack-cors (1.0.2)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.1.4)
|
||||
actioncable (= 5.1.4)
|
||||
actionmailer (= 5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
actionview (= 5.1.4)
|
||||
activejob (= 5.1.4)
|
||||
activemodel (= 5.1.4)
|
||||
activerecord (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
rails (5.2.1)
|
||||
actioncable (= 5.2.1)
|
||||
actionmailer (= 5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activejob (= 5.2.1)
|
||||
activemodel (= 5.2.1)
|
||||
activerecord (= 5.2.1)
|
||||
activestorage (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.1.4)
|
||||
railties (= 5.2.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.1.4)
|
||||
actionpack (= 5.1.4)
|
||||
activesupport (= 5.1.4)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (12.1.0)
|
||||
ransack (1.8.3)
|
||||
actionpack (>= 3.0)
|
||||
activerecord (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rake (12.3.1)
|
||||
ransack (2.0.1)
|
||||
actionpack (>= 5.0)
|
||||
activerecord (>= 5.0)
|
||||
activesupport (>= 5.0)
|
||||
i18n
|
||||
polyamorous (~> 1.3)
|
||||
rb-fsevent (0.10.2)
|
||||
rb-fsevent (0.10.3)
|
||||
rb-inotify (0.9.10)
|
||||
ffi (>= 0.5.0, < 2)
|
||||
record_collection (0.10.4)
|
||||
@@ -230,28 +238,29 @@ GEM
|
||||
activemodel (>= 4.1)
|
||||
railties (>= 3.1)
|
||||
redcarpet (3.4.0)
|
||||
request_store (1.3.2)
|
||||
request_store (1.4.1)
|
||||
rack (>= 1.4)
|
||||
responders (2.4.0)
|
||||
actionpack (>= 4.2.0, < 5.3)
|
||||
railties (>= 4.2.0, < 5.3)
|
||||
rspec-core (3.6.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-expectations (3.6.0)
|
||||
rspec-core (3.8.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-expectations (3.8.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-mocks (3.6.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-mocks (3.8.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-rails (3.6.1)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-rails (3.8.0)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.6.0)
|
||||
rspec-expectations (~> 3.6.0)
|
||||
rspec-mocks (~> 3.6.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-support (3.6.0)
|
||||
sass (3.5.3)
|
||||
rspec-core (~> 3.8.0)
|
||||
rspec-expectations (~> 3.8.0)
|
||||
rspec-mocks (~> 3.8.0)
|
||||
rspec-support (~> 3.8.0)
|
||||
rspec-support (3.8.0)
|
||||
sass (3.5.7)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
@@ -262,13 +271,13 @@ GEM
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
simple_form (3.5.0)
|
||||
actionpack (> 4, < 5.2)
|
||||
activemodel (> 4, < 5.2)
|
||||
slim (3.0.8)
|
||||
simple_form (4.0.1)
|
||||
actionpack (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
slim (3.0.9)
|
||||
temple (>= 0.7.6, < 0.9)
|
||||
tilt (>= 1.3.3, < 2.1)
|
||||
slim-rails (3.1.2)
|
||||
slim-rails (3.1.3)
|
||||
actionpack (>= 3.1)
|
||||
railties (>= 3.1)
|
||||
slim (~> 3.0)
|
||||
@@ -276,7 +285,7 @@ GEM
|
||||
activesupport (>= 4.2)
|
||||
spring-commands-rspec (1.0.4)
|
||||
spring (>= 0.9.1)
|
||||
sprockets (3.7.1)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.2.1)
|
||||
@@ -285,26 +294,28 @@ GEM
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
state_machines (0.5.0)
|
||||
state_machines-activemodel (0.5.0)
|
||||
activemodel (>= 4.1, < 5.2)
|
||||
state_machines-activemodel (0.5.1)
|
||||
activemodel (>= 4.1, < 6.0)
|
||||
state_machines (>= 0.5.0)
|
||||
state_machines-activerecord (0.5.0)
|
||||
activerecord (>= 4.1, < 5.2)
|
||||
state_machines-activerecord (0.5.1)
|
||||
activerecord (>= 4.1, < 6.0)
|
||||
state_machines-activemodel (>= 0.5.0)
|
||||
temple (0.8.0)
|
||||
terrapin (0.6.0)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
thor (0.20.0)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.8)
|
||||
tzinfo (1.2.3)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
websocket-driver (0.6.5)
|
||||
websocket-driver (0.7.0)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
xpath (2.1.0)
|
||||
nokogiri (~> 1.3)
|
||||
yard (0.9.9)
|
||||
websocket-extensions (0.1.3)
|
||||
xpath (3.1.0)
|
||||
nokogiri (~> 1.8)
|
||||
yard (0.9.16)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -317,8 +328,9 @@ DEPENDENCIES
|
||||
database_cleaner
|
||||
dunlop-core!
|
||||
dunlop-ember!
|
||||
factory_girl_rails
|
||||
factory_bot_rails
|
||||
kaminari
|
||||
paperclip (~> 5.3)
|
||||
pry-doc
|
||||
pry-rails
|
||||
rack-cors
|
||||
@@ -329,4 +341,4 @@ DEPENDENCIES
|
||||
sqlite3
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.0
|
||||
1.16.3
|
||||
|
||||
@@ -8,23 +8,23 @@ module Dunlop
|
||||
def ember_path
|
||||
app_globals = {}
|
||||
if adapter_name = params[:adapter].to_s.scan(/\w+/).first.presence
|
||||
app_index = Rails.root.join("public/adapters/#{adapter_name}/app/index.html")
|
||||
return render text: 'unauthorized, no adapter engine', status: 403 unless adapter = Panda.adapters[adapter_name]
|
||||
return render html: '403 - unauthorized, no adapter engine', status: 403 unless adapter = Panda.adapters[adapter_name]
|
||||
@app_index = Rails.root.join("public/adapters/#{adapter.url_name}/app/index.html")
|
||||
#app_globals = adapter.settings # load through request instead. More stable then changing environments
|
||||
unless Rails.application.config.try(:loose_ember_app_authorization)
|
||||
return render text: 'unauthorized, no adapter engine', status: 403 unless current_user.admin? or authorize!(:read, adapter.engine)
|
||||
return render html: '403 - unauthorized, no adapter engine permission', status: 403 unless current_user.admin? or can?(:read, adapter.engine)
|
||||
end
|
||||
else
|
||||
app_index = Rails.root.join('public/app/index.html')
|
||||
@app_index = Rails.root.join('public/app/index.html')
|
||||
end
|
||||
Rails.logger.info "Loading ember app for path '#/#{params[:rest]}' adapter: '#{params[:adapter].presence || 'main_app'}'"
|
||||
if app_index.exist?
|
||||
index_html = app_index.read.to_s
|
||||
if @app_index.exist?
|
||||
index_html = @app_index.read.to_s
|
||||
app_globals[:flash] = flash.to_h if flash.present?
|
||||
index_html.sub! 'app_globals={}', "app_globals=#{app_globals.to_json}" if app_globals.present?
|
||||
render html: index_html.html_safe
|
||||
else
|
||||
render html: "App file <tt>#{app_index}</tt> not found".html_safe
|
||||
render html: "App file <tt>#{@app_index.to_s}</tt> not found".html_safe
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
h3
|
||||
span Could not find
|
||||
tt= '/app/index.html'
|
||||
tt= @app_index || '/app/index.html'
|
||||
span file
|
||||
|
||||
@@ -23,7 +23,5 @@ Gem::Specification.new do |s|
|
||||
s.add_dependency "active_model_serializers"
|
||||
|
||||
s.add_development_dependency "sqlite3"
|
||||
s.add_development_dependency 'rspec-rails'
|
||||
s.add_development_dependency 'capybara'
|
||||
s.add_development_dependency 'factory_girl_rails'
|
||||
end
|
||||
|
||||
@@ -20,7 +20,7 @@ module Dunlop::Ember::ApiBaseController
|
||||
|
||||
def index
|
||||
index_safeguard record_class
|
||||
result = record_scope.search(query).result
|
||||
result = record_scope.ransack(query).result
|
||||
result = result.includes(*FlatKeys.as_nested_structure(index_include_relations)) if index_include_relations.present?
|
||||
result = result.uniq if params[:uniq].present?
|
||||
if index_pagination?
|
||||
@@ -37,7 +37,7 @@ module Dunlop::Ember::ApiBaseController
|
||||
end
|
||||
|
||||
def create
|
||||
@record ||= record_class.new(record_params)
|
||||
@record ||= record_scope.new(record_params)
|
||||
create_safeguard @record
|
||||
return if performed?
|
||||
if @record.save
|
||||
@@ -50,7 +50,7 @@ module Dunlop::Ember::ApiBaseController
|
||||
def update
|
||||
update_safeguard @record
|
||||
return if performed?
|
||||
@record.update_attributes record_params
|
||||
@record.update record_params
|
||||
render json: @record
|
||||
end
|
||||
|
||||
@@ -144,7 +144,11 @@ module Dunlop::Ember::ApiBaseController
|
||||
def find_record(options = {})
|
||||
scope = record_scope
|
||||
scope = scope.includes(*Array.wrap(options[:includes])) if options[:includes]
|
||||
@record = scope.find(params[:id])
|
||||
if record_class.include?(HasUuidIdentifier) and HasUuidIdentifier::UUID_MATCH =~ params[:id].to_s
|
||||
@record = scope.find_by(identifier: params[:id]) or raise ActiveRecord::RecordNotFound # I (Benjamin) don't agree with this (raising) behaviour, but this is the rails standard for raising and rescue
|
||||
else
|
||||
@record = scope.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
def record_params
|
||||
@@ -189,6 +193,7 @@ module Dunlop::Ember::ApiBaseController
|
||||
self.class.predicate_end_matcher ||= Regexp.new("(_#{Ransack.predicates.keys.join('|_')})$")
|
||||
mapped_query = {}
|
||||
(params[:q] || {}).each do |key, value|
|
||||
# not setting the matcher means equality
|
||||
key = "#{key}_eq" unless %w[s sorts].include?(key) or record_class.try(:ransackable_scopes).try(:include?, key.to_sym) or key =~ self.class.predicate_end_matcher # expect equality when no predicate is given
|
||||
if key =~ /^type_/
|
||||
# map type to sti_type
|
||||
@@ -211,6 +216,7 @@ module Dunlop::Ember::ApiBaseController
|
||||
end
|
||||
return resource.to_json if resource.is_a?(Hash)
|
||||
return resource if resource.is_a?(String)
|
||||
return resource.to_json if resource.try(:custom_data?)
|
||||
|
||||
action_serialize_options_method = :"#{action_name}_serialize_options"
|
||||
#action_serialize_options = respond_to?(action_serialize_options_method) ? __send__(action_serialize_options_method) : {}
|
||||
|
||||
@@ -98,7 +98,7 @@ RSpec.describe Api::PostsController, type: :controller do
|
||||
type: "comment",
|
||||
attributes: {body: "post-1-comment-1"},
|
||||
relationships: {
|
||||
post: {data: {id: post1.id.to_s, type: "posts"}}
|
||||
post: {data: {id: post1.id.to_s, type: "post"}}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -31,7 +31,7 @@ RSpec.describe Api::PostsController, type: :controller do
|
||||
type: "comment",
|
||||
attributes: {body: "post-1-comment-1"},
|
||||
relationships: {
|
||||
post: {data: {id: post1.id.to_s, type: "posts"}}
|
||||
post: {data: {id: post1.id.to_s, type: "post"}}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Api::CommentSerializer < ActiveModel::Serializer
|
||||
attribute :body
|
||||
belongs_to :post
|
||||
belongs_to :post, serializer: Api::PostSerializer
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Api::PostSerializer < ActiveModel::Serializer
|
||||
attribute :title
|
||||
attribute :body
|
||||
has_many :comments
|
||||
has_many :comments, serializer: Api::CommentSerializer
|
||||
end
|
||||
|
||||
@@ -17,8 +17,8 @@ ActiveSupport.to_time_preserves_timezone = true
|
||||
# Require `belongs_to` associations by default. Previous versions had false.
|
||||
Rails.application.config.active_record.belongs_to_required_by_default = true
|
||||
|
||||
# Do not halt callback chains when a callback returns false. Previous versions had true.
|
||||
ActiveSupport.halt_callback_chains_on_return_false = false
|
||||
## Do not halt callback chains when a callback returns false. Previous versions had true.
|
||||
#ActiveSupport.halt_callback_chains_on_return_false = false
|
||||
|
||||
# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
|
||||
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory :comment do
|
||||
user_id 1
|
||||
post_id 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory :post do
|
||||
sequence(:title) {|i| "post-#{i}"}
|
||||
sequence(:body) {|i| "post-body-#{i}"}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FactoryGirl.define do
|
||||
FactoryBot.define do
|
||||
factory :user do
|
||||
sequence(:email) { |i| "user#{i}@example.com" }
|
||||
password 'secret'
|
||||
|
||||
@@ -19,7 +19,7 @@ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
|
||||
Dir[File.join(ENGINE_RAILS_ROOT, "spec/factories/**/*.rb")].each {|f| require f }
|
||||
#FactoryGirl.definition_file_paths = [File.join(ENGINE_RAILS_ROOT, "spec/factories/**/*.rb")] # not needed here
|
||||
#FactoryBot.definition_file_paths = [File.join(ENGINE_RAILS_ROOT, "spec/factories/**/*.rb")] # not needed here
|
||||
Dir.glob("spec/acceptance/steps/**/*steps.rb") { |f| load f, true }
|
||||
|
||||
# Add additional requires below this line. Rails is not loaded until this point!
|
||||
@@ -53,7 +53,7 @@ RSpec.configure do |config|
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
config.include FactoryBot::Syntax::Methods
|
||||
config.include Rspec::Dunlop::GeneralHelpers
|
||||
config.include Rspec::Dunlop::FeatureHelpers, type: :feature
|
||||
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||
@@ -64,7 +64,7 @@ RSpec.configure do |config|
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = false
|
||||
config.before :suite do
|
||||
#FactoryGirl.reload # to add the adapter factories
|
||||
#FactoryBot.reload # to add the adapter factories
|
||||
#DatabaseCleaner.clean_with(:truncation)
|
||||
DatabaseCleaner.clean_with(:truncation)
|
||||
Dunlop::NestedLogger.options[:yaml_options][:line_width] = 2000
|
||||
|
||||
Reference in New Issue
Block a user