Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup tweaks #1246

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions app/controllers/setup/kits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ def new
def create
case @kit
when :none
# weaksauce alert: this creates a Node which flags the Setup as done.
Project.new.issue_library
mark_as_done
when :welcome
kit_folder = Rails.root.join('lib','tasks', 'templates','welcome').to_s
kit_folder = Rails.root.join('lib', 'tasks', 'templates', 'welcome').to_s
logger = Log.new.info('Loading Welcome kit...')
# Before we import the Kit we need at least 1 user
User.create!(email: '[email protected]')
User.create!(email: '[email protected]') unless defined?(Dradis::Pro)
KitImportJob.perform_later(kit_folder, logger: logger)
end

Expand All @@ -24,9 +23,22 @@ def create

private
def ensure_pristine
defined?(Dradis::Pro) ? ensure_pristine_pro : ensure_pristine_ce
end

def ensure_pristine_ce
redirect_to project_path(1) unless Node.count.zero?
end

def mark_as_done
defined?(Dradis::Pro) ? mark_as_done_pro : mark_as_done_ce
end

def mark_as_done_ce
# weaksauce alert: this creates a Node which flags the Setup as done.
Project.new.issue_library
end

def set_kit
if %w{none welcome}.include?(params[:kit])
@kit = params[:kit].to_sym
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@
namespace :setup, only: [:index] do
if defined?(Dradis::Pro)
else
resource :kit, only: [:new, :create]
resource :password, only: [:new, :create]
end
resource :kit, only: [:new, :create]
end

resources :subscriptions, only: [:index, :create, :destroy]
Expand Down
Loading