Commit 4129a9dd by liyijie

Add user & app model

parent 7df91c1b
class ApplicationController < ActionController::API
def authenticated_auth
if respond_to?(:current_auth) && current_auth
current_auth
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
include ActionController::Helpers
include ActionController::RailsCom
include ActionController::Caching
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'])
$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'
GEM_COMMENT
end
# gem 'sqlite3', '~> 1.3.6'
gem 'pg'
inject_into_file 'Gemfile', before: "gem 'pg" do <<-COMMENT
# Use PostgresSql as the database for deploy
......@@ -52,21 +50,6 @@ COMMENT
end
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
# https://github.com/bbatsov/rubocop
gem 'rubocop', require: false
......@@ -76,8 +59,6 @@ gem 'rubocop-performance'
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 'tallty_import_export', git: 'https://git.tallty.com/open-source/tallty_import_export.git'
gem 'acts_as_paranoid'
gem "audited"
gem 'pry-byebug'
# deploy
......@@ -130,8 +111,6 @@ after_bundle do
# bundle exec rake swagger
COMMENT
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
copy_file 'src/spec/support/shoulda_matches.rb', 'spec/support/shoulda_matches.rb'
# factory_bot_rails gem configuration
......@@ -168,9 +147,12 @@ after_bundle do
copy_file 'src/config/cors.rb', 'config/initializers/cors.rb'
remove_file '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'
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 '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