Commit 4129a9dd by liyijie

Add user & app model

parent 7df91c1b
class ApplicationController < ActionController::API class ApplicationController < ActionController::API
def authenticated_auth include ActionController::Helpers
if respond_to?(:current_auth) && current_auth include ActionController::RailsCom
current_auth include ActionController::Caching
else
'Unknown'
end
end
rescue_from ActiveRecord::RecordNotFound do |e|
render json: { error: e.message }, status: 404
end
rescue_from ActiveRecord::RecordInvalid do |e|
render json: { error: e.message }, status: 422
end
end end
class App < ApplicationRecord
include Com::Model::App
include Res::Model::App
include Estate::Model::App
include Tofu::Model::App
include Bpm::Model::App
end
class User < ApplicationRecord
include Com::Model::User
include Res::Model::User
include Bpm::Model::User
end
Audited.current_user_method = :authenticated_auth
Ohm.redis = Redic.new(ENV['REDIS_URL']) Ohm.redis = Redic.new(ENV['REDIS_URL'])
$redis = Redis.new(url: ENV['REDIS_URL']) $redis = ENV['REDIS_PASSWORD'].present? ?
Redis.new(url: ENV['REDIS_URL'], password: ENV['REDIS_PASSWORD'] ) :
Redis.new(url: ENV['REDIS_URL'])
$token_redis = Redis::Namespace.new(:token, redis: $redis)
Redis::Objects.redis = Redis.new(url: ENV["REDIS_URL"], db: ENV["REDIS_DB"], password: ENV["REDIS_PASSWORD"])
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
config.before(:each) do |example|
@modules = example.metadata[:tags]&.first&.split(' ') || []
@user = create(:user, org: @org)
end
end
...@@ -14,8 +14,6 @@ gem 'dotenv-rails', require: 'dotenv/rails-now' ...@@ -14,8 +14,6 @@ gem 'dotenv-rails', require: 'dotenv/rails-now'
GEM_COMMENT GEM_COMMENT
end end
# gem 'sqlite3', '~> 1.3.6'
gem 'pg' gem 'pg'
inject_into_file 'Gemfile', before: "gem 'pg" do <<-COMMENT inject_into_file 'Gemfile', before: "gem 'pg" do <<-COMMENT
# Use PostgresSql as the database for deploy # Use PostgresSql as the database for deploy
...@@ -52,21 +50,6 @@ COMMENT ...@@ -52,21 +50,6 @@ COMMENT
end end
gsub_file 'app/controllers/application_controller.rb', 'respond_to :html', 'respond_to :json' gsub_file 'app/controllers/application_controller.rb', 'respond_to :html', 'respond_to :json'
gem 'will_paginate'
inject_into_file 'Gemfile', before: "gem 'will_paginate'" do <<-COMMENT
# Pagination library for Rails, Sinatra, Merb, DataMapper, and more http://github.com/mislav/will_paginat…
# https://github.com/mislav/will_paginate
COMMENT
end
gem 'aasm'
inject_into_file 'Gemfile', before: "gem 'aasm" do <<-COMMENT
# AASM - State machines for Ruby classes (plain Ruby, ActiveRecord, Mongoid)
# https://github.com/aasm/aasm
# rails generate aasm NAME [COLUMN_NAME]
COMMENT
end
# A Ruby static code analyzer, based on the community Ruby style guide. http://rubocop.readthedocs.io # A Ruby static code analyzer, based on the community Ruby style guide. http://rubocop.readthedocs.io
# https://github.com/bbatsov/rubocop # https://github.com/bbatsov/rubocop
gem 'rubocop', require: false gem 'rubocop', require: false
...@@ -76,8 +59,6 @@ gem 'rubocop-performance' ...@@ -76,8 +59,6 @@ gem 'rubocop-performance'
gem 'simple_controller', git: 'https://git.tallty.com/open-source/simple_controller.git' gem 'simple_controller', git: 'https://git.tallty.com/open-source/simple_controller.git'
gem 'acts_as_pasting', git: 'http://git.tallty.com/open-source/acts_as_pasting.git' gem 'acts_as_pasting', git: 'http://git.tallty.com/open-source/acts_as_pasting.git'
gem 'tallty_import_export', git: 'https://git.tallty.com/open-source/tallty_import_export.git' gem 'tallty_import_export', git: 'https://git.tallty.com/open-source/tallty_import_export.git'
gem 'acts_as_paranoid'
gem "audited"
gem 'pry-byebug' gem 'pry-byebug'
# deploy # deploy
...@@ -130,8 +111,6 @@ after_bundle do ...@@ -130,8 +111,6 @@ after_bundle do
# bundle exec rake swagger # bundle exec rake swagger
COMMENT COMMENT
end end
# Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
generate 'audited:install'
# shoulda-matchers gem configuration # shoulda-matchers gem configuration
copy_file 'src/spec/support/shoulda_matches.rb', 'spec/support/shoulda_matches.rb' copy_file 'src/spec/support/shoulda_matches.rb', 'spec/support/shoulda_matches.rb'
# factory_bot_rails gem configuration # factory_bot_rails gem configuration
...@@ -168,9 +147,12 @@ after_bundle do ...@@ -168,9 +147,12 @@ after_bundle do
copy_file 'src/config/cors.rb', 'config/initializers/cors.rb' copy_file 'src/config/cors.rb', 'config/initializers/cors.rb'
remove_file 'spec/swagger_helper.rb' remove_file 'spec/swagger_helper.rb'
copy_file 'src/spec/swagger_helper.rb', 'spec/swagger_helper.rb' copy_file 'src/spec/swagger_helper.rb', 'spec/swagger_helper.rb'
copy_file 'src/spec/support/spec_seeds.rb', 'spec/support/spec_seeds.rb'
remove_file 'app/controllers/application_controller.rb' remove_file 'app/controllers/application_controller.rb'
copy_file 'src/app/controllers/application_controller.rb', 'app/controllers/application_controller.rb' copy_file 'src/app/controllers/application_controller.rb', 'app/controllers/application_controller.rb'
copy_file 'src/config/audited.rb', 'config/initializers/audited.rb' copy_file 'src/app/models/user.rb', 'app/models/user.rb'
copy_file 'src/app/models/app.rb', 'app/models/app.rb'
copy_file 'src/config/redis.rb', 'config/initializers/redis.rb'
gsub_file 'config/puma.rb', 'app_name_to_replace', app_name gsub_file 'config/puma.rb', 'app_name_to_replace', app_name
gsub_file 'spec/swagger_helper.rb', 'app_name_to_replace', app_name gsub_file 'spec/swagger_helper.rb', 'app_name_to_replace', app_name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment