jinda 0.7.7.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +46 -29
- data/Rakefile +103 -1
- data/app/assets/config/manifest.js +4 -1
- data/app/assets/javascripts/jinda_bootstrap.js +20 -0
- data/app/assets/stylesheets/_jinda_bootstrap_theme.scss +190 -0
- data/{lib/generators/jinda/templates/app/assets/stylesheets/jinda_jqm.css.scss → app/assets/stylesheets/jinda_bootstrap.css.scss} +12 -10
- data/app/config/routes.rb +38 -28
- data/app/controllers/concerns/jinda_general_concern.rb +86 -87
- data/app/controllers/concerns/jinda_run_concern.rb +184 -184
- data/app/controllers/jinda_controller.rb +23 -22
- data/bin/lint_modified +21 -0
- data/config/routes.rb +41 -22
- data/lib/generators/jinda/config_generator.rb +102 -81
- data/lib/generators/jinda/install_generator.rb +305 -148
- data/lib/generators/jinda/install_generator.rb.bak2 +268 -0
- data/lib/generators/jinda/installer/gems_install.rb +125 -127
- data/lib/generators/jinda/minitest_generator.rb +19 -18
- data/lib/generators/jinda/rspec_generator.rb +15 -14
- data/lib/generators/jinda/templates/DOCKER.md +188 -0
- data/lib/generators/jinda/templates/Dockerfile +15 -5
- data/lib/generators/jinda/templates/README.md +3 -3
- data/lib/generators/jinda/templates/app/assets/config/manifest.js +4 -0
- data/lib/generators/jinda/templates/app/assets/javascripts/application.js +8 -8
- data/lib/generators/jinda/templates/app/channels/application_cable/channel.rb +2 -0
- data/lib/generators/jinda/templates/app/channels/application_cable/connection.rb +2 -0
- data/{test/dummy → lib/generators/jinda/templates}/app/controllers/adminltes_controller.rb +1 -0
- data/lib/generators/jinda/templates/app/controllers/api/v1/notes_controller.rb +80 -78
- data/lib/generators/jinda/templates/app/controllers/jinda_org/admins_controller.rb +4 -2
- data/lib/generators/jinda/templates/app/controllers/jinda_org/application_controller.rb +11 -9
- data/lib/generators/jinda/templates/app/controllers/jinda_org/articles_controller.rb +40 -44
- data/lib/generators/jinda/templates/app/controllers/jinda_org/comments_controller.rb +10 -8
- data/lib/generators/jinda/templates/app/controllers/jinda_org/docs_controller.rb +23 -24
- data/lib/generators/jinda/templates/app/controllers/jinda_org/identities_controller.rb +3 -1
- data/lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb +25 -27
- data/lib/generators/jinda/templates/app/controllers/jinda_org/password_resets_controller.rb +16 -18
- data/lib/generators/jinda/templates/app/controllers/jinda_org/sessions_controller.rb +13 -14
- data/lib/generators/jinda/templates/app/controllers/jinda_org/sitemap_controller.rb +4 -4
- data/lib/generators/jinda/templates/app/controllers/jinda_org/users_controller.rb +14 -14
- data/lib/generators/jinda/templates/app/controllers/mindmap_editor_controller.rb +74 -0
- data/lib/generators/jinda/templates/app/helpers/admins_helper.rb +2 -0
- data/lib/generators/jinda/templates/app/helpers/application_helper.rb +21 -20
- data/lib/generators/jinda/templates/app/helpers/articles_helper.rb +2 -0
- data/lib/generators/jinda/templates/app/helpers/basic_helper.rb +2 -0
- data/lib/generators/jinda/templates/app/helpers/comments_helper.rb +2 -0
- data/lib/generators/jinda/templates/app/helpers/ctrs_helper.rb +2 -0
- data/lib/generators/jinda/templates/app/helpers/devs_helper.rb +2 -0
- data/lib/generators/jinda/templates/app/helpers/mindmap_editor_helper.rb +3 -0
- data/lib/generators/jinda/templates/app/helpers/pictures_helper.rb +2 -0
- data/lib/generators/jinda/templates/app/helpers/sitemap_helper.rb +2 -0
- data/lib/generators/jinda/templates/app/helpers/users_helper.rb +2 -0
- data/lib/generators/jinda/templates/app/jinda/index.mm +276 -298
- data/lib/generators/jinda/templates/app/jinda/template/index.mm +1 -0
- data/lib/generators/jinda/templates/app/mailers/jinda_mailer.rb +5 -3
- data/lib/generators/jinda/templates/app/mailers/note_mailer.rb +6 -4
- data/lib/generators/jinda/templates/app/mailers/user_mailer.rb +5 -5
- data/lib/generators/jinda/templates/app/models/address.rb +10 -8
- data/lib/generators/jinda/templates/app/models/article.rb +8 -6
- data/lib/generators/jinda/templates/app/models/comment.rb +10 -8
- data/lib/generators/jinda/templates/app/models/identity.rb +11 -10
- data/lib/generators/jinda/templates/app/models/jinda/doc.rb +36 -33
- data/lib/generators/jinda/templates/app/models/jinda/jinda_module.rb +15 -0
- data/lib/generators/jinda/templates/app/models/jinda/module.rb +14 -10
- data/lib/generators/jinda/templates/app/models/jinda/notice.rb +15 -11
- data/lib/generators/jinda/templates/app/models/jinda/role.rb +11 -7
- data/lib/generators/jinda/templates/app/models/jinda/runseq.rb +23 -20
- data/lib/generators/jinda/templates/app/models/jinda/service.rb +19 -15
- data/lib/generators/jinda/templates/app/models/jinda/xmain.rb +42 -36
- data/lib/generators/jinda/templates/app/models/note.rb +14 -10
- data/lib/generators/jinda/templates/app/models/param.rb +23 -20
- data/lib/generators/jinda/templates/app/models/person.rb +9 -7
- data/lib/generators/jinda/templates/app/models/user.rb +42 -41
- data/lib/generators/jinda/templates/app/views/articles/show.html.haml +2 -2
- data/lib/generators/jinda/templates/app/views/identities/new.html.haml +13 -0
- data/lib/generators/jinda/templates/app/views/jinda/_static_bootstrap.haml +23 -0
- data/lib/generators/jinda/templates/app/views/jinda/feed.rss.builder +15 -13
- data/lib/generators/jinda/templates/app/views/jinda/index.html.haml +3 -2
- data/lib/generators/jinda/templates/app/views/layouts/application.haml +31 -4
- data/lib/generators/jinda/templates/app/views/layouts/lte/_header.haml +54 -0
- data/{test/dummy → lib/generators/jinda/templates}/app/views/layouts/lte/_sidebar.haml +1 -1
- data/lib/generators/jinda/templates/app/views/mindmap_editor/edit.html.haml +126 -0
- data/lib/generators/jinda/templates/app/views/mindmap_editor/save.html.haml +2 -0
- data/lib/generators/jinda/templates/app/views/sessions/new.html.haml +13 -0
- data/lib/generators/jinda/templates/bin/lint_modified +21 -0
- data/lib/generators/jinda/templates/config/mongoid.yml +3 -3
- data/lib/generators/jinda/templates/config/mongoid.yml-docker +3 -3
- data/lib/generators/jinda/templates/config/mongoid.yml-localhost +3 -3
- data/lib/generators/jinda/templates/docker-compose-mongodb.yml +13 -0
- data/lib/generators/jinda/templates/docker-compose-web.yml +36 -0
- data/lib/generators/jinda/templates/docker-compose.yml +10 -14
- data/lib/generators/jinda/templates/spec/controllers/api/v1_get_index_spec.rb +15 -14
- data/lib/generators/jinda/templates/spec/controllers/api/v1_get_my_spec.rb +9 -4
- data/lib/generators/jinda/templates/spec/controllers/api/v1_post_spec.rb +4 -3
- data/lib/generators/jinda/templates/spec/controllers/sessions_controller_spec.rb +82 -90
- data/lib/generators/jinda/templates/spec/features/userlogins_spec.rb +12 -15
- data/lib/generators/jinda/templates/spec/mailers/note_spec.rb +5 -8
- data/lib/generators/jinda/templates/spec/mailers/previews/note_preview.rb +3 -5
- data/lib/generators/jinda/templates/spec/models/note_spec.rb +36 -35
- data/lib/generators/jinda/templates/spec/models/user_spec.rb +10 -8
- data/lib/generators/jinda/templates/spec/rails_helper.rb +29 -31
- data/lib/generators/jinda/templates/spec/spec_helper.rb +19 -17
- data/lib/generators/jinda/templates/spec/support/authentication_helper.rb +8 -7
- data/lib/generators/jinda/templates/spec/support/databasecleaner.rb +3 -1
- data/lib/generators/jinda/templates/spec/support/factory_bot.rb +7 -5
- data/lib/generators/jinda/templates/spec/support/omniauth_macros.rb +14 -19
- data/lib/generators/jinda/templates/spec/support/request_spec_helper.rb +3 -1
- data/lib/generators/jinda/templates/spec/views/articles/_article.html.erb_spec.rbx +9 -8
- data/lib/generators/jinda/templates/test/application_system_test_case.rb +3 -1
- data/lib/generators/jinda/templates/test/integration/jinda_routes_test.rb +16 -21
- data/lib/generators/jinda/templates/test/test_helper.rb +7 -3
- data/lib/jinda/date_helpers.rb +50 -41
- data/lib/jinda/gem_helpers.rb +10 -8
- data/lib/jinda/gen_class.rb +14 -12
- data/lib/jinda/gen_controller.rb +9 -8
- data/lib/jinda/gen_freemind.rb +33 -32
- data/lib/jinda/gen_helpers.rb +146 -139
- data/lib/jinda/gen_models.rb +125 -131
- data/lib/jinda/gen_modules.rb +21 -16
- data/lib/jinda/gen_runseq.rb +71 -67
- data/lib/jinda/gen_services.rb +74 -80
- data/lib/jinda/gen_xmain.rb +38 -36
- data/lib/jinda/get_app.rb +31 -29
- data/lib/jinda/helpers.rb +4 -4
- data/lib/jinda/init_vars.rb +41 -36
- data/lib/jinda/mindmap_converter.rb +196 -0
- data/lib/jinda/railtie.rb +10 -2
- data/lib/jinda/rake_views.rb +61 -60
- data/lib/jinda/refresh.rb +67 -61
- data/lib/jinda/themes.rb +80 -60
- data/lib/jinda/version.rb +3 -1
- data/lib/jinda.rb +2 -0
- data/lib/tasks/jinda.rake +25 -22
- data/test/INTEGRATION_TEST_README.md +374 -0
- data/test/LOCAL_DEVELOPMENT.md +345 -0
- data/test/README.md +243 -0
- data/test/TEST_INFRASTRUCTURE.md +412 -0
- data/test/TEST_INSTALLATION_SH_FIXES.md +205 -0
- data/test/UNIT_TESTS_README.md +366 -0
- data/test/api_notes_controller_test.rb +231 -0
- data/test/dummy/DOCKER.md +188 -0
- data/test/dummy/Dockerfile +15 -7
- data/test/dummy/Gemfile +38 -29
- data/test/dummy/Gemfile.lock +671 -292
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/channels/application_cable/channel.rb +2 -0
- data/test/dummy/app/channels/application_cable/connection.rb +2 -0
- data/test/dummy/app/controllers/admins_controller.rb +4 -2
- data/test/dummy/app/controllers/api/v1/notes_controller.rb +80 -78
- data/test/dummy/app/controllers/application_controller.rb +11 -9
- data/test/dummy/app/controllers/articles_controller.rb +40 -44
- data/test/dummy/app/controllers/comments_controller.rb +10 -8
- data/test/dummy/app/controllers/ctrs_controller.rb +2 -0
- data/test/dummy/app/controllers/devs_controller.rb +2 -0
- data/test/dummy/app/controllers/docs_controller.rb +23 -24
- data/test/dummy/app/controllers/identities_controller.rb +3 -1
- data/test/dummy/app/controllers/mindmap_editor_controller.rb +74 -0
- data/test/dummy/app/controllers/notes_controller.rb +25 -27
- data/test/dummy/app/controllers/password_resets_controller.rb +16 -18
- data/test/dummy/app/controllers/sessions_controller.rb +13 -14
- data/test/dummy/app/controllers/sitemap_controller.rb +4 -4
- data/test/dummy/app/controllers/users_controller.rb +14 -14
- data/test/dummy/app/helpers/admins_helper.rb +2 -0
- data/test/dummy/app/helpers/application_helper.rb +21 -20
- data/test/dummy/app/helpers/articles_helper.rb +2 -0
- data/test/dummy/app/helpers/basic_helper.rb +2 -0
- data/test/dummy/app/helpers/comments_helper.rb +2 -0
- data/test/dummy/app/helpers/ctrs_helper.rb +2 -0
- data/test/dummy/app/helpers/devs_helper.rb +2 -0
- data/test/dummy/app/helpers/mindmap_editor_helper.rb +3 -0
- data/test/dummy/app/helpers/pictures_helper.rb +2 -0
- data/test/dummy/app/helpers/sitemap_helper.rb +2 -0
- data/test/dummy/app/helpers/users_helper.rb +2 -0
- data/test/dummy/app/jinda/index.mm +384 -486
- data/test/dummy/app/jinda/template/index.mm +1 -0
- data/test/dummy/app/mailers/application_mailer.rb +2 -2
- data/test/dummy/app/mailers/application_mailer.rb-org +4 -0
- data/test/dummy/app/mailers/jinda_mailer.rb +5 -3
- data/test/dummy/app/mailers/note_mailer.rb +6 -4
- data/test/dummy/app/mailers/user_mailer.rb +5 -5
- data/test/dummy/app/models/address.rb +2 -0
- data/test/dummy/app/models/article.rb +2 -0
- data/test/dummy/app/models/comment.rb +3 -2
- data/test/dummy/app/models/identity.rb +11 -10
- data/test/dummy/app/models/jinda/doc.rb +36 -33
- data/test/dummy/app/models/jinda/jinda_module.rb +15 -0
- data/test/dummy/app/models/jinda/module.rb +14 -10
- data/test/dummy/app/models/jinda/notice.rb +15 -11
- data/test/dummy/app/models/jinda/role.rb +11 -7
- data/test/dummy/app/models/jinda/runseq.rb +23 -20
- data/test/dummy/app/models/jinda/service.rb +19 -15
- data/test/dummy/app/models/jinda/xmain.rb +42 -36
- data/test/dummy/app/models/note.rb +3 -8
- data/test/dummy/app/models/param.rb +23 -20
- data/test/dummy/app/models/person.rb +2 -0
- data/test/dummy/app/models/picture.rb +11 -0
- data/test/dummy/app/models/user.rb +42 -41
- data/test/dummy/app/views/admins/index.haml +21 -0
- data/test/dummy/app/views/api/v1/notes/delete/select_note.html.erb +21 -0
- data/test/dummy/app/views/api/v1/notes/edit/edit_note.html.erb +21 -0
- data/test/dummy/app/views/api/v1/notes/index.haml +21 -0
- data/test/dummy/app/views/api/v1/notes/new/new_note.html.erb +21 -0
- data/test/dummy/app/views/articles/show.html.haml +2 -2
- data/test/dummy/app/views/devs/index.haml +21 -0
- data/test/dummy/app/views/jinda/feed.rss.builder +15 -13
- data/test/dummy/app/views/jinda/index.html.haml +3 -2
- data/test/dummy/app/views/layouts/application.haml +2 -2
- data/test/dummy/app/views/mindmap_editor/edit.html.haml +126 -0
- data/test/dummy/app/views/mindmap_editor/save.html.haml +2 -0
- data/test/dummy/bin/docker-entrypoint +3 -0
- data/test/dummy/bin/lint_modified +21 -0
- data/test/dummy/bin/setup +1 -1
- data/test/dummy/config/application.rb +7 -2
- data/test/dummy/config/boot.rb +2 -1
- data/test/dummy/config/cable.yml +1 -1
- data/test/dummy/config/credentials.yml.enc +1 -1
- data/test/dummy/config/environments/development.rb +7 -1
- data/test/dummy/config/environments/production.rb +30 -26
- data/test/dummy/config/environments/test.rb +12 -8
- data/test/dummy/config/initializers/content_security_policy.rb +2 -2
- data/test/dummy/config/initializers/filter_parameter_logging.rb +3 -3
- data/test/dummy/config/initializers/mindmap_converter.rb +5 -0
- data/test/dummy/config/initializers/mongoid.rb +24 -9
- data/test/dummy/config/initializers/omniauth.rb +5 -0
- data/test/dummy/config/initializers/permissions_policy.rb +11 -9
- data/test/dummy/config/locales/en.yml +11 -13
- data/test/dummy/config/mongoid.yml +172 -53
- data/test/dummy/config/mongoid.yml-docker +3 -3
- data/test/dummy/config/mongoid.yml-localhost +3 -3
- data/test/dummy/config/puma.rb +21 -20
- data/test/dummy/config/routes.rb +7 -1
- data/test/dummy/docker-compose-mongodb.yml +13 -0
- data/test/dummy/docker-compose-web.yml +36 -0
- data/test/dummy/docker-compose.yml +10 -18
- data/test/dummy/log/development.log +5834 -2261
- data/test/dummy/spec/controllers/api/v1_get_index_spec.rb +15 -14
- data/test/dummy/spec/controllers/api/v1_get_my_spec.rb +9 -4
- data/test/dummy/spec/controllers/api/v1_post_spec.rb +4 -3
- data/test/dummy/spec/controllers/sessions_controller_spec.rb +82 -90
- data/test/dummy/spec/factories/pictures.rb +5 -0
- data/test/dummy/spec/features/userlogins_spec.rb +12 -15
- data/test/dummy/spec/mailers/note_spec.rb +5 -8
- data/test/dummy/spec/mailers/previews/note_preview.rb +3 -5
- data/test/dummy/spec/models/note_spec.rb +36 -35
- data/test/dummy/spec/models/picture_spec.rb +5 -0
- data/test/dummy/spec/models/user_spec.rb +10 -8
- data/test/dummy/spec/rails_helper.rb +29 -31
- data/test/dummy/spec/requests/ctrs_spec.rb +7 -0
- data/test/dummy/spec/requests/devs_spec.rb +7 -0
- data/test/dummy/spec/spec_helper.rb +19 -17
- data/test/dummy/spec/support/authentication_helper.rb +8 -7
- data/test/dummy/spec/support/databasecleaner.rb +3 -1
- data/test/dummy/spec/support/factory_bot.rb +7 -5
- data/test/dummy/spec/support/omniauth_macros.rb +14 -19
- data/test/dummy/spec/support/request_spec_helper.rb +3 -1
- data/test/dummy/spec/views/articles/_article.html.erb_spec.rbx +9 -8
- data/test/generated_app_test.rb +261 -0
- data/test/installation_test.rb +368 -0
- data/test/integration_test.rb +398 -0
- data/test/jenkins_stage_test.rb +182 -0
- data/test/note_model_test.rb +224 -0
- data/test/note_validation_integration_test.rb +292 -0
- data/test/run_unit_tests.sh +91 -0
- data/test/test_helper.rb +8 -16
- metadata +188 -60
- data/lib/generators/jinda/templates/app/assets/stylesheets/application.css.scss +0 -15
- data/lib/generators/jinda/templates/app/controllers/jinda_org/password_resets.rb +0 -28
- data/lib/generators/jinda/templates/app/views/layouts/_head.html.erb +0 -10
- data/lib/generators/jinda/templates/app/views/layouts/_meta_tag.html.erb +0 -19
- data/lib/generators/jinda/templates/app/views/layouts/bsb/_footer.haml +0 -7
- data/lib/generators/jinda/templates/app/views/layouts/bsb/_header.haml +0 -147
- data/lib/generators/jinda/templates/app/views/layouts/bsb/_menu.haml +0 -47
- data/lib/generators/jinda/templates/app/views/layouts/bsb/_menu_mm.haml +0 -34
- data/lib/generators/jinda/templates/app/views/layouts/bsb/_sidebar.haml +0 -155
- data/lib/generators/jinda/templates/app/views/layouts/bsb/application.haml-bsb +0 -47
- data/lib/generators/jinda/templates/app/views/layouts/gmail.html.erb +0 -9
- data/lib/generators/jinda/templates/app/views/layouts/jqm/_full.haml +0 -33
- data/lib/generators/jinda/templates/app/views/layouts/jqm/_page.haml +0 -16
- data/lib/generators/jinda/templates/app/views/layouts/jqm/application.haml-jqm +0 -4
- data/lib/generators/jinda/templates/app/views/layouts/mailer.html.erb +0 -13
- data/lib/generators/jinda/templates/app/views/layouts/mailer.html.haml +0 -3
- data/lib/generators/jinda/templates/app/views/layouts/mailer.text.erb +0 -1
- data/lib/generators/jinda/templates/app/views/layouts/mailer.text.haml +0 -1
- data/lib/generators/jinda/templates/app/views/layouts/mobile.html.erb +0 -13
- data/lib/generators/jinda/templates/app/views/layouts/mobilejq.html.erb +0 -31
- data/lib/generators/jinda/templates/app/views/layouts/print.html.erb +0 -22
- data/lib/generators/jinda/templates/app/views/layouts/utf8.html.erb +0 -22
- data/lib/generators/jinda/templates/config/initializers/fix_mongoid_generator.rb-org +0 -14
- data/test/dummy/Guardfile +0 -96
- data/test/dummy/app/controllers/application_controller.rb.bak +0 -2
- data/test/dummy/app/controllers/password_resets.rb +0 -28
- data/test/dummy/app/helpers/application_helper.rb.bak +0 -2
- data/test/dummy/app/views/identities/new-bak.html.haml +0 -32
- data/test/dummy/app/views/layouts/application.haml.bak +0 -4
- data/test/dummy/app/views/layouts/application.html.erb.bak +0 -15
- data/test/dummy/app/views/layouts/lte/_header.haml +0 -111
- data/test/dummy/app/views/layouts/lte/_rightbar.haml +0 -123
- data/test/dummy/app/views/sessions/new-bak.html.haml +0 -22
- data/test/dummy/config/initializers/fix_mongoid_generator.rb-org +0 -14
- data/test/dummy/tmp/development_secret.txt +0 -1
- data/test/integration/navigation_test.rb +0 -7
- data/test/jinda_test.rb +0 -7
- /data/{test/dummy → lib/generators/jinda/templates}/app/assets/stylesheets/application.scss +0 -0
- /data/{test/dummy → lib/generators/jinda/templates}/app/assets/stylesheets/jinda.scss +0 -0
- /data/lib/generators/jinda/templates/app/mailers/{application_mailer.rb → application_mailer.rb-org} +0 -0
- /data/{test/dummy → lib/generators/jinda/templates}/app/views/adminltes/dashboard1.haml +0 -0
- /data/{test/dummy → lib/generators/jinda/templates}/app/views/adminltes/dashboard2.haml +0 -0
- /data/{test/dummy → lib/generators/jinda/templates}/app/views/layouts/lte/_flash.haml +0 -0
- /data/{test/dummy → lib/generators/jinda/templates}/app/views/layouts/lte/_footer.haml +0 -0
- /data/{test/dummy → lib/generators/jinda/templates}/app/views/layouts/lte/_menu.haml +0 -0
- /data/{test/dummy → lib/generators/jinda/templates}/app/views/layouts/lte/_menu_mm.haml +0 -0
- /data/lib/generators/jinda/templates/app/views/layouts/{bsb → lte}/_rightbar.haml +0 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'minitest/autorun'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'open3'
|
|
6
|
+
require 'timeout'
|
|
7
|
+
require 'net/http'
|
|
8
|
+
require 'uri'
|
|
9
|
+
|
|
10
|
+
# Integration test suite for Jinda generated application
|
|
11
|
+
#
|
|
12
|
+
# This test verifies the actual functionality of the generated Rails app:
|
|
13
|
+
# - Home page renders correctly with expected content
|
|
14
|
+
# - Login system works with admin credentials
|
|
15
|
+
# - Application routes and controllers function properly
|
|
16
|
+
#
|
|
17
|
+
# Prerequisites:
|
|
18
|
+
# - Run installation_test.rb first to generate a test app
|
|
19
|
+
# - Or set TEST_APP_PATH to an existing Jinda app
|
|
20
|
+
#
|
|
21
|
+
# Usage:
|
|
22
|
+
# # Test specific app:
|
|
23
|
+
# TEST_APP_PATH=/path/to/app ruby test/integration_test.rb
|
|
24
|
+
#
|
|
25
|
+
# # Use latest test app from installation_test:
|
|
26
|
+
# ruby test/integration_test.rb
|
|
27
|
+
#
|
|
28
|
+
# # Keep server running after tests (for manual debugging):
|
|
29
|
+
# KEEP_SERVER=true ruby test/integration_test.rb
|
|
30
|
+
#
|
|
31
|
+
# # Custom port:
|
|
32
|
+
# TEST_PORT=3001 ruby test/integration_test.rb
|
|
33
|
+
#
|
|
34
|
+
# rubocop:disable Style/ClassVars
|
|
35
|
+
class JindaIntegrationTest < Minitest::Test
|
|
36
|
+
# Tests must run in order
|
|
37
|
+
i_suck_and_my_tests_are_order_dependent!
|
|
38
|
+
|
|
39
|
+
def self.test_order
|
|
40
|
+
:alpha
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
TEST_DIR = File.expand_path('~/tmp/jinda_tests')
|
|
44
|
+
TEST_PORT = ENV.fetch('TEST_PORT', '3000')
|
|
45
|
+
MONGODB_PORT = ENV.fetch('MONGODB_PORT', '27888')
|
|
46
|
+
|
|
47
|
+
# Admin credentials from seeds.rb
|
|
48
|
+
ADMIN_USERNAME = 'admin'
|
|
49
|
+
ADMIN_PASSWORD = 'secret'
|
|
50
|
+
ADMIN_EMAIL = 'admin@test.com'
|
|
51
|
+
|
|
52
|
+
@@test_app_path = nil
|
|
53
|
+
@@server_pid = nil
|
|
54
|
+
@@session_cookie = nil
|
|
55
|
+
|
|
56
|
+
def setup
|
|
57
|
+
# Find test app
|
|
58
|
+
if ENV['TEST_APP_PATH']
|
|
59
|
+
@@test_app_path = ENV['TEST_APP_PATH']
|
|
60
|
+
elsif @@test_app_path.nil?
|
|
61
|
+
# Find most recent test app from installation_test
|
|
62
|
+
if Dir.exist?(TEST_DIR)
|
|
63
|
+
test_apps = Dir.glob(File.join(TEST_DIR, 'jinda_test_*')).sort_by { |f| File.mtime(f) }
|
|
64
|
+
@@test_app_path = test_apps.last
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
skip 'No test app found. Run installation_test.rb first or set TEST_APP_PATH' unless @@test_app_path
|
|
69
|
+
skip "Test app not found: #{@@test_app_path}" unless File.directory?(@@test_app_path)
|
|
70
|
+
|
|
71
|
+
@test_app_path = @@test_app_path
|
|
72
|
+
@base_url = "http://localhost:#{TEST_PORT}"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def teardown
|
|
76
|
+
# Cleanup handled in Minitest.after_run
|
|
77
|
+
nil
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Cleanup after all tests
|
|
81
|
+
Minitest.after_run do
|
|
82
|
+
if @@server_pid && ENV['KEEP_SERVER'] != 'true'
|
|
83
|
+
begin
|
|
84
|
+
Process.kill('TERM', @@server_pid)
|
|
85
|
+
Process.wait(@@server_pid)
|
|
86
|
+
rescue StandardError => e
|
|
87
|
+
puts "Warning: Could not kill server process: #{e.message}"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Clean up PID file
|
|
91
|
+
pid_file = File.join(@@test_app_path, 'tmp/pids/server.pid')
|
|
92
|
+
FileUtils.rm_f(pid_file)
|
|
93
|
+
elsif ENV['KEEP_SERVER'] == 'true'
|
|
94
|
+
puts "\n=== Server kept running at #{TEST_PORT} (PID: #{@@server_pid}) ==="
|
|
95
|
+
puts "To stop: kill #{@@server_pid}"
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_01_start_rails_server
|
|
100
|
+
Dir.chdir(@test_app_path) do
|
|
101
|
+
puts "\n=== Starting Rails server on port #{TEST_PORT} ==="
|
|
102
|
+
|
|
103
|
+
# Clean up old PID file if exists
|
|
104
|
+
pid_file = 'tmp/pids/server.pid'
|
|
105
|
+
FileUtils.rm_f(pid_file)
|
|
106
|
+
|
|
107
|
+
# Start server in background
|
|
108
|
+
@@server_pid = spawn(
|
|
109
|
+
{ 'RAILS_ENV' => 'development', 'MONGODB_PORT' => MONGODB_PORT },
|
|
110
|
+
'bundle', 'exec', 'rails', 'server', '-p', TEST_PORT, '-d',
|
|
111
|
+
out: 'log/test_server.log',
|
|
112
|
+
err: 'log/test_server_error.log'
|
|
113
|
+
)
|
|
114
|
+
Process.detach(@@server_pid)
|
|
115
|
+
|
|
116
|
+
# Wait for server to start (check both process and HTTP)
|
|
117
|
+
server_ready = false
|
|
118
|
+
Timeout.timeout(60) do
|
|
119
|
+
loop do
|
|
120
|
+
# Check if process is running
|
|
121
|
+
stdout, = Open3.capture3("lsof -i :#{TEST_PORT}")
|
|
122
|
+
process_running = stdout.include?('ruby')
|
|
123
|
+
|
|
124
|
+
# Check if HTTP responds
|
|
125
|
+
http_responds = false
|
|
126
|
+
begin
|
|
127
|
+
uri = URI(@base_url)
|
|
128
|
+
response = Net::HTTP.get_response(uri)
|
|
129
|
+
http_responds = !response.nil?
|
|
130
|
+
rescue StandardError
|
|
131
|
+
http_responds = false
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
if process_running && http_responds
|
|
135
|
+
server_ready = true
|
|
136
|
+
break
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
sleep 2
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
assert server_ready, "Rails server did not start within 60 seconds on port #{TEST_PORT}"
|
|
144
|
+
puts "✓ Server started (PID: #{@@server_pid})"
|
|
145
|
+
end
|
|
146
|
+
rescue Timeout::Error
|
|
147
|
+
flunk "Server start timeout on port #{TEST_PORT}"
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def test_02_home_page_loads
|
|
151
|
+
uri = URI(@base_url)
|
|
152
|
+
response = Net::HTTP.get_response(uri)
|
|
153
|
+
|
|
154
|
+
assert_includes [200, 302], response.code.to_i,
|
|
155
|
+
"Expected HTTP 200 or 302, got #{response.code}"
|
|
156
|
+
|
|
157
|
+
# Follow redirect if needed
|
|
158
|
+
if response.code.to_i == 302
|
|
159
|
+
location = response['location']
|
|
160
|
+
uri = URI(location.start_with?('http') ? location : "#{@base_url}#{location}")
|
|
161
|
+
response = Net::HTTP.get_response(uri)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
body = response.body
|
|
165
|
+
|
|
166
|
+
# Check for Jinda dashboard content (from screenshot)
|
|
167
|
+
assert_includes body, 'Jinda', 'Page should contain "Jinda" title'
|
|
168
|
+
assert_includes body, 'Dashboard', 'Page should contain "Dashboard" section'
|
|
169
|
+
|
|
170
|
+
puts '✓ Home page loads successfully'
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def test_03_home_page_contains_version_info
|
|
174
|
+
uri = URI(@base_url)
|
|
175
|
+
response = Net::HTTP.get_response(uri)
|
|
176
|
+
|
|
177
|
+
# Follow redirect if needed
|
|
178
|
+
if response.code.to_i == 302
|
|
179
|
+
location = response['location']
|
|
180
|
+
uri = URI(location.start_with?('http') ? location : "#{@base_url}#{location}")
|
|
181
|
+
response = Net::HTTP.get_response(uri)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
body = response.body
|
|
185
|
+
|
|
186
|
+
# Check for version information (from screenshot)
|
|
187
|
+
assert_includes body, 'Ruby Version', 'Should display Ruby version info'
|
|
188
|
+
assert_includes body, 'Rails Version', 'Should display Rails version info'
|
|
189
|
+
assert_includes body, 'gem jinda', 'Should display Jinda gem version'
|
|
190
|
+
|
|
191
|
+
puts '✓ Version information displayed correctly'
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def test_04_home_page_contains_installation_info
|
|
195
|
+
uri = URI(@base_url)
|
|
196
|
+
response = Net::HTTP.get_response(uri)
|
|
197
|
+
|
|
198
|
+
# Follow redirect if needed
|
|
199
|
+
if response.code.to_i == 302
|
|
200
|
+
location = response['location']
|
|
201
|
+
uri = URI(location.start_with?('http') ? location : "#{@base_url}#{location}")
|
|
202
|
+
response = Net::HTTP.get_response(uri)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
body = response.body
|
|
206
|
+
|
|
207
|
+
# Check for installation section (from screenshot)
|
|
208
|
+
assert_includes body, 'Installation', 'Should contain Installation section'
|
|
209
|
+
assert_includes body, 'Create New Rails', 'Should contain Rails creation instructions'
|
|
210
|
+
|
|
211
|
+
puts '✓ Installation information displayed'
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def test_05_login_page_accessible
|
|
215
|
+
uri = URI("#{@base_url}/auth/identity")
|
|
216
|
+
response = Net::HTTP.get_response(uri)
|
|
217
|
+
|
|
218
|
+
# Should either load login page or redirect to it
|
|
219
|
+
assert_includes [200, 302], response.code.to_i,
|
|
220
|
+
"Login page should be accessible, got HTTP #{response.code}"
|
|
221
|
+
|
|
222
|
+
if response.code.to_i == 200
|
|
223
|
+
body = response.body
|
|
224
|
+
# Check for login form elements
|
|
225
|
+
assert_match(/password|sign.?in|login/i, body, 'Login page should contain login form')
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
puts '✓ Login page accessible'
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def test_06_login_with_admin_credentials
|
|
232
|
+
# Get the login page first to obtain CSRF token
|
|
233
|
+
uri = URI("#{@base_url}/auth/identity")
|
|
234
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
235
|
+
|
|
236
|
+
get_request = Net::HTTP::Get.new(uri.path)
|
|
237
|
+
get_response = http.request(get_request)
|
|
238
|
+
|
|
239
|
+
# Extract CSRF token if present
|
|
240
|
+
csrf_token = nil
|
|
241
|
+
if get_response.body =~ /csrf[_-]token[^>]*value=["']([^"']+)["']/i
|
|
242
|
+
csrf_token = ::Regexp.last_match(1)
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# Extract session cookie
|
|
246
|
+
cookies = get_response.get_fields('set-cookie')
|
|
247
|
+
session_cookie = cookies&.map { |c| c.split(';').first }&.join('; ')
|
|
248
|
+
|
|
249
|
+
# Attempt login with admin credentials
|
|
250
|
+
post_uri = URI("#{@base_url}/auth/identity/callback")
|
|
251
|
+
post_http = Net::HTTP.new(post_uri.host, post_uri.port)
|
|
252
|
+
|
|
253
|
+
post_request = Net::HTTP::Post.new(post_uri.path)
|
|
254
|
+
post_request['Cookie'] = session_cookie if session_cookie
|
|
255
|
+
post_request['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
256
|
+
|
|
257
|
+
params = {
|
|
258
|
+
'auth_key' => ADMIN_USERNAME,
|
|
259
|
+
'password' => ADMIN_PASSWORD
|
|
260
|
+
}
|
|
261
|
+
params['authenticity_token'] = csrf_token if csrf_token
|
|
262
|
+
|
|
263
|
+
post_request.body = URI.encode_www_form(params)
|
|
264
|
+
post_response = post_http.request(post_request)
|
|
265
|
+
|
|
266
|
+
# Should redirect after successful login
|
|
267
|
+
assert_includes [200, 302, 303], post_response.code.to_i,
|
|
268
|
+
"Login should succeed or redirect, got HTTP #{post_response.code}"
|
|
269
|
+
|
|
270
|
+
# Store session cookie for subsequent tests
|
|
271
|
+
if post_response.get_fields('set-cookie')
|
|
272
|
+
@@session_cookie = post_response.get_fields('set-cookie')
|
|
273
|
+
.map { |c| c.split(';').first }
|
|
274
|
+
.join('; ')
|
|
275
|
+
end
|
|
276
|
+
@@session_cookie ||= session_cookie
|
|
277
|
+
|
|
278
|
+
puts '✓ Admin login successful'
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
def test_07_authenticated_access_to_dashboard
|
|
282
|
+
skip 'No session cookie from login' unless @@session_cookie
|
|
283
|
+
|
|
284
|
+
uri = URI(@base_url)
|
|
285
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
286
|
+
|
|
287
|
+
request = Net::HTTP::Get.new(uri.path)
|
|
288
|
+
request['Cookie'] = @@session_cookie
|
|
289
|
+
|
|
290
|
+
response = http.request(request)
|
|
291
|
+
|
|
292
|
+
assert_includes [200, 302], response.code.to_i,
|
|
293
|
+
"Authenticated request should succeed, got HTTP #{response.code}"
|
|
294
|
+
|
|
295
|
+
puts '✓ Authenticated access works'
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
def test_08_users_page_accessible
|
|
299
|
+
skip 'No session cookie from login' unless @@session_cookie
|
|
300
|
+
|
|
301
|
+
uri = URI("#{@base_url}/users")
|
|
302
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
303
|
+
|
|
304
|
+
request = Net::HTTP::Get.new(uri.path)
|
|
305
|
+
request['Cookie'] = @@session_cookie
|
|
306
|
+
|
|
307
|
+
response = http.request(request)
|
|
308
|
+
|
|
309
|
+
# Users page should be accessible to admin
|
|
310
|
+
assert_includes [200, 302], response.code.to_i,
|
|
311
|
+
"Users page should be accessible to admin, got HTTP #{response.code}"
|
|
312
|
+
|
|
313
|
+
if response.code.to_i == 200
|
|
314
|
+
assert_includes response.body, 'user', 'Users page should contain user-related content'
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
puts '✓ Users page accessible'
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def test_09_articles_page_accessible
|
|
321
|
+
skip 'No session cookie from login' unless @@session_cookie
|
|
322
|
+
|
|
323
|
+
uri = URI("#{@base_url}/articles")
|
|
324
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
325
|
+
|
|
326
|
+
request = Net::HTTP::Get.new(uri.path)
|
|
327
|
+
request['Cookie'] = @@session_cookie
|
|
328
|
+
|
|
329
|
+
response = http.request(request)
|
|
330
|
+
|
|
331
|
+
# Articles page should exist
|
|
332
|
+
assert_includes [200, 302, 404], response.code.to_i,
|
|
333
|
+
"Articles endpoint should respond, got HTTP #{response.code}"
|
|
334
|
+
|
|
335
|
+
puts '✓ Articles page responds'
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def test_10_logout_functionality
|
|
339
|
+
skip 'No session cookie from login' unless @@session_cookie
|
|
340
|
+
|
|
341
|
+
# Find logout path
|
|
342
|
+
logout_uri = URI("#{@base_url}/logout")
|
|
343
|
+
http = Net::HTTP.new(logout_uri.host, logout_uri.port)
|
|
344
|
+
|
|
345
|
+
# Try DELETE method first (standard Rails)
|
|
346
|
+
request = Net::HTTP::Delete.new(logout_uri.path)
|
|
347
|
+
request['Cookie'] = @@session_cookie
|
|
348
|
+
|
|
349
|
+
response = http.request(request)
|
|
350
|
+
|
|
351
|
+
# Logout should redirect or succeed
|
|
352
|
+
assert_includes [200, 302, 303, 404], response.code.to_i,
|
|
353
|
+
"Logout should work or endpoint should exist, got HTTP #{response.code}"
|
|
354
|
+
|
|
355
|
+
# If 404, try GET method
|
|
356
|
+
if response.code.to_i == 404
|
|
357
|
+
request = Net::HTTP::Get.new(logout_uri.path)
|
|
358
|
+
request['Cookie'] = @@session_cookie
|
|
359
|
+
response = http.request(request)
|
|
360
|
+
|
|
361
|
+
assert_includes [200, 302, 303, 404], response.code.to_i,
|
|
362
|
+
"Logout GET should work, got HTTP #{response.code}"
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
puts '✓ Logout functionality tested'
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
def test_11_verify_mongodb_connection
|
|
369
|
+
Dir.chdir(@test_app_path) do
|
|
370
|
+
stdout, stderr, status = Open3.capture3(
|
|
371
|
+
{ 'RAILS_ENV' => 'development', 'MONGODB_PORT' => MONGODB_PORT },
|
|
372
|
+
'bundle', 'exec', 'rails', 'runner',
|
|
373
|
+
'puts "MongoDB connected: #{Mongoid.default_client.database.name}"'
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
assert_predicate status, :success?, "MongoDB connection check failed: #{stderr}"
|
|
377
|
+
assert_includes stdout, 'MongoDB connected', 'Should confirm MongoDB connection'
|
|
378
|
+
|
|
379
|
+
puts '✓ MongoDB connection verified'
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def test_12_verify_admin_user_exists
|
|
384
|
+
Dir.chdir(@test_app_path) do
|
|
385
|
+
stdout, stderr, status = Open3.capture3(
|
|
386
|
+
{ 'RAILS_ENV' => 'development', 'MONGODB_PORT' => MONGODB_PORT },
|
|
387
|
+
'bundle', 'exec', 'rails', 'runner',
|
|
388
|
+
'puts "Admin exists: #{Identity.where(code: \"admin\").exists?}"'
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
assert_predicate status, :success?, "Admin check failed: #{stderr}"
|
|
392
|
+
assert_includes stdout, 'Admin exists: true', 'Admin user should exist after seeding'
|
|
393
|
+
|
|
394
|
+
puts '✓ Admin user verified in database'
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
# rubocop:enable Style/ClassVars
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'minitest/autorun'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'open3'
|
|
6
|
+
|
|
7
|
+
# Test suite for Jenkins CI pipeline stages
|
|
8
|
+
#
|
|
9
|
+
# This test verifies that the "Test Generated Application" Jenkins stage
|
|
10
|
+
# executes successfully and performs the expected operations.
|
|
11
|
+
#
|
|
12
|
+
# Usage:
|
|
13
|
+
# ruby test/jenkins_stage_test.rb
|
|
14
|
+
#
|
|
15
|
+
class JenkinsStageTest < Minitest::Test
|
|
16
|
+
JINDA_ROOT = File.expand_path('..', __dir__)
|
|
17
|
+
JENKINSFILE_PATH = File.join(JINDA_ROOT, 'ci/Jenkinsfile')
|
|
18
|
+
|
|
19
|
+
def test_01_jenkinsfile_exists
|
|
20
|
+
assert File.exist?(JENKINSFILE_PATH),
|
|
21
|
+
'Jenkinsfile should exist at ci/Jenkinsfile'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_02_jenkinsfile_contains_required_test_stages
|
|
25
|
+
content = File.read(JENKINSFILE_PATH)
|
|
26
|
+
|
|
27
|
+
# New simplified Jenkinsfile uses Rake tasks
|
|
28
|
+
assert_includes content, "stage('Unit Tests')",
|
|
29
|
+
'Jenkinsfile should contain "Unit Tests" stage'
|
|
30
|
+
assert_includes content, "stage('Installation Tests')",
|
|
31
|
+
'Jenkinsfile should contain "Installation Tests" stage'
|
|
32
|
+
assert_includes content, "stage('Integration Tests')",
|
|
33
|
+
'Jenkinsfile should contain "Integration Tests" stage'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_03_stage_includes_bundle_install_step
|
|
37
|
+
content = File.read(JENKINSFILE_PATH)
|
|
38
|
+
|
|
39
|
+
assert_includes content, 'bundle install',
|
|
40
|
+
'Stage should include bundle install step for generated app'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_04_stage_uses_rake_tasks
|
|
44
|
+
content = File.read(JENKINSFILE_PATH)
|
|
45
|
+
|
|
46
|
+
assert_includes content, 'rake test:unit',
|
|
47
|
+
'Should use rake test:unit'
|
|
48
|
+
assert_includes content, 'rake test:installation',
|
|
49
|
+
'Should use rake test:installation'
|
|
50
|
+
assert_includes content, 'rake test:integration',
|
|
51
|
+
'Should use rake test:integration'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_05_stage_runs_tests_in_parallel
|
|
55
|
+
content = File.read(JENKINSFILE_PATH)
|
|
56
|
+
|
|
57
|
+
assert_includes content, 'parallel {',
|
|
58
|
+
'Should have parallel test execution'
|
|
59
|
+
assert_includes content, "stage('RuboCop - Root')",
|
|
60
|
+
'Should run RuboCop in parallel'
|
|
61
|
+
assert_includes content, "stage('Unit Tests')",
|
|
62
|
+
'Should run unit tests in parallel'
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_06_stage_installs_dependencies
|
|
66
|
+
content = File.read(JENKINSFILE_PATH)
|
|
67
|
+
|
|
68
|
+
assert_includes content, 'gem install bundler',
|
|
69
|
+
'Should install bundler'
|
|
70
|
+
assert_includes content, 'gem install rubocop',
|
|
71
|
+
'Should install rubocop'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_07_stage_builds_gem
|
|
75
|
+
content = File.read(JENKINSFILE_PATH)
|
|
76
|
+
|
|
77
|
+
assert_includes content, "stage('Build Gem')",
|
|
78
|
+
'Should have Build Gem stage'
|
|
79
|
+
assert_includes content, 'gem build jinda.gemspec',
|
|
80
|
+
'Should build gem'
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_08_stage_validates_gem
|
|
84
|
+
content = File.read(JENKINSFILE_PATH)
|
|
85
|
+
|
|
86
|
+
assert_includes content, "stage('Validate Gem')",
|
|
87
|
+
'Should have Validate Gem stage'
|
|
88
|
+
assert_includes content, 'gem specification',
|
|
89
|
+
'Should validate gem specification'
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def test_09_stage_starts_mongodb
|
|
93
|
+
content = File.read(JENKINSFILE_PATH)
|
|
94
|
+
|
|
95
|
+
assert_includes content, "stage('Start MongoDB')",
|
|
96
|
+
'Should have Start MongoDB stage'
|
|
97
|
+
assert_includes content, 'docker run',
|
|
98
|
+
'Should start MongoDB in Docker'
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_10_stage_handles_cleanup
|
|
102
|
+
content = File.read(JENKINSFILE_PATH)
|
|
103
|
+
|
|
104
|
+
assert_includes content, 'post {',
|
|
105
|
+
'Should have post-build actions'
|
|
106
|
+
assert_includes content, 'docker stop',
|
|
107
|
+
'Should stop MongoDB container'
|
|
108
|
+
assert_includes content, 'docker rm',
|
|
109
|
+
'Should remove MongoDB container'
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def test_11_stage_archives_artifacts
|
|
113
|
+
content = File.read(JENKINSFILE_PATH)
|
|
114
|
+
|
|
115
|
+
assert_includes content, 'archiveArtifacts',
|
|
116
|
+
'Should archive artifacts'
|
|
117
|
+
assert_includes content, 'jinda-*.gem',
|
|
118
|
+
'Should archive gem file'
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_12_jenkinsfile_syntax_valid
|
|
122
|
+
# Test that Jenkinsfile has valid Groovy syntax structure
|
|
123
|
+
content = File.read(JENKINSFILE_PATH)
|
|
124
|
+
|
|
125
|
+
assert_includes content, 'pipeline {',
|
|
126
|
+
'Jenkinsfile should start with pipeline block'
|
|
127
|
+
assert_includes content, 'stages {',
|
|
128
|
+
'Jenkinsfile should contain stages block'
|
|
129
|
+
assert_includes content, 'post {',
|
|
130
|
+
'Jenkinsfile should contain post block'
|
|
131
|
+
|
|
132
|
+
# Count braces to ensure they're balanced
|
|
133
|
+
open_braces = content.scan('{').count
|
|
134
|
+
close_braces = content.scan('}').count
|
|
135
|
+
|
|
136
|
+
assert_equal open_braces, close_braces,
|
|
137
|
+
'Jenkinsfile should have balanced braces'
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def test_13_stage_executes_in_correct_order
|
|
141
|
+
content = File.read(JENKINSFILE_PATH)
|
|
142
|
+
|
|
143
|
+
# Extract stage order
|
|
144
|
+
stage_matches = content.scan(/stage\('([^']+)'\)/).flatten
|
|
145
|
+
|
|
146
|
+
unit_index = stage_matches.index('Unit Tests')
|
|
147
|
+
installation_index = stage_matches.index('Installation Tests')
|
|
148
|
+
integration_index = stage_matches.index('Integration Tests')
|
|
149
|
+
|
|
150
|
+
refute_nil unit_index, 'Unit Tests stage should exist'
|
|
151
|
+
refute_nil installation_index, 'Installation Tests stage should exist'
|
|
152
|
+
refute_nil integration_index, 'Integration Tests stage should exist'
|
|
153
|
+
|
|
154
|
+
assert installation_index > unit_index,
|
|
155
|
+
'Installation should run after Unit Tests'
|
|
156
|
+
assert integration_index > installation_index,
|
|
157
|
+
'Integration should run after Installation'
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def test_14_stage_uses_correct_environment_variables
|
|
161
|
+
content = File.read(JENKINSFILE_PATH)
|
|
162
|
+
|
|
163
|
+
assert_includes content, '${WORKSPACE}',
|
|
164
|
+
'Stage should use WORKSPACE environment variable'
|
|
165
|
+
assert_includes content, 'tmp/jinda_tests',
|
|
166
|
+
'Stage should use standard test directory'
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def test_15_stage_has_error_handling
|
|
170
|
+
content = File.read(JENKINSFILE_PATH)
|
|
171
|
+
|
|
172
|
+
# Check error handling in post blocks and cleanup
|
|
173
|
+
assert_includes content, 'always {',
|
|
174
|
+
'Should have always block for cleanup'
|
|
175
|
+
assert_includes content, '|| true',
|
|
176
|
+
'Cleanup steps should not fail build'
|
|
177
|
+
assert_includes content, 'success {',
|
|
178
|
+
'Should have success handler'
|
|
179
|
+
assert_includes content, 'failure {',
|
|
180
|
+
'Should have failure handler'
|
|
181
|
+
end
|
|
182
|
+
end
|