pixelforce_kit 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +299 -0
- data/LICENSE +21 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/app/controllers/admin/api/admin_base_controller.rb +116 -0
- data/app/controllers/admin/api/app_versions_controller.rb +26 -0
- data/app/controllers/admin/api/available_modules_controller.rb +20 -0
- data/app/controllers/api/base_controller.rb +82 -0
- data/app/controllers/api/v1/health_check_controller.rb +12 -0
- data/app/controllers/application_controller.rb +10 -0
- data/app/controllers/auth/passwords_controller.rb +7 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/concerns/exception_handler.rb +57 -0
- data/app/controllers/concerns/request_header_handler.rb +35 -0
- data/app/controllers/concerns/response_handler.rb +51 -0
- data/app/controllers/concerns/search_params_parser.rb +35 -0
- data/app/controllers/pages_controller.rb +36 -0
- data/app/controllers/users_controller.rb +3 -0
- data/app/models/ahoy/event.rb +8 -0
- data/app/models/ahoy/visit.rb +6 -0
- data/app/models/application_record.rb +11 -0
- data/app/models/concerns/account_deletable.rb +26 -0
- data/app/models/concerns/assets_uploadable.rb +20 -0
- data/app/models/concerns/codenamable.rb +13 -0
- data/app/models/concerns/image_sizable.rb +58 -0
- data/app/models/concerns/isolationable.rb +18 -0
- data/app/models/concerns/searchable.rb +94 -0
- data/app/models/concerns/taggable.rb +57 -0
- data/app/models/tag.rb +13 -0
- data/app/models/tag_attachable.rb +6 -0
- data/app/models/tag_category.rb +5 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/db/migrate/20220617021719_create_ahoy_visits_and_events.rb +67 -0
- data/db/migrate/20240828040425_create_tags.rb +12 -0
- data/db/migrate/20240828040646_create_tag_attachables.rb +9 -0
- data/db/migrate/20240912054241_create_tag_categories.rb +11 -0
- data/db/schema.rb +24 -0
- data/lib/pixelforce_kit/engine.rb +17 -0
- data/lib/pixelforce_kit/initializer/ahoy.rb +50 -0
- data/lib/pixelforce_kit/railtie.rb +4 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/base.rb +4 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/elbas.rb +10 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/logrotate.rb +10 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/puma.rb +46 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/resque.rb +43 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/resque_scheduler.rb +43 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/sidekiq.rb +88 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/supervisor.rb +9 -0
- data/lib/pixelforce_kit/recipes/capistrano_recipes/unicorn.rb +58 -0
- data/lib/pixelforce_kit/recipes/templates/logrotate.erb +10 -0
- data/lib/pixelforce_kit/recipes/templates/nginx_config.erb +32 -0
- data/lib/pixelforce_kit/recipes/templates/nginx_puma_config.erb +43 -0
- data/lib/pixelforce_kit/recipes/templates/puma.rb.erb +34 -0
- data/lib/pixelforce_kit/recipes/templates/puma_systemd.erb +19 -0
- data/lib/pixelforce_kit/recipes/templates/resque_init.erb +49 -0
- data/lib/pixelforce_kit/recipes/templates/resque_scheduler_init.erb +49 -0
- data/lib/pixelforce_kit/recipes/templates/resque_scheduler_supervisor.erb +13 -0
- data/lib/pixelforce_kit/recipes/templates/resque_supervisor.erb +13 -0
- data/lib/pixelforce_kit/recipes/templates/sidekiq_init.erb +49 -0
- data/lib/pixelforce_kit/recipes/templates/sidekiq_supervisor.erb +12 -0
- data/lib/pixelforce_kit/recipes/templates/sidekiq_systemd.erb +17 -0
- data/lib/pixelforce_kit/recipes/templates/supervisor.erb +19 -0
- data/lib/pixelforce_kit/recipes/templates/unicorn_init.erb +55 -0
- data/lib/pixelforce_kit/recipes/templates/unicorn_supervisor.erb +13 -0
- data/lib/pixelforce_kit/recipes.rb +4 -0
- data/lib/pixelforce_kit/spec_helper.rb +120 -0
- data/lib/pixelforce_kit/version.rb +3 -0
- data/lib/pixelforce_kit.rb +8 -0
- data/pixelforce_kit.gemspec +33 -0
- metadata +269 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
### BEGIN INIT INFO
|
4
|
+
# Provides: resque scheduler
|
5
|
+
# Required-Start: $local_fs $remote_fs $network $syslog
|
6
|
+
# Required-Stop: $local_fs $remote_fs $network $syslog
|
7
|
+
# Default-Start: 2 3 4 5
|
8
|
+
# Default-Stop: 0 1 6
|
9
|
+
# Short-Description: resque scheduler worker via init.d
|
10
|
+
# Description: starts resque scheduler
|
11
|
+
### END INIT INFO
|
12
|
+
|
13
|
+
USER="<%= fetch(:user) %>"
|
14
|
+
PROJECT_PATH="<%= fetch(:deploy_to) %>"
|
15
|
+
NAME="resque_scheduler"
|
16
|
+
DESC="Resque Scheduler for $USER"
|
17
|
+
PID="$PROJECT_PATH/shared/pids/resque_scheduler.pid"
|
18
|
+
LOGFILE="$PROJECT_PATH/shared/log/resque.log"
|
19
|
+
CD_TO_APP_DIR="cd $PROJECT_PATH/current"
|
20
|
+
|
21
|
+
|
22
|
+
case "$1" in
|
23
|
+
start)
|
24
|
+
START_DAEMON_PROCESS="bundle exec rake RAILS_ENV=<%= fetch(:rails_env) %> QUEUE='*' PIDFILE=$PID BACKGROUND=yes environment resque:scheduler 2>&1 > $LOGFILE"
|
25
|
+
echo -n "Starting $DESC: "
|
26
|
+
if [ `whoami` = 'root' ]; then
|
27
|
+
su - $USER -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
|
28
|
+
else
|
29
|
+
/bin/bash -l -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
|
30
|
+
fi
|
31
|
+
echo "$NAME."
|
32
|
+
;;
|
33
|
+
stop)
|
34
|
+
STOP_DAEMON_PROCESS="test -f $PID && kill -s QUIT `cat $PID` && rm -f $PID"
|
35
|
+
echo -n "Stopping $DESC: "
|
36
|
+
if [ `whoami` = 'root' ]; then
|
37
|
+
su - $USER -c "$CD_TO_APP_DIR && $STOP_DAEMON_PROCESS"
|
38
|
+
else
|
39
|
+
/bin/bash -l -c "$CD_TO_APP_DIR && $STOP_DAEMON_PROCESS"
|
40
|
+
fi
|
41
|
+
echo "$NAME."
|
42
|
+
;;
|
43
|
+
*)
|
44
|
+
echo "Usage: $NAME {start|stop|restart|reload}" >&2
|
45
|
+
exit 1
|
46
|
+
;;
|
47
|
+
esac
|
48
|
+
|
49
|
+
exit 0
|
@@ -0,0 +1,13 @@
|
|
1
|
+
[program:resque_scheduler]
|
2
|
+
user=<%= fetch(:user) %>
|
3
|
+
environment=HOME="/home/<%= fetch(:user) %>",USER="<%= fetch(:user) %>"
|
4
|
+
directory=<%= fetch(:deploy_to) %>/current
|
5
|
+
command=/home/<%= fetch(:user) %>/.rvm/bin/rvm <%= fetch(:rvm_ruby_version, '2.4.7') %> do bundle exec rake RAILS_ENV=<%= fetch(:rails_env) %> QUEUE='*' environment resque:scheduler 2>&1 > <%= fetch(:deploy_to) %>/shared/log/resque_scheduler.log
|
6
|
+
autostart=<%= fetch(:autostart, 'true') %>
|
7
|
+
autorestart=<%= fetch(:autorestart, 'true') %>
|
8
|
+
stopsignal=QUIT
|
9
|
+
startsecs=5
|
10
|
+
startretries=3
|
11
|
+
stdout_logfile=<%= fetch(:deploy_to) %>/shared/log/resque_scheduler.log
|
12
|
+
stdout_logfile_maxbytes=<%= fetch(:logfile_maxbytes, '1GB') %>
|
13
|
+
stdout_logfile_backups=<%= fetch(:logfile_backups, '10') %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
[program:resque]
|
2
|
+
user=<%= fetch(:user) %>
|
3
|
+
environment=HOME="/home/<%= fetch(:user) %>",USER="<%= fetch(:user) %>"
|
4
|
+
directory=<%= fetch(:deploy_to) %>/current
|
5
|
+
command=/home/<%= fetch(:user) %>/.rvm/bin/rvm <%= fetch(:rvm_ruby_version, '2.4.7') %> do bundle exec rake RAILS_ENV=<%= fetch(:rails_env) %> QUEUE=critical,default,mailers,low environment resque:work 2>&1 > <%= fetch(:deploy_to) %>/shared/log/resque.log
|
6
|
+
autostart=<%= fetch(:autostart, 'true') %>
|
7
|
+
autorestart=<%= fetch(:autorestart, 'true') %>
|
8
|
+
stopsignal=QUIT
|
9
|
+
startsecs=5
|
10
|
+
startretries=3
|
11
|
+
stdout_logfile=<%= fetch(:deploy_to) %>/shared/log/resque.log
|
12
|
+
stdout_logfile_maxbytes=<%= fetch(:logfile_maxbytes, '1GB') %>
|
13
|
+
stdout_logfile_backups=<%= fetch(:logfile_backups, '10') %>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
### BEGIN INIT INFO
|
4
|
+
# Provides: sidekiq
|
5
|
+
# Required-Start: $local_fs $remote_fs $network $syslog
|
6
|
+
# Required-Stop: $local_fs $remote_fs $network $syslog
|
7
|
+
# Default-Start: 2 3 4 5
|
8
|
+
# Default-Stop: 0 1 6
|
9
|
+
# Short-Description: starts the sidekiq web server
|
10
|
+
# Description: starts sidekiq
|
11
|
+
### END INIT INFO
|
12
|
+
|
13
|
+
USER="<%= fetch(:user) %>"
|
14
|
+
DAEMON=sidekiq
|
15
|
+
PROJECT_PATH="<%= fetch(:deploy_to) %>"
|
16
|
+
NAME=sidekiq
|
17
|
+
DESC="Sidekiq app for $USER"
|
18
|
+
PID="$PROJECT_PATH/shared/pids/sidekiq.pid"
|
19
|
+
LOGFILE="$PROJECT_PATH/shared/log/sidekiq.log"
|
20
|
+
CD_TO_APP_DIR="cd $PROJECT_PATH/current"
|
21
|
+
|
22
|
+
case "$1" in
|
23
|
+
start)
|
24
|
+
START_DAEMON_PROCESS="bundle exec sidekiq -d -e <%= fetch(:rails_env) %> -L $LOGFILE -P $PID"
|
25
|
+
|
26
|
+
echo -n "Starting $DESC: "
|
27
|
+
if [ `whoami` = 'root' ]; then
|
28
|
+
su - $USER -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
|
29
|
+
else
|
30
|
+
/bin/bash -l -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
|
31
|
+
fi
|
32
|
+
echo "$NAME."
|
33
|
+
;;
|
34
|
+
stop)
|
35
|
+
echo -n "Stopping $DESC: "
|
36
|
+
if [ `whoami` = 'root' ]; then
|
37
|
+
su - $USER -c "$CD_TO_APP_DIR && bundle exec sidekiqctl stop $PID 60"
|
38
|
+
else
|
39
|
+
/bin/bash -l -c "$CD_TO_APP_DIR && bundle exec sidekiqctl stop $PID 60"
|
40
|
+
fi
|
41
|
+
echo "$NAME."
|
42
|
+
;;
|
43
|
+
*)
|
44
|
+
echo "Usage: $NAME {start|stop|restart|reload}" >&2
|
45
|
+
exit 1
|
46
|
+
;;
|
47
|
+
esac
|
48
|
+
|
49
|
+
exit 0
|
@@ -0,0 +1,12 @@
|
|
1
|
+
[program:sidekiq]
|
2
|
+
user=<%= fetch(:user) %>
|
3
|
+
environment=HOME="/home/<%= fetch(:user) %>",USER="<%= fetch(:user) %>"
|
4
|
+
directory=<%= fetch(:deploy_to) %>/current
|
5
|
+
command=/home/<%= fetch(:user) %>/.rvm/bin/rvm <%= fetch(:rvm_ruby_version, '2.4.7') %> do bundle exec sidekiq -L <%= fetch(:deploy_to) %>/shared/log/sidekiq.log -e <%= fetch(:rails_env) %>
|
6
|
+
autostart=<%= fetch(:autostart, 'true') %>
|
7
|
+
autorestart=<%= fetch(:autorestart, 'true') %>
|
8
|
+
startsecs=5
|
9
|
+
startretries=3
|
10
|
+
stdout_logfile=<%= fetch(:deploy_to) %>/shared/log/sidekiq.log
|
11
|
+
stdout_logfile_maxbytes=<%= fetch(:logfile_maxbytes, '1GB') %>
|
12
|
+
stdout_logfile_backups=<%= fetch(:logfile_backups, '10') %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
[Unit]
|
2
|
+
Description=Sidekiq Background Process
|
3
|
+
After=syslog.target network.target
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
Type=simple
|
7
|
+
User=<%= fetch(:user) %>
|
8
|
+
WorkingDirectory=<%= fetch(:deploy_to) %>/current
|
9
|
+
|
10
|
+
# Helpful for debugging socket activation, etc.
|
11
|
+
Environment=MALLOC_ARENA_MAX=2
|
12
|
+
|
13
|
+
ExecStart=/bin/bash -l -c 'bundle exec sidekiq -L <%= fetch(:deploy_to) %>/shared/log/sidekiq.log -e <%= fetch(:rails_env) %>'
|
14
|
+
Restart=always
|
15
|
+
|
16
|
+
[Install]
|
17
|
+
WantedBy=multi-user.target
|
@@ -0,0 +1,19 @@
|
|
1
|
+
; Generated with pixelforce recipies
|
2
|
+
[unix_http_server]
|
3
|
+
file=/tmp/supervisor.sock ; (the path to the socket file)
|
4
|
+
chmod=0700 ; sockef file mode (default 0700)
|
5
|
+
|
6
|
+
[supervisord]
|
7
|
+
user=<%= fetch(:user) %>
|
8
|
+
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
|
9
|
+
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
|
10
|
+
|
11
|
+
[rpcinterface:supervisor]
|
12
|
+
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
13
|
+
|
14
|
+
[supervisorctl]
|
15
|
+
serverurl=unix:///tmp/supervisor.sock
|
16
|
+
|
17
|
+
[include]
|
18
|
+
files = /etc/supervisor/conf.d/*.conf
|
19
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
### BEGIN INIT INFO
|
4
|
+
# Provides: <%= fetch(:application) %>
|
5
|
+
# Required-Start: $local_fs $remote_fs $network $syslog
|
6
|
+
# Required-Stop: $local_fs $remote_fs $network $syslog
|
7
|
+
# Default-Start: 2 3 4 5
|
8
|
+
# Default-Stop: 0 1 6
|
9
|
+
# Short-Description: starts the unicorn web server
|
10
|
+
# Description: starts unicorn
|
11
|
+
### END INIT INFO
|
12
|
+
|
13
|
+
USER="<%= fetch(:user) %>"
|
14
|
+
DAEMON=unicorn
|
15
|
+
PROJECT_PATH="<%= fetch(:deploy_to) %>"
|
16
|
+
DAEMON_OPTS="-c $PROJECT_PATH/current/config/unicorn.rb -E <%= fetch(:rails_env) %> -D"
|
17
|
+
NAME=unicorn
|
18
|
+
DESC="Unicorn app for $USER"
|
19
|
+
PID="$PROJECT_PATH/shared/pids/unicorn.pid"
|
20
|
+
|
21
|
+
case "$1" in
|
22
|
+
start)
|
23
|
+
CD_TO_APP_DIR="cd $PROJECT_PATH/current"
|
24
|
+
START_DAEMON_PROCESS="bundle exec $DAEMON $DAEMON_OPTS"
|
25
|
+
|
26
|
+
echo -n "Starting $DESC: "
|
27
|
+
if [ `whoami` = 'root' ]; then
|
28
|
+
su - $USER -c "$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS"
|
29
|
+
else
|
30
|
+
$CD_TO_APP_DIR > /dev/null 2>&1 && $START_DAEMON_PROCESS
|
31
|
+
fi
|
32
|
+
echo "$NAME."
|
33
|
+
;;
|
34
|
+
stop)
|
35
|
+
echo -n "Stopping $DESC: "
|
36
|
+
kill -QUIT `cat $PID`
|
37
|
+
echo "$NAME."
|
38
|
+
;;
|
39
|
+
restart)
|
40
|
+
echo -n "Restarting $DESC: "
|
41
|
+
kill -USR2 `cat $PID`
|
42
|
+
echo "$NAME."
|
43
|
+
;;
|
44
|
+
reload)
|
45
|
+
echo -n "Reloading $DESC configuration: "
|
46
|
+
kill -HUP `cat $PID`
|
47
|
+
echo "$NAME."
|
48
|
+
;;
|
49
|
+
*)
|
50
|
+
echo "Usage: $NAME {start|stop|restart|reload}" >&2
|
51
|
+
exit 1
|
52
|
+
;;
|
53
|
+
esac
|
54
|
+
|
55
|
+
exit 0
|
@@ -0,0 +1,13 @@
|
|
1
|
+
[program:<%= fetch(:application) %>]
|
2
|
+
user=<%= fetch(:user) %>
|
3
|
+
environment=HOME="/home/<%= fetch(:user) %>",USER="<%= fetch(:user) %>"
|
4
|
+
directory=<%= fetch(:deploy_to) %>/current
|
5
|
+
command=/home/<%= fetch(:user) %>/.rvm/bin/rvm <%= fetch(:rvm_ruby_version, '2.4.7') %> do bundle exec unicornherder -u unicorn -p <%= fetch(:deploy_to) %>/shared/pids/unicorn.pid -- -c config/unicorn.rb -E <%= fetch(:rails_env) %>
|
6
|
+
autostart=<%= fetch(:autostart, 'true') %>
|
7
|
+
autorestart=<%= fetch(:autorestart, 'true') %>
|
8
|
+
startsecs=5
|
9
|
+
startretries=3
|
10
|
+
stderr_logfile=<%= fetch(:deploy_to) %>/shared/log/<%= fetch(:application) %>.log
|
11
|
+
stdout_logfile=<%= fetch(:deploy_to) %>/shared/log/<%= fetch(:rails_env) %>.log
|
12
|
+
stdout_logfile_maxbytes=<%= fetch(:logfile_maxbytes, '5GB') %>
|
13
|
+
stdout_logfile_backups=<%= fetch(:logfile_backups, '10') %>
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
ENV['RAILS_ENV'] = 'test'
|
4
|
+
|
5
|
+
require 'rails'
|
6
|
+
require 'active_record'
|
7
|
+
require 'action_controller/railtie'
|
8
|
+
require 'rspec/rails'
|
9
|
+
require 'devise'
|
10
|
+
require 'devise_token_auth'
|
11
|
+
require 'kaminari'
|
12
|
+
require 'jbuilder'
|
13
|
+
require 'ahoy_matey'
|
14
|
+
require 'factory_bot'
|
15
|
+
require 'fake_app'
|
16
|
+
require 'database_cleaner/active_record'
|
17
|
+
require 'net/http'
|
18
|
+
require 'webmock/rspec'
|
19
|
+
|
20
|
+
load "#{File.dirname(__FILE__)}/../../db/schema.rb"
|
21
|
+
ActiveRecord::Migration.verbose = false
|
22
|
+
ActiveRecord::MigrationContext.new(ActiveRecord::Migrator.migrations_paths).migrate
|
23
|
+
|
24
|
+
FactoryBot.definition_file_paths += [File.expand_path('../../spec/factories', __dir__)]
|
25
|
+
|
26
|
+
module AuthenticationHelpers
|
27
|
+
def sign_in(user)
|
28
|
+
if(user.is_a?(User))
|
29
|
+
allow(controller).to receive(:current_user).and_return(user)
|
30
|
+
allow(controller).to receive(:authenticate_user!).and_return(true)
|
31
|
+
else
|
32
|
+
allow(controller).to receive(:current_admin_user).and_return(user)
|
33
|
+
allow(controller).to receive(:authenticate_admin_user!).and_return(true)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def sign_out
|
38
|
+
if(user.is_a?(User))
|
39
|
+
allow(controller).to receive(:current_user).and_return(nil)
|
40
|
+
allow(controller).to receive(:authenticate_user!).and_return(false)
|
41
|
+
else
|
42
|
+
allow(controller).to receive(:current_admin_user).and_return(nil)
|
43
|
+
allow(controller).to receive(:authenticate_admin_user!).and_return(false)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
RSpec.configure do |config|
|
49
|
+
config.exclude_pattern = 'spec/integration/**/*_spec.rb'
|
50
|
+
config.run_all_when_everything_filtered = true
|
51
|
+
config.filter_run :focus
|
52
|
+
config.order = 'random'
|
53
|
+
config.render_views
|
54
|
+
|
55
|
+
# Enable flags like --only-failures and --next-failure
|
56
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
57
|
+
|
58
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
59
|
+
config.disable_monkey_patching!
|
60
|
+
|
61
|
+
config.include AuthenticationHelpers, type: :controller
|
62
|
+
|
63
|
+
config.expect_with :rspec do |c|
|
64
|
+
c.syntax = %i[should expect]
|
65
|
+
end
|
66
|
+
config.include FactoryBot::Syntax::Methods
|
67
|
+
|
68
|
+
config.before(:suite) do
|
69
|
+
DatabaseCleaner.strategy = :truncation
|
70
|
+
FactoryBot.find_definitions
|
71
|
+
end
|
72
|
+
|
73
|
+
config.before(:each) do
|
74
|
+
DatabaseCleaner.clean
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
RSpec::Matchers.define :equal_time do |expected|
|
79
|
+
match do |actual|
|
80
|
+
expected.to_i == actual.to_i
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
RSpec.configure do |config|
|
85
|
+
config.include AuthenticationHelpers, type: :controller
|
86
|
+
end
|
87
|
+
|
88
|
+
RSpec::Expectations.configuration.on_potential_false_positives = :nothing
|
89
|
+
|
90
|
+
def travel_to(date_or_time)
|
91
|
+
now = if date_or_time.is_a?(Date) && !date_or_time.is_a?(DateTime)
|
92
|
+
date_or_time.midnight.to_time
|
93
|
+
else
|
94
|
+
date_or_time.to_time.change(usec: 0)
|
95
|
+
end
|
96
|
+
|
97
|
+
allow(Time).to receive(:now).and_return(Time.at(now.to_i))
|
98
|
+
allow(DateTime).to receive(:now).and_return(Time.at(now.to_i))
|
99
|
+
allow(Date).to receive(:today).and_return(now.to_date)
|
100
|
+
end
|
101
|
+
|
102
|
+
def travel(duration)
|
103
|
+
travel_to Time.now + duration
|
104
|
+
end
|
105
|
+
|
106
|
+
class ApplicationRecord < ActiveRecord::Base
|
107
|
+
self.abstract_class = true
|
108
|
+
end
|
109
|
+
|
110
|
+
class User < ApplicationRecord
|
111
|
+
end
|
112
|
+
|
113
|
+
class AdminUser < ActiveRecord::Base
|
114
|
+
end
|
115
|
+
|
116
|
+
class ApplicationController < ActionController::Base
|
117
|
+
def get_search_params
|
118
|
+
{}
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pixelforce_kit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pixelforce_kit"
|
8
|
+
spec.version = PixelforceKit::VERSION
|
9
|
+
spec.authors = ["Ben Zhang"]
|
10
|
+
spec.email = ["bzbnhang@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Write a short summary, because Rubygems requires one.}
|
13
|
+
spec.description = %q{Write a longer description or delete this line.}
|
14
|
+
spec.homepage = "https://github.com/BenZhang/pixelforce_kit"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
23
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
spec.add_development_dependency 'faker'
|
26
|
+
spec.add_dependency "elbas"
|
27
|
+
spec.add_dependency 'devise'
|
28
|
+
spec.add_dependency 'devise_token_auth'
|
29
|
+
spec.add_dependency 'kaminari'
|
30
|
+
spec.add_dependency 'jbuilder'
|
31
|
+
spec.add_dependency 'ahoy_matey'
|
32
|
+
spec.add_dependency(%q<capistrano>, ["> 3.0.0"])
|
33
|
+
end
|