incline 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +186 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +208 -0
- data/Rakefile +37 -0
- data/app/assets/fonts/incline/.keep +0 -0
- data/app/assets/images/incline/.keep +0 -0
- data/app/assets/images/incline/barcode-B.svg +181 -0
- data/app/assets/javascripts/incline/activate_classed_items.js +11 -0
- data/app/assets/javascripts/incline/application.js +30 -0
- data/app/assets/javascripts/incline/bootstrap-datepicker.js +1800 -0
- data/app/assets/javascripts/incline/datatables.js +22193 -0
- data/app/assets/javascripts/incline/escapeHtml.js +10 -0
- data/app/assets/javascripts/incline/inline_actions.js +479 -0
- data/app/assets/javascripts/incline/jquery.doubleScroll.js +112 -0
- data/app/assets/javascripts/incline/jquery.number.js +764 -0
- data/app/assets/javascripts/incline/regexMask.js +27 -0
- data/app/assets/javascripts/incline/select2/i18n/en.js +3 -0
- data/app/assets/javascripts/incline/select2/select2.full.js +6436 -0
- data/app/assets/stylesheets/incline/application.css +18 -0
- data/app/assets/stylesheets/incline/bootstrap-theme.min.css +5 -0
- data/app/assets/stylesheets/incline/custom.scss +279 -0
- data/app/assets/stylesheets/incline/datatables.css +494 -0
- data/app/assets/stylesheets/incline/datepicker3.css +790 -0
- data/app/assets/stylesheets/incline/select2.css +484 -0
- data/app/controllers/incline/access_groups_controller.rb +127 -0
- data/app/controllers/incline/access_test_controller.rb +30 -0
- data/app/controllers/incline/account_activations_controller.rb +28 -0
- data/app/controllers/incline/application_controller.rb +11 -0
- data/app/controllers/incline/contact_controller.rb +34 -0
- data/app/controllers/incline/password_resets_controller.rb +113 -0
- data/app/controllers/incline/security_controller.rb +100 -0
- data/app/controllers/incline/sessions_controller.rb +50 -0
- data/app/controllers/incline/users_controller.rb +304 -0
- data/app/controllers/incline/welcome_controller.rb +19 -0
- data/app/helpers/incline/.keep +0 -0
- data/app/mailers/incline/application_mailer_base.rb +11 -0
- data/app/mailers/incline/contact_form.rb +19 -0
- data/app/mailers/incline/user_mailer.rb +45 -0
- data/app/models/incline/access_group.rb +121 -0
- data/app/models/incline/access_group_group_member.rb +12 -0
- data/app/models/incline/access_group_user_member.rb +10 -0
- data/app/models/incline/action_group.rb +12 -0
- data/app/models/incline/action_security.rb +222 -0
- data/app/models/incline/contact_message.rb +37 -0
- data/app/models/incline/disable_info.rb +20 -0
- data/app/models/incline/password_reset.rb +14 -0
- data/app/models/incline/password_reset_request.rb +14 -0
- data/app/models/incline/user.rb +437 -0
- data/app/models/incline/user_login_history.rb +30 -0
- data/app/views/incline/access_groups/_details.json.jbuilder +10 -0
- data/app/views/incline/access_groups/_form.html.erb +19 -0
- data/app/views/incline/access_groups/_list.html.erb +60 -0
- data/app/views/incline/access_groups/_messages.json.jbuilder +6 -0
- data/app/views/incline/access_groups/edit.html.erb +2 -0
- data/app/views/incline/access_groups/index.html.erb +6 -0
- data/app/views/incline/access_groups/index.json.jbuilder +16 -0
- data/app/views/incline/access_groups/new.html.erb +2 -0
- data/app/views/incline/access_groups/show.html.erb +9 -0
- data/app/views/incline/access_groups/show.json.jbuilder +11 -0
- data/app/views/incline/contact/new.html.erb +22 -0
- data/app/views/incline/contact_form/contact.html.erb +16 -0
- data/app/views/incline/contact_form/contact.text.erb +13 -0
- data/app/views/incline/password_resets/edit.html.erb +16 -0
- data/app/views/incline/password_resets/new.html.erb +12 -0
- data/app/views/incline/security/_details.json.jbuilder +7 -0
- data/app/views/incline/security/_form.html.erb +20 -0
- data/app/views/incline/security/_list.html.erb +89 -0
- data/app/views/incline/security/_messages.json.jbuilder +6 -0
- data/app/views/incline/security/edit.html.erb +2 -0
- data/app/views/incline/security/index.html.erb +6 -0
- data/app/views/incline/security/index.json.jbuilder +16 -0
- data/app/views/incline/security/show.html.erb +31 -0
- data/app/views/incline/security/show.json.jbuilder +11 -0
- data/app/views/incline/sessions/new.html.erb +26 -0
- data/app/views/incline/user_mailer/account_activation.html.erb +7 -0
- data/app/views/incline/user_mailer/account_activation.text.erb +6 -0
- data/app/views/incline/user_mailer/invalid_password_reset.html.erb +3 -0
- data/app/views/incline/user_mailer/invalid_password_reset.text.erb +5 -0
- data/app/views/incline/user_mailer/password_reset.html.erb +8 -0
- data/app/views/incline/user_mailer/password_reset.text.erb +7 -0
- data/app/views/incline/users/_details.json.jbuilder +32 -0
- data/app/views/incline/users/_form.html.erb +21 -0
- data/app/views/incline/users/_list.html.erb +102 -0
- data/app/views/incline/users/_messages.json.jbuilder +6 -0
- data/app/views/incline/users/disable_confirm.html.erb +19 -0
- data/app/views/incline/users/edit.html.erb +5 -0
- data/app/views/incline/users/index.html.erb +6 -0
- data/app/views/incline/users/index.json.jbuilder +16 -0
- data/app/views/incline/users/new.html.erb +5 -0
- data/app/views/incline/users/show.html.erb +12 -0
- data/app/views/incline/users/show.json.jbuilder +11 -0
- data/app/views/incline/welcome/home.html.erb +5 -0
- data/app/views/layouts/application.html.erb +1 -0
- data/app/views/layouts/incline/_account_menu.html.erb +18 -0
- data/app/views/layouts/incline/_app_menu_anon.html.erb +1 -0
- data/app/views/layouts/incline/_app_menu_authenticated.html.erb +1 -0
- data/app/views/layouts/incline/_footer.html.erb +13 -0
- data/app/views/layouts/incline/_header.html.erb +21 -0
- data/app/views/layouts/incline/_html_mailer.html.erb +5 -0
- data/app/views/layouts/incline/_incline_app.html.erb +25 -0
- data/app/views/layouts/incline/_messages.html.erb +3 -0
- data/app/views/layouts/incline/_shim.html.erb +3 -0
- data/app/views/layouts/incline/_text_mailer.text.erb +1 -0
- data/app/views/layouts/incline/application.html.erb +1 -0
- data/app/views/layouts/mailer.html.erb +2 -0
- data/app/views/layouts/mailer.text.erb +2 -0
- data/bin/rails +12 -0
- data/bin/test_scaffold.sh +10 -0
- data/config/routes.rb +61 -0
- data/db/migrate/20170511230126_create_incline_users.rb +26 -0
- data/db/migrate/20170515003052_create_incline_access_groups.rb +10 -0
- data/db/migrate/20170515003221_create_incline_user_login_histories.rb +12 -0
- data/db/migrate/20170515150908_create_incline_access_group_user_members.rb +11 -0
- data/db/migrate/20170515151058_create_incline_access_group_group_members.rb +11 -0
- data/db/migrate/20170517193432_add_comments_to_incline_user.rb +5 -0
- data/db/migrate/20170622132700_create_incline_action_securities.rb +16 -0
- data/db/migrate/20170622172712_create_incline_action_groups.rb +11 -0
- data/db/migrate/20170622195742_add_non_standard_to_action_security.rb +5 -0
- data/db/migrate/20170622230422_add_visible_to_action_security.rb +5 -0
- data/db/seeds.rb +81 -0
- data/exe/new_incline_app +42 -0
- data/lib/generators/incline/install_generator.rb +259 -0
- data/lib/generators/incline/templates/_app_menu_anon.html.erb +1 -0
- data/lib/generators/incline/templates/_app_menu_authenticated.html.erb +1 -0
- data/lib/generators/incline/templates/incline_application.css +17 -0
- data/lib/generators/incline/templates/incline_application.html.erb +1 -0
- data/lib/generators/incline/templates/incline_application.js +12 -0
- data/lib/generators/incline/templates/incline_database.yml +25 -0
- data/lib/generators/incline/templates/incline_email.yml +20 -0
- data/lib/generators/incline/templates/incline_mailer.html.erb +2 -0
- data/lib/generators/incline/templates/incline_mailer.text.erb +2 -0
- data/lib/generators/incline/templates/incline_users.yml +64 -0
- data/lib/generators/incline/templates/incline_version.rb +3 -0
- data/lib/incline/auth_engine_base.rb +52 -0
- data/lib/incline/data_tables_request.rb +336 -0
- data/lib/incline/date_time_formats.rb +6 -0
- data/lib/incline/engine.rb +212 -0
- data/lib/incline/errors.rb +15 -0
- data/lib/incline/extensions/action_controller_base.rb +526 -0
- data/lib/incline/extensions/action_mailer_base.rb +66 -0
- data/lib/incline/extensions/action_view_base.rb +489 -0
- data/lib/incline/extensions/active_record_base.rb +308 -0
- data/lib/incline/extensions/application.rb +137 -0
- data/lib/incline/extensions/application_configuration.rb +50 -0
- data/lib/incline/extensions/connection_adapter.rb +55 -0
- data/lib/incline/extensions/date_time_value.rb +123 -0
- data/lib/incline/extensions/date_value.rb +77 -0
- data/lib/incline/extensions/decimal_value.rb +55 -0
- data/lib/incline/extensions/erb_scaffold_generator.rb +31 -0
- data/lib/incline/extensions/float_value.rb +59 -0
- data/lib/incline/extensions/form_builder.rb +617 -0
- data/lib/incline/extensions/integer_value.rb +54 -0
- data/lib/incline/extensions/jbuilder_generator.rb +38 -0
- data/lib/incline/extensions/jbuilder_template.rb +39 -0
- data/lib/incline/extensions/main_app.rb +40 -0
- data/lib/incline/extensions/numeric.rb +63 -0
- data/lib/incline/extensions/object.rb +31 -0
- data/lib/incline/extensions/resource_route_generator.rb +53 -0
- data/lib/incline/extensions/session.rb +113 -0
- data/lib/incline/extensions/string.rb +50 -0
- data/lib/incline/extensions/test_case.rb +764 -0
- data/lib/incline/extensions/time_zone_converter.rb +40 -0
- data/lib/incline/global_status.rb +236 -0
- data/lib/incline/helpers/route_hash_formatter.rb +46 -0
- data/lib/incline/json_log_formatter.rb +96 -0
- data/lib/incline/json_logger.rb +17 -0
- data/lib/incline/log.rb +153 -0
- data/lib/incline/number_formats.rb +17 -0
- data/lib/incline/recaptcha.rb +346 -0
- data/lib/incline/user_manager.rb +212 -0
- data/lib/incline/validators/email_validator.rb +45 -0
- data/lib/incline/validators/ip_address_validator.rb +32 -0
- data/lib/incline/validators/recaptcha_validator.rb +37 -0
- data/lib/incline/validators/safe_name_validator.rb +31 -0
- data/lib/incline/version.rb +3 -0
- data/lib/incline/work_path.rb +75 -0
- data/lib/incline.rb +197 -0
- data/lib/tasks/incline_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +43 -0
- data/lib/templates/erb/scaffold/_list.html.erb +81 -0
- data/lib/templates/erb/scaffold/edit.html.erb +1 -0
- data/lib/templates/erb/scaffold/index.html.erb +6 -0
- data/lib/templates/erb/scaffold/new.html.erb +1 -0
- data/lib/templates/erb/scaffold/show.html.erb +34 -0
- data/lib/templates/jbuilder/scaffold/_details.json.jbuilder +20 -0
- data/lib/templates/jbuilder/scaffold/index.json.jbuilder +16 -0
- data/lib/templates/jbuilder/scaffold/show.json.jbuilder +16 -0
- data/lib/templates/rails/scaffold_controller/controller.rb +128 -0
- data/test/controllers/incline/access_groups_controller_test.rb +65 -0
- data/test/controllers/incline/access_test_controller_test.rb +53 -0
- data/test/controllers/incline/contact_controller_test.rb +32 -0
- data/test/controllers/incline/security_controller_test.rb +39 -0
- data/test/controllers/incline/welcome_controller_test.rb +16 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +12 -0
- data/test/dummy/app/assets/stylesheets/application.css +17 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +1 -0
- data/test/dummy/app/views/layouts/incline/_app_menu_anon.html.erb +1 -0
- data/test/dummy/app/views/layouts/incline/_app_menu_authenticated.html.erb +1 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +2 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +2 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config/application.rb +38 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +34 -0
- data/test/dummy/config/email.yml +24 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +45 -0
- data/test/dummy/config/environments/production.rb +85 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/to_time_preserves_timezone.rb +10 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/schema.rb +108 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/extensions/action_controller_base_extensions_test.rb +21 -0
- data/test/extensions/action_mailer_base_extensions_test.rb +20 -0
- data/test/extensions/action_view_base_extensions_test.rb +267 -0
- data/test/extensions/active_record_extensions_test.rb +173 -0
- data/test/extensions/application_configuration_extensions_test.rb +46 -0
- data/test/extensions/application_extensions_test.rb +23 -0
- data/test/extensions/connection_adapter_extensions_test.rb +54 -0
- data/test/extensions/date_time_value_extensions_test.rb +104 -0
- data/test/extensions/date_value_extensions_test.rb +102 -0
- data/test/extensions/decimal_value_extensions_test.rb +85 -0
- data/test/extensions/erb_scaffold_generator_extensions_test.rb +17 -0
- data/test/extensions/float_value_extensions_test.rb +78 -0
- data/test/extensions/form_builder_extensions_test.rb +28 -0
- data/test/extensions/integer_value_extensions_test.rb +78 -0
- data/test/extensions/jbuilder_generator_extensions_test.rb +21 -0
- data/test/extensions/jbuilder_template_extensions_test.rb +47 -0
- data/test/extensions/main_app_extensions_test.rb +55 -0
- data/test/extensions/numeric_extensions_test.rb +76 -0
- data/test/extensions/object_extensions_test.rb +104 -0
- data/test/extensions/session_extensions_test.rb +69 -0
- data/test/extensions/string_extensions_test.rb +32 -0
- data/test/extensions/test_case_extensions_test.rb +538 -0
- data/test/extensions/time_zone_converter_extensions_test.rb +10 -0
- data/test/fixtures/incline/access_group_group_members.yml +1 -0
- data/test/fixtures/incline/access_group_user_members.yml +1 -0
- data/test/fixtures/incline/access_groups.yml +13 -0
- data/test/fixtures/incline/action_groups.yml +6 -0
- data/test/fixtures/incline/action_securities.yml +18 -0
- data/test/fixtures/incline/user_login_histories.yml +1 -0
- data/test/fixtures/incline/users.yml +64 -0
- data/test/incline_test.rb +63 -0
- data/test/integration/incline/users_edit_test.rb +180 -0
- data/test/integration/incline/users_login_test.rb +105 -0
- data/test/integration/incline/users_signup_test.rb +147 -0
- data/test/integration/navigation_test.rb +11 -0
- data/test/lib/data_tables_request_test.rb +245 -0
- data/test/lib/date_time_formats_test.rb +111 -0
- data/test/lib/global_status_test.rb +89 -0
- data/test/lib/json_log_formatter_test.rb +43 -0
- data/test/lib/log_test.rb +36 -0
- data/test/lib/recaptcha_test.rb +75 -0
- data/test/lib/user_manager_test.rb +47 -0
- data/test/lib/work_path_test.rb +18 -0
- data/test/models/incline/access_group_group_member_test.rb +30 -0
- data/test/models/incline/access_group_test.rb +60 -0
- data/test/models/incline/access_group_user_member_test.rb +29 -0
- data/test/models/incline/action_group_test.rb +27 -0
- data/test/models/incline/action_security_test.rb +176 -0
- data/test/models/incline/contact_message_test.rb +66 -0
- data/test/models/incline/disable_info_test.rb +29 -0
- data/test/models/incline/password_reset_request_test.rb +35 -0
- data/test/models/incline/password_reset_test.rb +51 -0
- data/test/models/incline/user_login_history_test.rb +31 -0
- data/test/models/incline/user_test.rb +91 -0
- data/test/test_helper.rb +42 -0
- data/test/validators/email_validator_test.rb +102 -0
- data/test/validators/ip_address_validator_test.rb +107 -0
- data/test/validators/recaptcha_validator_test.rb +57 -0
- data/test/validators/safe_name_validator_test.rb +101 -0
- metadata +584 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class AccessGroupGroupMemberTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
@group1 = incline_access_groups(:one)
|
7
|
+
@group2 = incline_access_groups(:two)
|
8
|
+
@group3 = incline_access_groups(:three)
|
9
|
+
@item = Incline::AccessGroupGroupMember.new(group_id: @group1.id, member_id: @group2.id)
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'should be valid' do
|
13
|
+
assert @item.valid?
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'should require group_id' do
|
17
|
+
assert_required @item, :group_id
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'should require member_id' do
|
21
|
+
assert_required @item, :member_id
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'member_id should be unique within group_id scope' do
|
25
|
+
assert_uniqueness @item, :member_id, false, group_id: @group3.id
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class AccessGroupTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@group = Incline::AccessGroup.new(name: 'Group X')
|
8
|
+
@group1 = incline_access_groups(:one)
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'should be valid' do
|
12
|
+
assert @group.valid?
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'should require name' do
|
16
|
+
assert_required @group, :name
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'name should not be too long' do
|
20
|
+
assert_max_length @group, :name, 100
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'name should be unique' do
|
24
|
+
assert_uniqueness @group, :name
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'should allow members' do
|
28
|
+
# must save before adding.
|
29
|
+
@group.save!
|
30
|
+
@group.reload
|
31
|
+
|
32
|
+
@group.groups << @group1
|
33
|
+
|
34
|
+
assert @group.valid?
|
35
|
+
|
36
|
+
@group.save!
|
37
|
+
|
38
|
+
# group-x should have one member and group-1 should belong to one group.
|
39
|
+
assert_equal 1, @group.groups(true).count
|
40
|
+
assert_equal 1, @group1.memberships(true).count
|
41
|
+
|
42
|
+
# group-x has group-1 as a member and group-1 is a member of group-x.
|
43
|
+
assert @group.groups.include?(@group1)
|
44
|
+
assert @group1.memberships.include?(@group)
|
45
|
+
|
46
|
+
# group-1 equates to both group-1 and group-x for effective groups.
|
47
|
+
assert @group1.effective_groups.include?(@group1)
|
48
|
+
assert @group1.effective_groups.include?(@group)
|
49
|
+
|
50
|
+
# group-x equates to group-x but not group-1 for effective groups.
|
51
|
+
assert @group.effective_groups.include?(@group)
|
52
|
+
assert_not @group.effective_groups.include?(@group1)
|
53
|
+
|
54
|
+
# group-1 belongs to group-x but group-x does not belong to group-1.
|
55
|
+
assert @group1.belongs_to?(@group)
|
56
|
+
assert_not @group.belongs_to?(@group1)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class AccessGroupUserMemberTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
@group1 = incline_access_groups(:one)
|
7
|
+
@group2 = incline_access_groups(:two)
|
8
|
+
@user = incline_users(:one)
|
9
|
+
@item = Incline::AccessGroupUserMember.new(group_id: @group1.id, member_id: @user.id)
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'should be valid' do
|
13
|
+
assert @item.valid?
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'should require group_id' do
|
17
|
+
assert_required @item, :group_id
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'should require member_id' do
|
21
|
+
assert_required @item, :member_id
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'member_id should be unique within group_id scope' do
|
25
|
+
assert_uniqueness @item, :member_id, false, group_id: @group2.id
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class ActionGroupTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Incline::ActionGroup.new(action_security: incline_action_securities(:one), access_group: incline_access_groups(:one))
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'should be valid' do
|
11
|
+
assert @item.valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'should require action_security' do
|
15
|
+
assert_required @item, :action_security
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'should require access_group' do
|
19
|
+
assert_required @item, :access_group
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'access_group should be unique within action_security' do
|
23
|
+
assert_uniqueness @item, :access_group, action_security: incline_action_securities(:two)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class ActionSecurityTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
class EveryoneController < ActionController::Base
|
7
|
+
allow_anon true
|
8
|
+
end
|
9
|
+
|
10
|
+
class AnonOnlyController < ActionController::Base
|
11
|
+
require_anon true
|
12
|
+
end
|
13
|
+
|
14
|
+
class AdminOnlyController < ActionController::Base
|
15
|
+
require_admin true
|
16
|
+
end
|
17
|
+
|
18
|
+
class AnyUserController < ActionController::Base
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class MixedController < ActionController::Base
|
23
|
+
allow_anon :index
|
24
|
+
require_anon :new, :create
|
25
|
+
require_admin :edit, :update, :destroy
|
26
|
+
# And the final CRUD action (:show) is currently allowed by any logged in user.
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup
|
30
|
+
@item = Incline::ActionSecurity.new(path: '/things', controller_name: 'things', action_name: 'index')
|
31
|
+
end
|
32
|
+
|
33
|
+
test 'should be valid' do
|
34
|
+
assert @item.valid?
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'should require path' do
|
38
|
+
assert_required @item, :path
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'should require controller_name' do
|
42
|
+
assert_required @item, :controller_name
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'should require action_name' do
|
46
|
+
assert_required @item, :action_name
|
47
|
+
end
|
48
|
+
|
49
|
+
test 'should limit length of controller_name' do
|
50
|
+
assert_max_length @item, :controller_name, 200
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'should limit length of action_name' do
|
54
|
+
assert_max_length @item, :action_name, 200
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'action_name should be unique within controller_name' do
|
58
|
+
assert_uniqueness @item, :action_name, controller_name: 'other_things'
|
59
|
+
end
|
60
|
+
|
61
|
+
test 'names are stored in lowercase' do
|
62
|
+
@item.controller_name = 'THINGS'
|
63
|
+
assert_equal 'THINGS', @item.controller_name
|
64
|
+
@item.save!
|
65
|
+
assert_equal 'things', @item.controller_name
|
66
|
+
@item.action_name = 'SHOW'
|
67
|
+
assert_equal 'SHOW', @item.action_name
|
68
|
+
@item.save!
|
69
|
+
assert_equal 'show', @item.action_name
|
70
|
+
end
|
71
|
+
|
72
|
+
test 'allow_custom? works correctly' do
|
73
|
+
assert @item.allow_custom?
|
74
|
+
@item.require_admin = true
|
75
|
+
assert_not @item.allow_custom?
|
76
|
+
@item.require_admin = false
|
77
|
+
@item.require_anon = true
|
78
|
+
assert_not @item.allow_custom?
|
79
|
+
@item.require_anon = false
|
80
|
+
@item.allow_anon = true
|
81
|
+
assert_not @item.allow_custom?
|
82
|
+
@item.allow_anon = false
|
83
|
+
assert @item.allow_custom?
|
84
|
+
end
|
85
|
+
|
86
|
+
test 'short_permitted works correctly' do
|
87
|
+
|
88
|
+
{
|
89
|
+
nil => 'Users',
|
90
|
+
require_admin: 'Admins',
|
91
|
+
require_anon: 'Anon',
|
92
|
+
allow_anon: 'Everyone'
|
93
|
+
}.each do |attr,ret|
|
94
|
+
@item.send("#{attr}=", true) if attr
|
95
|
+
assert_equal ret, @item.short_permitted
|
96
|
+
@item.non_standard = true
|
97
|
+
assert_equal ret + '*', @item.short_permitted
|
98
|
+
@item.non_standard = false
|
99
|
+
@item.send("#{attr}=", false) if attr
|
100
|
+
end
|
101
|
+
assert_equal 'Users', @item.short_permitted
|
102
|
+
|
103
|
+
@item.groups << incline_access_groups(:one)
|
104
|
+
assert_equal 'Custom', @item.short_permitted
|
105
|
+
end
|
106
|
+
|
107
|
+
test 'anon_only test' do
|
108
|
+
%w(index new create show edit update destroy).each do |action|
|
109
|
+
@item = Incline::ActionSecurity.new(path: '/', controller_name: 'incline/action_security_test/anon_only', action_name: action)
|
110
|
+
@item.update_flags
|
111
|
+
assert_not @item.unknown_controller?
|
112
|
+
assert @item.require_anon?
|
113
|
+
assert_not @item.allow_anon?
|
114
|
+
assert_not @item.require_admin?
|
115
|
+
assert_not @item.allow_custom?
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
test 'everyone test' do
|
120
|
+
%w(index new create show edit update destroy).each do |action|
|
121
|
+
@item = Incline::ActionSecurity.new(path: '/', controller_name: 'incline/action_security_test/everyone', action_name: action)
|
122
|
+
@item.update_flags
|
123
|
+
assert_not @item.unknown_controller?
|
124
|
+
assert_not @item.require_anon?
|
125
|
+
assert @item.allow_anon?
|
126
|
+
assert_not @item.require_admin?
|
127
|
+
assert_not @item.allow_custom?
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
test 'admin_only test' do
|
132
|
+
%w(index new create show edit update destroy).each do |action|
|
133
|
+
@item = Incline::ActionSecurity.new(path: '/', controller_name: 'incline/action_security_test/admin_only', action_name: action)
|
134
|
+
@item.update_flags
|
135
|
+
assert_not @item.unknown_controller?
|
136
|
+
assert_not @item.require_anon?
|
137
|
+
assert_not @item.allow_anon?
|
138
|
+
assert @item.require_admin?
|
139
|
+
assert_not @item.allow_custom?
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
test 'any_user test' do
|
144
|
+
%w(index new create show edit update destroy).each do |action|
|
145
|
+
@item = Incline::ActionSecurity.new(path: '/', controller_name: 'incline/action_security_test/any_user', action_name: action)
|
146
|
+
@item.update_flags
|
147
|
+
assert_not @item.unknown_controller?
|
148
|
+
assert_not @item.require_anon?
|
149
|
+
assert_not @item.allow_anon?
|
150
|
+
assert_not @item.require_admin?
|
151
|
+
assert @item.allow_custom?
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
test 'mixed test' do
|
156
|
+
{ # anon allow admin user
|
157
|
+
index: [ false, true, false, false ],
|
158
|
+
new: [ true, false, false, false ],
|
159
|
+
create: [ true, false, false, false ],
|
160
|
+
show: [ false, false, false, true ],
|
161
|
+
edit: [ false, false, true, false ],
|
162
|
+
update: [ false, false, true, false ],
|
163
|
+
destroy: [ false, false, true, false ]
|
164
|
+
}.each do |action,(anon,allow,admin,user)|
|
165
|
+
@item = Incline::ActionSecurity.new(path: '/', controller_name: 'incline/action_security_test/mixed', action_name: action)
|
166
|
+
@item.update_flags
|
167
|
+
assert_not @item.unknown_controller?
|
168
|
+
assert_equal anon, @item.require_anon?
|
169
|
+
assert_equal allow, @item.allow_anon?
|
170
|
+
assert_equal admin, @item.require_admin?
|
171
|
+
assert_equal user, @item.allow_custom?
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class ContactMessageTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Incline::ContactMessage.new(
|
8
|
+
your_name: 'Jane Doe',
|
9
|
+
your_email: 'janed@example.com',
|
10
|
+
related_to: 'Other',
|
11
|
+
subject: 'Just a test',
|
12
|
+
body: 'This is just a test message.',
|
13
|
+
recaptcha: Incline::Recaptcha::DISABLED
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'should be valid' do
|
18
|
+
assert @item.valid?
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'should require your_name' do
|
22
|
+
assert_required @item, :your_name
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'should require your_email' do
|
26
|
+
assert_required @item, :your_email
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'should require related_to' do
|
30
|
+
assert_required @item, :related_to
|
31
|
+
end
|
32
|
+
|
33
|
+
test 'should require subject when related_to is other' do
|
34
|
+
@item.related_to = 'other'
|
35
|
+
assert_required @item, :subject
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'should not require subject when related_to is anything else' do
|
39
|
+
@item.related_to = 'something'
|
40
|
+
assert @item.valid?
|
41
|
+
@item.subject = nil
|
42
|
+
assert @item.valid?
|
43
|
+
@item.subject = ''
|
44
|
+
assert @item.valid?
|
45
|
+
@item.subject = ' '
|
46
|
+
assert @item.valid?
|
47
|
+
end
|
48
|
+
|
49
|
+
test 'should require body' do
|
50
|
+
assert_required @item, :body
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'should require recaptcha' do
|
54
|
+
assert_required @item, :recaptcha
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'should validate recaptcha' do
|
58
|
+
assert_recaptcha_validation @item, :recaptcha
|
59
|
+
end
|
60
|
+
|
61
|
+
test 'should validate email' do
|
62
|
+
assert_email_validation @item, :your_email
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class DisableInfoTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Incline::DisableInfo.new(user: incline_users(:one), reason: 'For testing')
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'should be valid' do
|
11
|
+
assert @item.valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'should require user' do
|
15
|
+
assert_required @item, :user, nil, /must be provided/
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'should require reason' do
|
19
|
+
assert_required @item, :reason
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'user must be enabled' do
|
23
|
+
@item.user = incline_users(:disabled)
|
24
|
+
assert_not @item.valid?
|
25
|
+
assert @item.errors[:user].to_s =~ /must be enabled/
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class PasswordResetRequestTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Incline::PasswordResetRequest.new(
|
8
|
+
email: 'user@example.com',
|
9
|
+
recaptcha: Incline::Recaptcha::DISABLED
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'should be valid' do
|
14
|
+
assert @item.valid?
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'should require email' do
|
18
|
+
assert_required @item, :email
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'should require recaptcha' do
|
22
|
+
assert_required @item, :recaptcha
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'email should be validated' do
|
26
|
+
assert_email_validation @item, :email
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'recaptcha should be validated' do
|
30
|
+
assert_recaptcha_validation @item, :recaptcha
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class PasswordResetTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@item = Incline::PasswordReset.new(
|
8
|
+
password: 'password',
|
9
|
+
password_confirmation: 'password',
|
10
|
+
recaptcha: Incline::Recaptcha::DISABLED
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'should be valid' do
|
15
|
+
assert @item.valid?
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'should require password' do
|
19
|
+
assert_required @item, :password
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'should require minimum password length' do
|
23
|
+
@item.password = @item.password_confirmation = 'a' * 8
|
24
|
+
assert @item.valid?
|
25
|
+
|
26
|
+
@item.password = @item.password_confirmation = 'a' * 7
|
27
|
+
assert_not @item.valid?
|
28
|
+
assert @item.errors[:password].to_s =~ /is too short/
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'should require password_confirmation' do
|
32
|
+
assert_required @item, :password_confirmation
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'password_confirmation should match password' do
|
36
|
+
@item.password_confirmation = 'a' * 8
|
37
|
+
assert_not @item.valid?
|
38
|
+
assert @item.errors[:password_confirmation].to_s =~ /doesn't match/
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'should require recaptcha' do
|
42
|
+
assert_required @item, :recaptcha
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'should validate recaptcha' do
|
46
|
+
assert_recaptcha_validation @item, :recaptcha
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class UserLoginHistoryTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
@user = incline_users(:one)
|
7
|
+
@item = Incline::UserLoginHistory.new(user: @user, ip_address: '1.2.3.4')
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'should be valid' do
|
11
|
+
assert @item.valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
test 'should require user' do
|
15
|
+
assert_required @item, :user
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'should require ip_address' do
|
19
|
+
assert_required @item, :ip_address
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'should validate ip_address' do
|
23
|
+
assert_ip_validation @item, :ip_address, :deny_mask
|
24
|
+
end
|
25
|
+
|
26
|
+
test 'message should not be too long' do
|
27
|
+
assert_max_length @item, :message, 200
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Incline
|
4
|
+
class UserTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
@item = Incline::User.new(
|
7
|
+
name: 'John Wayne',
|
8
|
+
email: 'j.wayne@example.com',
|
9
|
+
password: 'password',
|
10
|
+
password_confirmation: 'password',
|
11
|
+
recaptcha: Incline::Recaptcha::DISABLED
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'should be valid' do
|
16
|
+
assert @item.valid?
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'should require name' do
|
20
|
+
assert_required @item, :name
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'should require email' do
|
24
|
+
assert_required @item, :email
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'should require recaptcha' do
|
28
|
+
assert_required @item, :recaptcha
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'should validate recaptcha' do
|
32
|
+
assert_recaptcha_validation @item, :recaptcha
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'recaptcha not required for updates' do
|
36
|
+
@item.save!
|
37
|
+
@item.recaptcha = nil
|
38
|
+
assert @item.valid?
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'name should not be too long' do
|
42
|
+
assert_max_length @item, :name, 100
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'email should not be too long' do
|
46
|
+
assert_max_length @item, :email, 250, end_with: '@example.com'
|
47
|
+
end
|
48
|
+
|
49
|
+
test 'email should be unique' do
|
50
|
+
assert_uniqueness @item, :email
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'email should be validated' do
|
54
|
+
assert_email_validation @item, :email
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'email should be saved lowercase' do
|
58
|
+
mixed_case_email = 'JohnDoe@Example.COM'
|
59
|
+
@item.email = mixed_case_email
|
60
|
+
assert @item.valid?
|
61
|
+
assert_equal mixed_case_email, @item.email
|
62
|
+
@item.save!
|
63
|
+
assert_equal mixed_case_email.downcase, @item.email
|
64
|
+
end
|
65
|
+
|
66
|
+
test 'password should have min length' do
|
67
|
+
pwd = 'a' * 8
|
68
|
+
@item.password = @item.password_confirmation = pwd
|
69
|
+
assert @item.valid?
|
70
|
+
pwd = 'a' * 7
|
71
|
+
@item.password = @item.password_confirmation = pwd
|
72
|
+
assert_not @item.valid?
|
73
|
+
end
|
74
|
+
|
75
|
+
test 'password should not be blank' do
|
76
|
+
@item.password = @item.password_confirmation = ' ' * 8
|
77
|
+
assert_not @item.valid?
|
78
|
+
end
|
79
|
+
|
80
|
+
test 'password_confirmation must match' do
|
81
|
+
@item.password_confirmation = 'a' * 8
|
82
|
+
assert_not @item.valid?
|
83
|
+
end
|
84
|
+
|
85
|
+
test 'authenticated should return false for nil digest' do
|
86
|
+
assert_not @item.authenticated?(:remember, '')
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
5
|
+
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
6
|
+
ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
|
7
|
+
require "rails/test_help"
|
8
|
+
|
9
|
+
require 'byebug'
|
10
|
+
|
11
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
12
|
+
# to be shown.
|
13
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
14
|
+
|
15
|
+
# Load support files
|
16
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
17
|
+
|
18
|
+
# Load fixtures from the engine
|
19
|
+
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
20
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
21
|
+
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
22
|
+
ActiveSupport::TestCase.fixtures :all
|
23
|
+
end
|
24
|
+
|
25
|
+
class MsSqlTestConn < ActiveRecord::Base
|
26
|
+
self.abstract_class = true
|
27
|
+
|
28
|
+
cfg = ActiveRecord::Base.configurations['mssql_test']
|
29
|
+
if cfg
|
30
|
+
begin
|
31
|
+
establish_connection cfg
|
32
|
+
rescue TinyTds::Error
|
33
|
+
remove_connection
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.skip_tests?
|
38
|
+
self.connection.class.name != 'ActiveRecord::ConnectionAdapters::SQLServerAdapter'
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|