Skip to content

Commit

Permalink
Merged in feature/make_user_side (pull request #32)
Browse files Browse the repository at this point in the history
KBP-117 #time 1d - User side was done

Approved-by: İsmail Akbudak <[email protected]>
  • Loading branch information
Hamdi Bayhan committed Dec 7, 2017
2 parents d841e7c + 0ac62dd commit 1c57749
Show file tree
Hide file tree
Showing 58 changed files with 1,150 additions and 325 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ Naming/HeredocDelimiterNaming:
Exclude:
- 'spec/features/cli_help_spec.rb'
- 'spec/features/git_and_git_flow_spec.rb'

Style/ClassAndModuleChildren:
Exclude:
- 'templates/app_files/app/controllers/**/*.rb'
1 change: 1 addition & 0 deletions lib/cybele.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
require 'cybele/helpers/app_files/assets_files'
require 'cybele/helpers/app_files/controller_files'
require 'cybele/helpers/app_files/model_files'
require 'cybele/helpers/app_files/vendor_files'
require 'cybele/helpers/app_files/mailer_files'
require 'cybele/helpers/app_files/helper_files'
require 'cybele/helpers/app_files/view_files'
Expand Down
1 change: 1 addition & 0 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AppBuilder < Rails::AppBuilder # rubocop:disable Metrics/ClassLength
include Cybele::Helpers::AppFiles::AssetsFiles
include Cybele::Helpers::AppFiles::ControllerFiles
include Cybele::Helpers::AppFiles::ModelFiles
include Cybele::Helpers::AppFiles::VendorFiles
include Cybele::Helpers::AppFiles::MailerFiles
include Cybele::Helpers::AppFiles::HelperFiles
include Cybele::Helpers::AppFiles::ViewFiles
Expand Down
10 changes: 10 additions & 0 deletions lib/cybele/helpers/app_files/assets_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ module Helpers
module AppFiles
module AssetsFiles
def customize_assets_files
javascript_files
stylesheet_files
end

def javascript_files
# Javascript Assets files
remove_file 'app/assets/javascripts/application.js', force: true

Expand All @@ -15,7 +20,9 @@ def customize_assets_files
template 'app_files/app/assets/javascripts/hq/application.js',
'app/assets/javascripts/hq/application.js',
force: true
end

def stylesheet_files
# Css Assets files
remove_file 'app/assets/stylesheets/application.css', force: true

Expand All @@ -26,6 +33,9 @@ def customize_assets_files
template 'app_files/app/assets/stylesheets/hq/application.css.sass',
'app/assets/stylesheets/hq/application.css.sass',
force: true

copy_file 'app_files/app/assets/stylesheets/hq/_sidebar.css.sass',
'app/assets/stylesheets/hq/_sidebar.css.sass'
end
end
end
Expand Down
5 changes: 4 additions & 1 deletion lib/cybele/helpers/app_files/controller_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ module Helpers
module AppFiles
module ControllerFiles
def customize_controller_files
# HQ controller files
# Hq controller files
directory 'app_files/app/controllers/hq', 'app/controllers/hq'

# User controller files
directory 'app_files/app/controllers/user', 'app/controllers/user'

# Welcome controller
copy_file 'app_files/app/controllers/welcome_controller.rb', 'app/controllers/welcome_controller.rb'
end
Expand Down
1 change: 1 addition & 0 deletions lib/cybele/helpers/app_files/model_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module ModelFiles
def customize_model_files
# Model files
remove_file 'app/models/admin.rb', force: true
remove_file 'app/models/user.rb', force: true
directory 'app_files/app/models', 'app/models'
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cybele/helpers/app_files/vendor_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Helpers
module AppFiles
module VendorFiles
def customize_vendor_files
# View files with option
directory 'app_files/app/vendor', 'app/vendor'
# javascript and stylesheet files in vendor
directory 'app_files/app/vendor/assets', 'vendor/assets'
end
end
end
Expand Down
27 changes: 25 additions & 2 deletions lib/cybele/helpers/app_files/view_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,39 @@ module ViewFiles
def customize_view_files_with_option
# View files with option
directory 'app_files/app/views/hq', 'app/views/hq'
directory 'app_files/app/views/user', 'app/views/user'
directory 'app_files/app/views/layouts/hq', 'app/views/layouts/hq'
directory 'app_files/app/views/layouts/partials', 'app/views/layouts/partials'
directory 'app_files/app/views/welcome', 'app/views/welcome'
template 'app_files/app/views/layouts/application.html.haml.erb',
'app/views/layouts/application.html.haml', force: true
replace_erb_with_haml
end

def customize_default_view_files
# Default view files
directory 'app_files/app/views/admin_mailer', 'app/views/admin_mailer'
directory 'app_files/app/views/user_mailer', 'app/views/user_mailer'
end

def replace_erb_with_haml
remove_file 'app/views/welcome/index.html.erb', force: true
template 'app_files/app/views/welcome/index.html.erb',
'app/views/welcome/index.html.haml', force: true

remove_file 'app/views/layouts/mailer.html.erb', force: true
template 'app_files/app/views/layouts/mailer.html.erb',
'app/views/layouts/mailer.html.haml', force: true

remove_file 'app/views/layouts/application.html.erb', force: true
template 'app_files/app/views/layouts/application.html.erb',
'app/views/layouts/application.html.haml', force: true

remove_file 'app/views/layouts/partials/_navbar.html.erb', force: true
template 'app_files/app/views/layouts/partials/_navbar.html.erb',
'app/views/layouts/partials/_navbar.html.haml', force: true

remove_file 'app/views/layouts/hq/application.html.erb', force: true
template 'app_files/app/views/layouts/hq/application.html.erb',
'app/views/layouts/hq/application.html.haml', force: true
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/cybele/helpers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def generate_devise_models
generate 'devise User name:string surname:string is_active:boolean time_zone:string'
generate 'devise Admin name:string surname:string is_active:boolean time_zone:string'
remove_file 'config/locales/devise.en.yml', force: true
copy_file 'config/locales/devise.en.yml', 'config/locales/devise.en.yml'
copy_file 'config/locales/devise.tr.yml', 'config/locales/devise.tr.yml'
end

def generate_devise_views
Expand Down
6 changes: 5 additions & 1 deletion lib/cybele/helpers/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ def configure_routes
'devise_for :admins',
''

# User routes
replace_in_file 'config/routes.rb',
'devise_for :users',
''

inject_into_file 'config/routes.rb', template_content('config/routes.rb.erb'),
before: 'if Rails.env.production? || Rails.env.staging?'

end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/cybele/helpers/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def create_sidekiq_files
template 'sidekiq/sidekiq_schedule.yml.erb',
'config/sidekiq_schedule.yml',
force: true
# Proc file
template 'sidekiq/sidekiq_Procfile.erb',
'Procfile',
force: true
end
end
end
Expand Down
55 changes: 46 additions & 9 deletions spec/features/new_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,34 +241,55 @@
expect(application_controller).to match('class ApplicationController')
expect(application_controller).to match('configure_devise_permitted_parameters')

# Hq files
hq_admins_controller = content('app/controllers/hq/admins_controller.rb')
expect(hq_admins_controller).to match('class AdminsController')
expect(hq_admins_controller).to match('class Hq::AdminsController')

hq_application_controller = content('app/controllers/hq/application_controller.rb')
expect(hq_application_controller).to match('class ApplicationController')
expect(hq_application_controller).to match('class Hq::ApplicationController')
expect(hq_application_controller).to match('before_action :authenticate_admin!')

hq_audits_controller = content('app/controllers/hq/audits_controller.rb')
expect(hq_audits_controller).to match('class AuditsController')
expect(hq_audits_controller).to match('class Hq::AuditsController')

hq_dashboard_controller = content('app/controllers/hq/dashboard_controller.rb')
expect(hq_dashboard_controller).to match('class DashboardController')
expect(hq_dashboard_controller).to match('class Hq::DashboardController')

hq_passwords_controller = content('app/controllers/hq/passwords_controller.rb')
expect(hq_passwords_controller).to match('class PasswordsController')
expect(hq_passwords_controller).to match('class Hq::PasswordsController')

hq_registrations_controller = content('app/controllers/hq/registrations_controller.rb')
expect(hq_registrations_controller).to match('class RegistrationsController')
expect(hq_registrations_controller).to match('class Hq::RegistrationsController')

hq_sessions_controller = content('app/controllers/hq/sessions_controller.rb')
expect(hq_sessions_controller).to match('class SessionsController')
expect(hq_sessions_controller).to match('class Hq::SessionsController')

hq_users_controller = content('app/controllers/hq/users_controller.rb')
expect(hq_users_controller).to match('class UsersController')
expect(hq_users_controller).to match('class Hq::UsersController')

# User files
user_application_controller = content('app/controllers/user/application_controller.rb')
expect(user_application_controller).to match('class User::ApplicationController')
expect(user_application_controller).to match('before_action :authenticate_user!')

user_dashboard_controller = content('app/controllers/user/dashboard_controller.rb')
expect(user_dashboard_controller).to match('class User::DashboardController')

user_passwords_controller = content('app/controllers/user/passwords_controller.rb')
expect(user_passwords_controller).to match('class User::PasswordsController')

user_profile_controller = content('app/controllers/user/profile_controller.rb')
expect(user_profile_controller).to match('class User::ProfileController')

user_registrations_controller = content('app/controllers/user/registrations_controller.rb')
expect(user_registrations_controller).to match('class User::RegistrationsController')

user_sessions_controller = content('app/controllers/user/sessions_controller.rb')
expect(user_sessions_controller).to match('class User::SessionsController')
end

it 'uses view files with option' do
# HQ files
# Hq files
hq_admins_view = content('app/views/hq/admins/index.html.haml')
expect(hq_admins_view).to match('@admins')

Expand All @@ -290,6 +311,22 @@
hq_users_view = content('app/views/hq/users/index.html.haml')
expect(hq_users_view).to match('@users')

# User files
user_dashboard_view = content('app/views/user/dashboard/index.html.haml')
expect(user_dashboard_view).to match('current_user.email')

user_passwords_view = content('app/views/user/passwords/new.html.haml')
expect(user_passwords_view).to match('password_path')

user_registrations_view = content('app/views/user/registrations/edit.html.haml')
expect(user_registrations_view).to match('user_registration_path')

user_sessions_view = content('app/views/user/sessions/new.html.haml')
expect(user_sessions_view).to match('session_path')

user_profile_view = content('app/views/user/profile/show.html.haml')
expect(user_profile_view).to match('@profile')

# Layouts
expect(File).to exist(file_project_path('app/views/layouts/hq/partials/_dock.html.haml'))
expect(File).to exist(file_project_path('app/views/layouts/hq/partials/_breadcrumb.html.haml'))
Expand Down
19 changes: 18 additions & 1 deletion spec/features/new_not_default_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@

it 'do not use controller files' do
expect(File).to exist(file_project_path('app/controllers/application_controller.rb'))

# Hq files
expect(File).not_to exist(file_project_path('app/controllers/hq/admins_controller.rb'))
expect(File).not_to exist(file_project_path('app/controllers/hq/application_controller.rb'))
expect(File).not_to exist(file_project_path('app/controllers/hq/audits_controller.rb'))
Expand All @@ -219,10 +221,18 @@
expect(File).not_to exist(file_project_path('app/controllers/hq/registrations_controller.rb'))
expect(File).not_to exist(file_project_path('app/controllers/hq/sessions_controller.rb'))
expect(File).not_to exist(file_project_path('app/controllers/hq/users_controller.rb'))

# User files
expect(File).not_to exist(file_project_path('app/controllers/user/application_controller.rb'))
expect(File).not_to exist(file_project_path('app/controllers/user/dashboard_controller.rb'))
expect(File).not_to exist(file_project_path('app/controllers/user/passwords_controller.rb'))
expect(File).not_to exist(file_project_path('app/controllers/user/registrations_controller.rb'))
expect(File).not_to exist(file_project_path('app/controllers/user/sessions_controller.rb'))
expect(File).not_to exist(file_project_path('app/controllers/user/profile_controller.rb'))
end

it 'do not use view files with option' do
# HQ files
# Hq files
expect(File).not_to exist(file_project_path('app/views/hq/admins/index.html.haml'))
expect(File).not_to exist(file_project_path('app/views/hq/audits/index.html.haml'))
expect(File).not_to exist(file_project_path('app/views/hq/dashboard/index.html.haml'))
Expand All @@ -231,6 +241,13 @@
expect(File).not_to exist(file_project_path('app/views/hq/sessions/new.html.haml'))
expect(File).not_to exist(file_project_path('app/views/hq/users/index.html.haml'))

# User files
expect(File).not_to exist(file_project_path('app/views/user/dashboard/index.html.haml'))
expect(File).not_to exist(file_project_path('app/views/user/passwords/new.html.haml'))
expect(File).not_to exist(file_project_path('app/views/user/registrations/edit.html.haml'))
expect(File).not_to exist(file_project_path('app/views/user/sessions/new.html.haml'))
expect(File).not_to exist(file_project_path('app/views/user/profile/show.html.haml'))

# Layouts
expect(File).not_to exist(file_project_path('app/views/layouts/hq/partials/_breadcrumb.html.haml'))
expect(File).not_to exist(file_project_path('app/views/layouts/hq/partials/_dock.html.haml'))
Expand Down
3 changes: 2 additions & 1 deletion spec/support/devise_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def devise_model_file_test # rubocop:disable Metrics/AbcSize
end

def file_control_test
expect(File).not_to exist(file_project_path('config/locales/devise.en.yml'))
expect(File).to exist(file_project_path('config/locales/devise.en.yml'))
expect(File).to exist(file_project_path('config/locales/devise.tr.yml'))
end
end
60 changes: 60 additions & 0 deletions templates/app_files/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,67 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require popper
//= require jquery
//= require rails-ujs
//= require turbolinks
//= require bootstrap
//= require footable.min
//= require jquery.maskedinput.min
//= require trix
//= require jquery.datetimepicker
//= require nprogress
//= require_tree .

var ready = function(){
$('.table').footable();

$('.datetimepicker').datetimepicker({
format: $('.datetimepicker').data('format'),
step: 60,
lang: 'tr',
minDate: 0,
defaultTime: '12:00'
});

$(function () {
$('[data-toggle="tooltip"]').tooltip()
});

$("[data-mask]").each(function(index, element) {
var $element;
$element = $(element);
$element.mask($element.data('mask'));
});
$('form[data-turboform]').on('submit', function(e) {
Turbolinks.visit(this.action + (this.action.indexOf('?') === -1 ? '?' : '&') + $(this).serialize());
return false;
});
};

$(document).on('page:load', ready);

document.addEventListener("turbolinks:load", ready)

$(window).on('page:load', ready);

$(document).on('page:fetch', function() {
NProgress.start();
});

$(document).on('page:change', function() {
NProgress.done();
});

$(document).on('page:restore', function() {
NProgress.remove();
});

$(document).ajaxStart(function() {
NProgress.start();
});

$(document).ajaxComplete(function() {
NProgress.done();
});

Loading

0 comments on commit 1c57749

Please sign in to comment.