From fe2bce7fbb39b81d96257a808ace2aad7b17f053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Wed, 20 May 2026 08:32:31 -0300 Subject: [PATCH 01/55] :tada: init: Projeto Rails inicializado --- .dockerignore | 51 ++ .gitattributes | 9 + .github/dependabot.yml | 12 + .github/workflows/ci.yml | 150 +++++ .gitignore | 35 + .idea/CAMAAR.iml | 115 ++++ .idea/vcs.xml | 6 + .idea/workspace.xml | 280 ++++++++ .kamal/hooks/docker-setup.sample | 3 + .kamal/hooks/post-app-boot.sample | 3 + .kamal/hooks/post-deploy.sample | 14 + .kamal/hooks/post-proxy-reboot.sample | 3 + .kamal/hooks/pre-app-boot.sample | 3 + .kamal/hooks/pre-build.sample | 51 ++ .kamal/hooks/pre-connect.sample | 47 ++ .kamal/hooks/pre-deploy.sample | 122 ++++ .kamal/hooks/pre-proxy-reboot.sample | 3 + .kamal/secrets | 20 + .rubocop.yml | 8 + .ruby-version | 1 + Dockerfile | 77 +++ Gemfile | 68 ++ Gemfile.lock | 612 ++++++++++++++++++ Rakefile | 6 + app/assets/images/.keep | 0 app/assets/stylesheets/application.css | 10 + app/controllers/application_controller.rb | 7 + app/controllers/concerns/.keep | 0 app/helpers/application_helper.rb | 2 + app/javascript/application.js | 3 + app/javascript/controllers/application.js | 9 + .../controllers/hello_controller.js | 7 + app/javascript/controllers/index.js | 4 + app/jobs/application_job.rb | 7 + app/mailers/application_mailer.rb | 4 + app/models/application_record.rb | 3 + app/models/concerns/.keep | 0 app/views/layouts/application.html.erb | 29 + app/views/layouts/mailer.html.erb | 13 + app/views/layouts/mailer.text.erb | 1 + app/views/pwa/manifest.json.erb | 22 + app/views/pwa/service-worker.js | 26 + bin/brakeman | 7 + bin/bundler-audit | 6 + bin/ci | 6 + bin/cucumber | 11 + bin/dev | 2 + bin/docker-entrypoint | 8 + bin/importmap | 4 + bin/jobs | 6 + bin/kamal | 16 + bin/rails | 4 + bin/rake | 4 + bin/rubocop | 8 + bin/setup | 35 + bin/thrust | 5 + config.ru | 6 + config/application.rb | 27 + config/boot.rb | 4 + config/bundler-audit.yml | 5 + config/cable.yml | 17 + config/cache.yml | 16 + config/ci.rb | 24 + config/credentials.yml.enc | 1 + config/cucumber.yml | 8 + config/database.yml | 74 +++ config/deploy.yml | 119 ++++ config/environment.rb | 5 + config/environments/development.rb | 82 +++ config/environments/production.rb | 90 +++ config/environments/test.rb | 57 ++ config/importmap.rb | 7 + config/initializers/assets.rb | 7 + .../initializers/content_security_policy.rb | 29 + .../initializers/filter_parameter_logging.rb | 8 + config/initializers/inflections.rb | 16 + config/locales/en.yml | 31 + config/puma.rb | 42 ++ config/queue.yml | 18 + config/recurring.yml | 15 + config/routes.rb | 14 + config/storage.yml | 27 + db/cable_schema.rb | 11 + db/cache_schema.rb | 12 + db/queue_schema.rb | 129 ++++ db/seeds.rb | 9 + features/step_definitions/.keep | 0 features/support/env.rb | 53 ++ lib/tasks/.keep | 0 lib/tasks/cucumber.rake | 69 ++ log/.keep | 0 public/400.html | 135 ++++ public/404.html | 135 ++++ public/406-unsupported-browser.html | 135 ++++ public/422.html | 135 ++++ public/500.html | 135 ++++ public/icon.png | Bin 0 -> 4166 bytes public/icon.svg | 3 + public/robots.txt | 1 + script/.keep | 0 storage/.keep | 0 test/controllers/.keep | 0 test/fixtures/files/.keep | 0 test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/test_helper.rb | 15 + tmp/.keep | 0 tmp/pids/.keep | 0 tmp/storage/.keep | 0 vendor/.keep | 0 vendor/javascript/.keep | 0 113 files changed, 3694 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitattributes create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .idea/CAMAAR.iml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100755 .kamal/hooks/docker-setup.sample create mode 100755 .kamal/hooks/post-app-boot.sample create mode 100755 .kamal/hooks/post-deploy.sample create mode 100755 .kamal/hooks/post-proxy-reboot.sample create mode 100755 .kamal/hooks/pre-app-boot.sample create mode 100755 .kamal/hooks/pre-build.sample create mode 100755 .kamal/hooks/pre-connect.sample create mode 100755 .kamal/hooks/pre-deploy.sample create mode 100755 .kamal/hooks/pre-proxy-reboot.sample create mode 100644 .kamal/secrets create mode 100644 .rubocop.yml create mode 100644 .ruby-version create mode 100644 Dockerfile create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 Rakefile create mode 100644 app/assets/images/.keep create mode 100644 app/assets/stylesheets/application.css create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/concerns/.keep create mode 100644 app/helpers/application_helper.rb create mode 100644 app/javascript/application.js create mode 100644 app/javascript/controllers/application.js create mode 100644 app/javascript/controllers/hello_controller.js create mode 100644 app/javascript/controllers/index.js create mode 100644 app/jobs/application_job.rb create mode 100644 app/mailers/application_mailer.rb create mode 100644 app/models/application_record.rb create mode 100644 app/models/concerns/.keep create mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/layouts/mailer.html.erb create mode 100644 app/views/layouts/mailer.text.erb create mode 100644 app/views/pwa/manifest.json.erb create mode 100644 app/views/pwa/service-worker.js create mode 100755 bin/brakeman create mode 100755 bin/bundler-audit create mode 100755 bin/ci create mode 100755 bin/cucumber create mode 100755 bin/dev create mode 100755 bin/docker-entrypoint create mode 100755 bin/importmap create mode 100755 bin/jobs create mode 100755 bin/kamal create mode 100755 bin/rails create mode 100755 bin/rake create mode 100755 bin/rubocop create mode 100755 bin/setup create mode 100755 bin/thrust create mode 100644 config.ru create mode 100644 config/application.rb create mode 100644 config/boot.rb create mode 100644 config/bundler-audit.yml create mode 100644 config/cable.yml create mode 100644 config/cache.yml create mode 100644 config/ci.rb create mode 100644 config/credentials.yml.enc create mode 100644 config/cucumber.yml create mode 100644 config/database.yml create mode 100644 config/deploy.yml create mode 100644 config/environment.rb create mode 100644 config/environments/development.rb create mode 100644 config/environments/production.rb create mode 100644 config/environments/test.rb create mode 100644 config/importmap.rb create mode 100644 config/initializers/assets.rb create mode 100644 config/initializers/content_security_policy.rb create mode 100644 config/initializers/filter_parameter_logging.rb create mode 100644 config/initializers/inflections.rb create mode 100644 config/locales/en.yml create mode 100644 config/puma.rb create mode 100644 config/queue.yml create mode 100644 config/recurring.yml create mode 100644 config/routes.rb create mode 100644 config/storage.yml create mode 100644 db/cable_schema.rb create mode 100644 db/cache_schema.rb create mode 100644 db/queue_schema.rb create mode 100644 db/seeds.rb create mode 100644 features/step_definitions/.keep create mode 100644 features/support/env.rb create mode 100644 lib/tasks/.keep create mode 100644 lib/tasks/cucumber.rake create mode 100644 log/.keep create mode 100644 public/400.html create mode 100644 public/404.html create mode 100644 public/406-unsupported-browser.html create mode 100644 public/422.html create mode 100644 public/500.html create mode 100644 public/icon.png create mode 100644 public/icon.svg create mode 100644 public/robots.txt create mode 100644 script/.keep create mode 100644 storage/.keep create mode 100644 test/controllers/.keep create mode 100644 test/fixtures/files/.keep create mode 100644 test/helpers/.keep create mode 100644 test/integration/.keep create mode 100644 test/mailers/.keep create mode 100644 test/models/.keep create mode 100644 test/test_helper.rb create mode 100644 tmp/.keep create mode 100644 tmp/pids/.keep create mode 100644 tmp/storage/.keep create mode 100644 vendor/.keep create mode 100644 vendor/javascript/.keep diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..325bfc036d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,51 @@ +# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. + +# Ignore git directory. +/.git/ +/.gitignore + +# Ignore bundler config. +/.bundle + +# Ignore all environment files. +/.env* + +# Ignore all default key files. +/config/master.key +/config/credentials/*.key + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/.keep + +# Ignore storage (uploaded files in development and any SQLite databases). +/storage/* +!/storage/.keep +/tmp/storage/* +!/tmp/storage/.keep + +# Ignore assets. +/node_modules/ +/app/assets/builds/* +!/app/assets/builds/.keep +/public/assets + +# Ignore CI service files. +/.github + +# Ignore Kamal files. +/config/deploy*.yml +/.kamal + +# Ignore development files +/.devcontainer + +# Ignore Docker-related files +/.dockerignore +/Dockerfile* diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..8dc4323435 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# See https://git-scm.com/docs/gitattributes for more about git attribute files. + +# Mark the database schema as having been generated. +db/schema.rb linguist-generated + +# Mark any vendored files as having been vendored. +vendor/* linguist-vendored +config/credentials/*.yml.enc diff=rails_credentials +config/credentials.yml.enc diff=rails_credentials diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..83610cfa4c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: bundler + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..48f6abf003 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,150 @@ +name: CI + +on: + pull_request: + push: + branches: [ main ] + +jobs: + scan_ruby: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Scan for common Rails security vulnerabilities using static analysis + run: bin/brakeman --no-pager + + - name: Scan for known security vulnerabilities in gems used + run: bin/bundler-audit + + scan_js: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Scan for security vulnerabilities in JavaScript dependencies + run: bin/importmap audit + + lint: + runs-on: ubuntu-latest + env: + RUBOCOP_CACHE_ROOT: tmp/rubocop + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Prepare RuboCop cache + uses: actions/cache@v4 + env: + DEPENDENCIES_HASH: ${{ hashFiles('.ruby-version', '**/.rubocop.yml', '**/.rubocop_todo.yml', 'Gemfile.lock') }} + with: + path: ${{ env.RUBOCOP_CACHE_ROOT }} + key: rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}-${{ github.ref_name == github.event.repository.default_branch && github.run_id || 'default' }} + restore-keys: | + rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}- + + - name: Lint code for consistent style + run: bin/rubocop -f github + + test: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql + env: + MYSQL_ALLOW_EMPTY_PASSWORD: true + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + # redis: + # image: valkey/valkey:8 + # ports: + # - 6379:6379 + # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Install packages + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y default-libmysqlclient-dev libvips + + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Run tests + env: + RAILS_ENV: test + DATABASE_URL: mysql2://127.0.0.1:3306 + # RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} + # REDIS_URL: redis://localhost:6379/0 + run: bin/rails db:test:prepare test + + system-test: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql + env: + MYSQL_ALLOW_EMPTY_PASSWORD: true + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + # redis: + # image: valkey/valkey:8 + # ports: + # - 6379:6379 + # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Install packages + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y default-libmysqlclient-dev libvips + + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Run System Tests + env: + RAILS_ENV: test + DATABASE_URL: mysql2://127.0.0.1:3306 + # RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} + # REDIS_URL: redis://localhost:6379/0 + run: bin/rails db:test:prepare test:system + + - name: Keep screenshots from failed system tests + uses: actions/upload-artifact@v4 + if: failure() + with: + name: screenshots + path: ${{ github.workspace }}/tmp/screenshots + if-no-files-found: ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..fbcab405eb --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# Temporary files generated by your text editor or operating system +# belong in git's global ignore instead: +# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore` + +# Ignore bundler config. +/.bundle + +# Ignore all environment files. +/.env* + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + +# Ignore storage (uploaded files in development and any SQLite databases). +/storage/* +!/storage/.keep +/tmp/storage/* +!/tmp/storage/ +!/tmp/storage/.keep + +/public/assets + +# Ignore key files for decrypting credentials and more. +/config/*.key + diff --git a/.idea/CAMAAR.iml b/.idea/CAMAAR.iml new file mode 100644 index 0000000000..282e3a1610 --- /dev/null +++ b/.idea/CAMAAR.iml @@ -0,0 +1,115 @@ + + + + + + + + + + + + file://$MODULE_DIR$/app + + + file://$MODULE_DIR$/app/assets + + + file://$MODULE_DIR$/app/channels + + + file://$MODULE_DIR$/app/controllers + + + file://$MODULE_DIR$/app/helpers + + + file://$MODULE_DIR$/app/mailers + + + file://$MODULE_DIR$/app/models + + + file://$MODULE_DIR$/app/views + + + file://$MODULE_DIR$/config + + + file://$MODULE_DIR$/config/cable.yml + + + file://$MODULE_DIR$/config/cache.yml + + + file://$MODULE_DIR$/config/database.yml + + + file://$MODULE_DIR$/config/environment.rb + + + file://$MODULE_DIR$/config/environments + + + file://$MODULE_DIR$/config/initializers + + + file://$MODULE_DIR$/config/locales + + + file://$MODULE_DIR$/config/routes + + + file://$MODULE_DIR$/config/routes.rb + + + file://$MODULE_DIR$/config/solid_cache.yml + + + file://$MODULE_DIR$/db + + + file://$MODULE_DIR$/db/migrate + + + file://$MODULE_DIR$/db/seeds.rb + + + file://$MODULE_DIR$/lib + + + file://$MODULE_DIR$/lib/assets + + + file://$MODULE_DIR$/lib/tasks + + + file://$MODULE_DIR$/lib/templates + + + file://$MODULE_DIR$/log/development.log + + + file://$MODULE_DIR$/public + + + file://$MODULE_DIR$/public/javascripts + + + file://$MODULE_DIR$/public/stylesheets + + + file://$MODULE_DIR$/test/mailers/previews + file://$MODULE_DIR$/test/mailers/previews + + + file://$MODULE_DIR$/tmp + + + file://$MODULE_DIR$/vendor + + + file://$MODULE_DIR$/vendor/assets + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000..35eb1ddfbb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000000..42de37f639 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,280 @@ + + + + + + + + { + "lastFilter": { + "state": "OPEN", + "assignee": "neatzzy" + } +} + { + "selectedUrlAndAccountId": { + "url": "https://github.com/gusfring41/CAMAAR.git", + "accountId": "16cd7249-73f1-4476-a633-ea508292c1bb" + } +} + { + "associatedIndex": 7, + "fromUser": false +} + + + + { + "keyToString": { + "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true", + "RunOnceActivity.git.unshallow": "true", + "RunOnceActivity.ruby.rubocop.migration.global.runOnSaveToExternalFormatter": "true", + "RunOnceActivity.typescript.service.memoryLimit.init": "true", + "SHARE_PROJECT_CONFIGURATION_FILES": "true", + "codeWithMe.voiceChat.enabledByDefault": "false", + "git-widget-placeholder": "main", + "nodejs_package_manager_path": "npm", + "ruby.structure.view.model.defaults.configured": "true", + "vue.rearranger.settings.migration": "true" + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1779276211683 + + + + + + \ No newline at end of file diff --git a/.kamal/hooks/docker-setup.sample b/.kamal/hooks/docker-setup.sample new file mode 100755 index 0000000000..2fb07d7d7a --- /dev/null +++ b/.kamal/hooks/docker-setup.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Docker set up on $KAMAL_HOSTS..." diff --git a/.kamal/hooks/post-app-boot.sample b/.kamal/hooks/post-app-boot.sample new file mode 100755 index 0000000000..70f9c4bc95 --- /dev/null +++ b/.kamal/hooks/post-app-boot.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Booted app version $KAMAL_VERSION on $KAMAL_HOSTS..." diff --git a/.kamal/hooks/post-deploy.sample b/.kamal/hooks/post-deploy.sample new file mode 100755 index 0000000000..fd364c2a77 --- /dev/null +++ b/.kamal/hooks/post-deploy.sample @@ -0,0 +1,14 @@ +#!/bin/sh + +# A sample post-deploy hook +# +# These environment variables are available: +# KAMAL_RECORDED_AT +# KAMAL_PERFORMER +# KAMAL_VERSION +# KAMAL_HOSTS +# KAMAL_ROLES (if set) +# KAMAL_DESTINATION (if set) +# KAMAL_RUNTIME + +echo "$KAMAL_PERFORMER deployed $KAMAL_VERSION to $KAMAL_DESTINATION in $KAMAL_RUNTIME seconds" diff --git a/.kamal/hooks/post-proxy-reboot.sample b/.kamal/hooks/post-proxy-reboot.sample new file mode 100755 index 0000000000..1435a677f2 --- /dev/null +++ b/.kamal/hooks/post-proxy-reboot.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Rebooted kamal-proxy on $KAMAL_HOSTS" diff --git a/.kamal/hooks/pre-app-boot.sample b/.kamal/hooks/pre-app-boot.sample new file mode 100755 index 0000000000..45f7355045 --- /dev/null +++ b/.kamal/hooks/pre-app-boot.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Booting app version $KAMAL_VERSION on $KAMAL_HOSTS..." diff --git a/.kamal/hooks/pre-build.sample b/.kamal/hooks/pre-build.sample new file mode 100755 index 0000000000..c5a55678b2 --- /dev/null +++ b/.kamal/hooks/pre-build.sample @@ -0,0 +1,51 @@ +#!/bin/sh + +# A sample pre-build hook +# +# Checks: +# 1. We have a clean checkout +# 2. A remote is configured +# 3. The branch has been pushed to the remote +# 4. The version we are deploying matches the remote +# +# These environment variables are available: +# KAMAL_RECORDED_AT +# KAMAL_PERFORMER +# KAMAL_VERSION +# KAMAL_HOSTS +# KAMAL_ROLES (if set) +# KAMAL_DESTINATION (if set) + +if [ -n "$(git status --porcelain)" ]; then + echo "Git checkout is not clean, aborting..." >&2 + git status --porcelain >&2 + exit 1 +fi + +first_remote=$(git remote) + +if [ -z "$first_remote" ]; then + echo "No git remote set, aborting..." >&2 + exit 1 +fi + +current_branch=$(git branch --show-current) + +if [ -z "$current_branch" ]; then + echo "Not on a git branch, aborting..." >&2 + exit 1 +fi + +remote_head=$(git ls-remote $first_remote --tags $current_branch | cut -f1) + +if [ -z "$remote_head" ]; then + echo "Branch not pushed to remote, aborting..." >&2 + exit 1 +fi + +if [ "$KAMAL_VERSION" != "$remote_head" ]; then + echo "Version ($KAMAL_VERSION) does not match remote HEAD ($remote_head), aborting..." >&2 + exit 1 +fi + +exit 0 diff --git a/.kamal/hooks/pre-connect.sample b/.kamal/hooks/pre-connect.sample new file mode 100755 index 0000000000..77744bdca8 --- /dev/null +++ b/.kamal/hooks/pre-connect.sample @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby + +# A sample pre-connect check +# +# Warms DNS before connecting to hosts in parallel +# +# These environment variables are available: +# KAMAL_RECORDED_AT +# KAMAL_PERFORMER +# KAMAL_VERSION +# KAMAL_HOSTS +# KAMAL_ROLES (if set) +# KAMAL_DESTINATION (if set) +# KAMAL_RUNTIME + +hosts = ENV["KAMAL_HOSTS"].split(",") +results = nil +max = 3 + +elapsed = Benchmark.realtime do + results = hosts.map do |host| + Thread.new do + tries = 1 + + begin + Socket.getaddrinfo(host, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) + rescue SocketError + if tries < max + puts "Retrying DNS warmup: #{host}" + tries += 1 + sleep rand + retry + else + puts "DNS warmup failed: #{host}" + host + end + end + + tries + end + end.map(&:value) +end + +retries = results.sum - hosts.size +nopes = results.count { |r| r == max } + +puts "Prewarmed %d DNS lookups in %.2f sec: %d retries, %d failures" % [ hosts.size, elapsed, retries, nopes ] diff --git a/.kamal/hooks/pre-deploy.sample b/.kamal/hooks/pre-deploy.sample new file mode 100755 index 0000000000..05b3055b72 --- /dev/null +++ b/.kamal/hooks/pre-deploy.sample @@ -0,0 +1,122 @@ +#!/usr/bin/env ruby + +# A sample pre-deploy hook +# +# Checks the Github status of the build, waiting for a pending build to complete for up to 720 seconds. +# +# Fails unless the combined status is "success" +# +# These environment variables are available: +# KAMAL_RECORDED_AT +# KAMAL_PERFORMER +# KAMAL_VERSION +# KAMAL_HOSTS +# KAMAL_COMMAND +# KAMAL_SUBCOMMAND +# KAMAL_ROLES (if set) +# KAMAL_DESTINATION (if set) + +# Only check the build status for production deployments +if ENV["KAMAL_COMMAND"] == "rollback" || ENV["KAMAL_DESTINATION"] != "production" + exit 0 +end + +require "bundler/inline" + +# true = install gems so this is fast on repeat invocations +gemfile(true, quiet: true) do + source "https://rubygems.org" + + gem "octokit" + gem "faraday-retry" +end + +MAX_ATTEMPTS = 72 +ATTEMPTS_GAP = 10 + +def exit_with_error(message) + $stderr.puts message + exit 1 +end + +class GithubStatusChecks + attr_reader :remote_url, :git_sha, :github_client, :combined_status + + def initialize + @remote_url = github_repo_from_remote_url + @git_sha = `git rev-parse HEAD`.strip + @github_client = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"]) + refresh! + end + + def refresh! + @combined_status = github_client.combined_status(remote_url, git_sha) + end + + def state + combined_status[:state] + end + + def first_status_url + first_status = combined_status[:statuses].find { |status| status[:state] == state } + first_status && first_status[:target_url] + end + + def complete_count + combined_status[:statuses].count { |status| status[:state] != "pending"} + end + + def total_count + combined_status[:statuses].count + end + + def current_status + if total_count > 0 + "Completed #{complete_count}/#{total_count} checks, see #{first_status_url} ..." + else + "Build not started..." + end + end + + private + def github_repo_from_remote_url + url = `git config --get remote.origin.url`.strip.delete_suffix(".git") + if url.start_with?("https://github.com/") + url.delete_prefix("https://github.com/") + elsif url.start_with?("git@github.com:") + url.delete_prefix("git@github.com:") + else + url + end + end +end + + +$stdout.sync = true + +begin + puts "Checking build status..." + + attempts = 0 + checks = GithubStatusChecks.new + + loop do + case checks.state + when "success" + puts "Checks passed, see #{checks.first_status_url}" + exit 0 + when "failure" + exit_with_error "Checks failed, see #{checks.first_status_url}" + when "pending" + attempts += 1 + end + + exit_with_error "Checks are still pending, gave up after #{MAX_ATTEMPTS * ATTEMPTS_GAP} seconds" if attempts == MAX_ATTEMPTS + + puts checks.current_status + sleep(ATTEMPTS_GAP) + checks.refresh! + end +rescue Octokit::NotFound + exit_with_error "Build status could not be found" +end diff --git a/.kamal/hooks/pre-proxy-reboot.sample b/.kamal/hooks/pre-proxy-reboot.sample new file mode 100755 index 0000000000..061f8059e6 --- /dev/null +++ b/.kamal/hooks/pre-proxy-reboot.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Rebooting kamal-proxy on $KAMAL_HOSTS..." diff --git a/.kamal/secrets b/.kamal/secrets new file mode 100644 index 0000000000..b3089d6f5a --- /dev/null +++ b/.kamal/secrets @@ -0,0 +1,20 @@ +# Secrets defined here are available for reference under registry/password, env/secret, builder/secrets, +# and accessories/*/env/secret in config/deploy.yml. All secrets should be pulled from either +# password manager, ENV, or a file. DO NOT ENTER RAW CREDENTIALS HERE! This file needs to be safe for git. + +# Example of extracting secrets from 1password (or another compatible pw manager) +# SECRETS=$(kamal secrets fetch --adapter 1password --account your-account --from Vault/Item KAMAL_REGISTRY_PASSWORD RAILS_MASTER_KEY) +# KAMAL_REGISTRY_PASSWORD=$(kamal secrets extract KAMAL_REGISTRY_PASSWORD ${SECRETS}) +# RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY ${SECRETS}) + +# Example of extracting secrets from Rails credentials +# KAMAL_REGISTRY_PASSWORD=$(rails credentials:fetch kamal.registry_password) + +# Use a GITHUB_TOKEN if private repositories are needed for the image +# GITHUB_TOKEN=$(gh config get -h github.com oauth_token) + +# Grab the registry password from ENV +# KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD + +# Improve security by using a password manager. Never check config/master.key into git! +RAILS_MASTER_KEY=$(cat config/master.key) diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000000..f9d86d4a54 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,8 @@ +# Omakase Ruby styling for Rails +inherit_gem: { rubocop-rails-omakase: rubocop.yml } + +# Overwrite or add rules to create your own house style +# +# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` +# Layout/SpaceInsideArrayLiteralBrackets: +# Enabled: false diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000000..4d54daddb6 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +4.0.2 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..c625035af4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,77 @@ +# syntax=docker/dockerfile:1 +# check=error=true + +# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand: +# docker build -t camaar . +# docker run -d -p 80:80 -e RAILS_MASTER_KEY= --name camaar camaar + +# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html + +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version +ARG RUBY_VERSION=4.0.2 +FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base + +# Rails app lives here +WORKDIR /rails + +# Install base packages +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y curl default-mysql-client libjemalloc2 libvips && \ + ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so && \ + rm -rf /var/lib/apt/lists /var/cache/apt/archives + +# Set production environment variables and enable jemalloc for reduced memory usage and latency. +ENV RAILS_ENV="production" \ + BUNDLE_DEPLOYMENT="1" \ + BUNDLE_PATH="/usr/local/bundle" \ + BUNDLE_WITHOUT="development" \ + LD_PRELOAD="/usr/local/lib/libjemalloc.so" + +# Throw-away build stage to reduce size of final image +FROM base AS build + +# Install packages needed to build gems +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y build-essential default-libmysqlclient-dev git libvips libyaml-dev pkg-config && \ + rm -rf /var/lib/apt/lists /var/cache/apt/archives + +# Install application gems +COPY vendor/* ./vendor/ +COPY Gemfile Gemfile.lock ./ + +RUN bundle install && \ + rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ + # -j 1 disable parallel compilation to avoid a QEMU bug: https://github.com/rails/bootsnap/issues/495 + bundle exec bootsnap precompile -j 1 --gemfile + +# Copy application code +COPY . . + +# Precompile bootsnap code for faster boot times. +# -j 1 disable parallel compilation to avoid a QEMU bug: https://github.com/rails/bootsnap/issues/495 +RUN bundle exec bootsnap precompile -j 1 app/ lib/ + +# Precompiling assets for production without requiring secret RAILS_MASTER_KEY +RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile + + + + +# Final stage for app image +FROM base + +# Run and own only the runtime files as a non-root user for security +RUN groupadd --system --gid 1000 rails && \ + useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash +USER 1000:1000 + +# Copy built artifacts: gems, application +COPY --chown=rails:rails --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}" +COPY --chown=rails:rails --from=build /rails /rails + +# Entrypoint prepares the database. +ENTRYPOINT ["/rails/bin/docker-entrypoint"] + +# Start server via Thruster by default, this can be overwritten at runtime +EXPOSE 80 +CMD ["./bin/thrust", "./bin/rails", "server"] diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..92bb4366f4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,68 @@ +source "https://rubygems.org" + +# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" +gem "rails", "~> 8.1.3" +# The modern asset pipeline for Rails [https://github.com/rails/propshaft] +gem "propshaft" +# Use mysql as the database for Active Record +gem "mysql2", "~> 0.5" +# Use the Puma web server [https://github.com/puma/puma] +gem "puma", ">= 5.0" +# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] +gem "importmap-rails" +# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] +gem "turbo-rails" +# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] +gem "stimulus-rails" +# Build JSON APIs with ease [https://github.com/rails/jbuilder] +gem "jbuilder" + +# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] +# gem "bcrypt", "~> 3.1.7" + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem "tzinfo-data", platforms: %i[ windows jruby ] + +# Use the database-backed adapters for Rails.cache, Active Job, and Action Cable +gem "solid_cache" +gem "solid_queue" +gem "solid_cable" + +# Reduces boot times through caching; required in config/boot.rb +gem "bootsnap", require: false + +# Deploy this application anywhere as a Docker container [https://kamal-deploy.org] +gem "kamal", require: false + +# Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/] +gem "thruster", require: false + +# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] +gem "image_processing", "~> 1.2" + +group :development, :test do + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem "debug", platforms: %i[ mri windows ], require: "debug/prelude" + + # Audits gems for known security defects (use config/bundler-audit.yml to ignore issues) + gem "bundler-audit", require: false + + # Static analysis for security vulnerabilities [https://brakemanscanner.org/] + gem "brakeman", require: false + + # Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/] + gem "rubocop-rails-omakase", require: false +end + +group :development do + # Use console on exceptions pages [https://github.com/rails/web-console] + gem "web-console" +end + +group :test do + # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] + gem "capybara" + gem "selenium-webdriver" + gem 'cucumber-rails', require: false + gem 'database_cleaner' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000..591d95f42b --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,612 @@ +GEM + remote: https://rubygems.org/ + specs: + action_text-trix (2.1.19) + railties + actioncable (8.1.3) + actionpack (= 8.1.3) + activesupport (= 8.1.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (8.1.3) + actionpack (= 8.1.3) + activejob (= 8.1.3) + activerecord (= 8.1.3) + activestorage (= 8.1.3) + activesupport (= 8.1.3) + mail (>= 2.8.0) + actionmailer (8.1.3) + actionpack (= 8.1.3) + actionview (= 8.1.3) + activejob (= 8.1.3) + activesupport (= 8.1.3) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (8.1.3) + actionview (= 8.1.3) + activesupport (= 8.1.3) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (8.1.3) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.3) + activerecord (= 8.1.3) + activestorage (= 8.1.3) + activesupport (= 8.1.3) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (8.1.3) + activesupport (= 8.1.3) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (8.1.3) + activesupport (= 8.1.3) + globalid (>= 0.3.6) + activemodel (8.1.3) + activesupport (= 8.1.3) + activerecord (8.1.3) + activemodel (= 8.1.3) + activesupport (= 8.1.3) + timeout (>= 0.4.0) + activestorage (8.1.3) + actionpack (= 8.1.3) + activejob (= 8.1.3) + activerecord (= 8.1.3) + activesupport (= 8.1.3) + marcel (~> 1.0) + activesupport (8.1.3) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + json + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + addressable (2.9.0) + public_suffix (>= 2.0.2, < 8.0) + ast (2.4.3) + base64 (0.3.0) + bcrypt_pbkdf (1.1.2) + bigdecimal (4.1.2) + bindex (0.8.1) + bootsnap (1.24.4) + msgpack (~> 1.2) + brakeman (8.0.4) + racc + builder (3.3.0) + bundler-audit (0.9.3) + bundler (>= 1.2.0) + thor (~> 1.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + concurrent-ruby (1.3.6) + connection_pool (3.0.2) + crass (1.0.6) + cucumber (10.2.0) + base64 (~> 0.2) + builder (~> 3.2) + cucumber-ci-environment (> 9, < 12) + cucumber-core (> 15, < 17) + cucumber-cucumber-expressions (> 17, < 20) + cucumber-html-formatter (> 21, < 23) + diff-lcs (~> 1.5) + logger (~> 1.6) + mini_mime (~> 1.1) + multi_test (~> 1.1) + sys-uname (~> 1.3) + cucumber-ci-environment (11.0.0) + cucumber-core (16.2.0) + cucumber-gherkin (> 36, < 40) + cucumber-messages (> 31, < 33) + cucumber-tag-expressions (> 6, < 9) + cucumber-cucumber-expressions (19.0.0) + bigdecimal + cucumber-gherkin (39.1.0) + cucumber-messages (>= 31, < 33) + cucumber-html-formatter (22.3.0) + cucumber-messages (> 23, < 33) + cucumber-messages (32.3.1) + cucumber-rails (4.0.1) + capybara (>= 3.25, < 4) + cucumber (>= 7, < 11) + railties (>= 6.1, < 9) + cucumber-tag-expressions (8.1.0) + database_cleaner (2.1.0) + database_cleaner-active_record (>= 2, < 3) + database_cleaner-active_record (2.2.2) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0) + database_cleaner-core (2.0.1) + date (3.5.1) + debug (1.11.1) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.6.2) + dotenv (3.2.0) + drb (2.2.3) + ed25519 (1.4.0) + erb (6.0.4) + erubi (1.13.1) + et-orbi (1.4.0) + tzinfo + ffi (1.17.4-aarch64-linux-gnu) + ffi (1.17.4-aarch64-linux-musl) + ffi (1.17.4-arm-linux-gnu) + ffi (1.17.4-arm-linux-musl) + ffi (1.17.4-arm64-darwin) + ffi (1.17.4-x86_64-linux-gnu) + ffi (1.17.4-x86_64-linux-musl) + fugit (1.12.1) + et-orbi (~> 1.4) + raabro (~> 1.4) + globalid (1.3.0) + activesupport (>= 6.1) + i18n (1.14.8) + concurrent-ruby (~> 1.0) + image_processing (1.14.0) + mini_magick (>= 4.9.5, < 6) + ruby-vips (>= 2.0.17, < 3) + importmap-rails (2.2.3) + actionpack (>= 6.0.0) + activesupport (>= 6.0.0) + railties (>= 6.0.0) + io-console (0.8.2) + irb (1.18.0) + pp (>= 0.6.0) + prism (>= 1.3.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.15.0) + actionview (>= 7.0.0) + activesupport (>= 7.0.0) + json (2.19.5) + kamal (2.11.0) + activesupport (>= 7.0) + base64 (~> 0.2) + bcrypt_pbkdf (~> 1.0) + concurrent-ruby (~> 1.2) + dotenv (~> 3.1) + ed25519 (~> 1.4) + net-ssh (~> 7.3) + sshkit (>= 1.23.0, < 2.0) + thor (~> 1.3) + zeitwerk (>= 2.6.18, < 3.0) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) + loofah (2.25.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.9.0) + logger + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.2.1) + matrix (0.4.3) + memoist3 (1.0.0) + mini_magick (5.3.1) + logger + mini_mime (1.1.5) + minitest (6.0.6) + drb (~> 2.0) + prism (~> 1.5) + msgpack (1.8.0) + multi_test (1.1.0) + mysql2 (0.5.7) + bigdecimal + net-imap (0.6.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-scp (4.1.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-sftp (4.0.0) + net-ssh (>= 5.0.0, < 8.0.0) + net-smtp (0.5.1) + net-protocol + net-ssh (7.3.2) + nio4r (2.7.5) + nokogiri (1.19.3-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.19.3-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.19.3-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.19.3-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.19.3-arm64-darwin) + racc (~> 1.4) + nokogiri (1.19.3-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.19.3-x86_64-linux-musl) + racc (~> 1.4) + ostruct (0.6.3) + parallel (2.1.0) + parser (3.3.11.1) + ast (~> 2.4.1) + racc + pp (0.6.3) + prettyprint + prettyprint (0.2.0) + prism (1.9.0) + propshaft (1.3.2) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) + rack + psych (5.3.1) + date + stringio + public_suffix (7.0.5) + puma (8.0.1) + nio4r (~> 2.0) + raabro (1.4.0) + racc (1.8.1) + rack (3.2.6) + rack-session (2.1.2) + base64 (>= 0.1.0) + rack (>= 3.0.0) + rack-test (2.2.0) + rack (>= 1.3) + rackup (2.3.1) + rack (>= 3) + rails (8.1.3) + actioncable (= 8.1.3) + actionmailbox (= 8.1.3) + actionmailer (= 8.1.3) + actionpack (= 8.1.3) + actiontext (= 8.1.3) + actionview (= 8.1.3) + activejob (= 8.1.3) + activemodel (= 8.1.3) + activerecord (= 8.1.3) + activestorage (= 8.1.3) + activesupport (= 8.1.3) + bundler (>= 1.15.0) + railties (= 8.1.3) + rails-dom-testing (2.3.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.7.0) + loofah (~> 2.25) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (8.1.3) + actionpack (= 8.1.3) + activesupport (= 8.1.3) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.4.2) + rdoc (7.2.0) + erb + psych (>= 4.0.0) + tsort + regexp_parser (2.12.0) + reline (0.6.3) + io-console (~> 0.5) + rexml (3.4.4) + rubocop (1.86.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (>= 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.49.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.49.1) + parser (>= 3.3.7.2) + prism (~> 1.7) + rubocop-performance (1.26.1) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) + rubocop-rails (2.35.2) + activesupport (>= 4.2.0) + lint_roller (~> 1.1) + rack (>= 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rails-omakase (1.1.0) + rubocop (>= 1.72) + rubocop-performance (>= 1.24) + rubocop-rails (>= 2.30) + ruby-progressbar (1.13.0) + ruby-vips (2.3.0) + ffi (~> 1.12) + logger + rubyzip (3.3.0) + securerandom (0.4.1) + selenium-webdriver (4.44.0) + base64 (~> 0.2) + logger (~> 1.4) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 4.0) + websocket (~> 1.0) + solid_cable (3.0.12) + actioncable (>= 7.2) + activejob (>= 7.2) + activerecord (>= 7.2) + railties (>= 7.2) + solid_cache (1.0.10) + activejob (>= 7.2) + activerecord (>= 7.2) + railties (>= 7.2) + solid_queue (1.4.0) + activejob (>= 7.1) + activerecord (>= 7.1) + concurrent-ruby (>= 1.3.1) + fugit (~> 1.11) + railties (>= 7.1) + thor (>= 1.3.1) + sshkit (1.25.0) + base64 + logger + net-scp (>= 1.1.2) + net-sftp (>= 2.1.2) + net-ssh (>= 2.8.0) + ostruct + stimulus-rails (1.3.4) + railties (>= 6.0.0) + stringio (3.2.0) + sys-uname (1.5.1) + ffi (~> 1.1) + memoist3 (~> 1.0.0) + thor (1.5.0) + thruster (0.1.21) + thruster (0.1.21-aarch64-linux) + thruster (0.1.21-arm64-darwin) + thruster (0.1.21-x86_64-linux) + timeout (0.6.1) + tsort (0.2.0) + turbo-rails (2.0.23) + actionpack (>= 7.1.0) + railties (>= 7.1.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.2.0) + uri (1.1.1) + useragent (0.16.11) + web-console (4.3.0) + actionview (>= 8.0.0) + bindex (>= 0.4.0) + railties (>= 8.0.0) + websocket (1.2.11) + websocket-driver (0.8.0) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.8.1) + +PLATFORMS + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin-25 + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + bootsnap + brakeman + bundler-audit + capybara + cucumber-rails + database_cleaner + debug + image_processing (~> 1.2) + importmap-rails + jbuilder + kamal + mysql2 (~> 0.5) + propshaft + puma (>= 5.0) + rails (~> 8.1.3) + rubocop-rails-omakase + selenium-webdriver + solid_cable + solid_cache + solid_queue + stimulus-rails + thruster + turbo-rails + tzinfo-data + web-console + +CHECKSUMS + action_text-trix (2.1.19) sha256=7012f59421009cf284aa651294896414d653a61a2417c9b8714c8476d2f74009 + actioncable (8.1.3) sha256=e5bc7f75e44e6a22de29c4f43176927c3a9ce4824464b74ed18d8226e75a80f0 + actionmailbox (8.1.3) sha256=df7da474eaa0e70df4ed5a6fef66eb3b3b0f2dbf7f14518deee8d77f1b4aae59 + actionmailer (8.1.3) sha256=831f724891bb70d0aaa4d76581a6321124b6a752cb655c9346aae5479318448d + actionpack (8.1.3) sha256=af998cae4d47c5d581a2cc363b5c77eb718b7c4b45748d81b1887b25621c29a3 + actiontext (8.1.3) sha256=d291019c00e1ea9e6463011fa214f6081a56d7b9a1d224e7d3f6384c1dafc7d2 + actionview (8.1.3) sha256=1347c88c7f3edb38100c5ce0e9fb5e62d7755f3edc1b61cce2eb0b2c6ea2fd5d + activejob (8.1.3) sha256=a149b1766aa8204c3c3da7309e4becd40fcd5529c348cffbf6c9b16b565fe8d3 + activemodel (8.1.3) sha256=90c05cbe4cef3649b8f79f13016191ea94c4525ce4a5c0fb7ef909c4b91c8219 + activerecord (8.1.3) sha256=8003be7b2466ba0a2a670e603eeb0a61dd66058fccecfc49901e775260ac70ab + activestorage (8.1.3) sha256=0564ce9309143951a67615e1bb4e090ee54b8befed417133cae614479b46384d + activesupport (8.1.3) sha256=21a5e0dfbd4c3ddd9e1317ec6a4d782fa226e7867dc70b0743acda81a1dca20e + addressable (2.9.0) sha256=7fdf6ac3660f7f4e867a0838be3f6cf722ace541dd97767fa42bc6cfa980c7af + ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383 + base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b + bcrypt_pbkdf (1.1.2) sha256=c2414c23ce66869b3eb9f643d6a3374d8322dfb5078125c82792304c10b94cf6 + bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd + bindex (0.8.1) sha256=7b1ecc9dc539ed8bccfc8cb4d2732046227b09d6f37582ff12e50a5047ceb17e + bootsnap (1.24.4) sha256=a4d939fc2cc5242a83d3a7cb4fb97743ac58475afe91e0600479a3df6f117541 + brakeman (8.0.4) sha256=7bf921fa9638544835df9aa7b3e720a9a72c0267f34f92135955edd80d4dcf6f + builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f + bundler-audit (0.9.3) sha256=81c8766c71e47d0d28a0f98c7eed028539f21a6ea3cd8f685eb6f42333c9b4e9 + capybara (3.40.0) sha256=42dba720578ea1ca65fd7a41d163dd368502c191804558f6e0f71b391054aeef + concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab + connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a + crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d + cucumber (10.2.0) sha256=fdedbd31ecf40858b60f04853f2aa15c44f5c30bbac29c6a227fa1e7005a8158 + cucumber-ci-environment (11.0.0) sha256=0df79a9e1d0b015b3d9def680f989200d96fef206f4d19ccf86a338c4f71d1e2 + cucumber-core (16.2.0) sha256=592b58a95cf42feef8e5a349f68e363784ba3b6568ffbcf6776e38e136cf970b + cucumber-cucumber-expressions (19.0.0) sha256=33208ff204732ac9bed42b46993a0a243054f71ece08579d57e53df6a1c9d93a + cucumber-gherkin (39.1.0) sha256=aed12a0c955d8563d80a012633c1a72075525f4d64d4cc983001df2181b379ed + cucumber-html-formatter (22.3.0) sha256=f9768ed05588dbd73a5f3824c2cc648bd86b00206e6972d743af8051281d0729 + cucumber-messages (32.3.1) sha256=ddc88e4c1cf7afb96c06005b92a4a6f221a2fa435a8b4ca04677d215fd82771c + cucumber-rails (4.0.1) sha256=bd3513ec47dc06188cc05703648cbc3560fb115f3f5cfb8b616065b4d6e8024d + cucumber-tag-expressions (8.1.0) sha256=9bd8c4b6654f8e5bf2a9c99329b6f32136a75e50cd39d4cfb3927d0fa9f52e21 + database_cleaner (2.1.0) sha256=1dcba26e3b1576da692fc6bac10136a4744da5bcc293d248aae19640c65d89cd + database_cleaner-active_record (2.2.2) sha256=88296b9f3088c31f7c0d4fcec10f68e4b71c96698043916de59b04debec10388 + database_cleaner-core (2.0.1) sha256=8646574c32162e59ed7b5258a97a208d3c44551b854e510994f24683865d846c + date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0 + debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6 + diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962 + dotenv (3.2.0) sha256=e375b83121ea7ca4ce20f214740076129ab8514cd81378161f11c03853fe619d + drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373 + ed25519 (1.4.0) sha256=16e97f5198689a154247169f3453ef4cfd3f7a47481fde0ae33206cdfdcac506 + erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9 + erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9 + et-orbi (1.4.0) sha256=6c7e3c90779821f9e3b324c5e96fda9767f72995d6ae435b96678a4f3e2de8bc + ffi (1.17.4-aarch64-linux-gnu) sha256=b208f06f91ffd8f5e1193da3cae3d2ccfc27fc36fba577baf698d26d91c080df + ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39 + ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564 + ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95 + ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b + ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d + ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e + fugit (1.12.1) sha256=5898f478ede9b415f0804e42b8f3fd53f814bd85eebffceebdbc34e1107aaf68 + globalid (1.3.0) sha256=05c639ad6eb4594522a0b07983022f04aa7254626ab69445a0e493aa3786ff11 + i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5 + image_processing (1.14.0) sha256=754cc169c9c262980889bec6bfd325ed1dafad34f85242b5a07b60af004742fb + importmap-rails (2.2.3) sha256=7101be2a4dc97cf1558fb8f573a718404c5f6bcfe94f304bf1f39e444feeb16a + io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc + irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3 + jbuilder (2.15.0) sha256=fe36cd45b47dd88cb2cbebc3adc4348f041825f580d503578594e8255817f889 + json (2.19.5) sha256=218a18553e4801d579ca7e0f5bc72bafd776d7397238a1fb4e74db5b0a812c59 + kamal (2.11.0) sha256=1408864425e0dec7e0a14d712a3b13f614e9f3a425b7661d3f9d287a51d7dd75 + language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc + lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87 + logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203 + loofah (2.25.1) sha256=d436c73dbd0c1147b16c4a41db097942d217303e1f7728704b37e4df9f6d2e04 + mail (2.9.0) sha256=6fa6673ecd71c60c2d996260f9ee3dd387d4673b8169b502134659ece6d34941 + marcel (1.2.1) sha256=1678e9360e32f9eafa917c80029e2f6d10b2715c66a4b87b6d0da9b9cd1f859f + matrix (0.4.3) sha256=a0d5ab7ddcc1973ff690ab361b67f359acbb16958d1dc072b8b956a286564c5b + memoist3 (1.0.0) sha256=686e42402cf150a362050c23143dc57b0ef88f8c344943ff8b7845792b50d56f + mini_magick (5.3.1) sha256=29395dfd76badcabb6403ee5aff6f681e867074f8f28ce08d78661e9e4a351c4 + mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef + minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1 + msgpack (1.8.0) sha256=e64ce0212000d016809f5048b48eb3a65ffb169db22238fb4b72472fecb2d732 + multi_test (1.1.0) sha256=e9e550cdd863fb72becfe344aefdcd4cbd26ebf307847f4a6c039a4082324d10 + mysql2 (0.5.7) sha256=ba09ede515a0ae8a7192040a1b778c0fb0f025fa5877e9be895cd325fa5e9d7b + net-imap (0.6.4) sha256=9a5598c67a3022c284d98430ef1d4948e7dbdb62596f61081ea8ca933270a02b + net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3 + net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8 + net-scp (4.1.0) sha256=a99b0b92a1e5d360b0de4ffbf2dc0c91531502d3d4f56c28b0139a7c093d1a5d + net-sftp (4.0.0) sha256=65bb91c859c2f93b09826757af11b69af931a3a9155050f50d1b06d384526364 + net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736 + net-ssh (7.3.2) sha256=65029e213c380e20e5fd92ece663934ab0a0fe888e0cd7cc6a5b664074362dd4 + nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1 + nokogiri (1.19.3-aarch64-linux-gnu) sha256=46b89e5d7b9e844c2ee360794240c6ea2a4e6fa0c5892a4ed487db621224b639 + nokogiri (1.19.3-aarch64-linux-musl) sha256=8392dfdcd21be7a94dbbe9ccc138dea01b97b24cb2dc02a114ca98bfb1d9a0b7 + nokogiri (1.19.3-arm-linux-gnu) sha256=3919d5ffc334ad778a4a9eb88fda7dcb8b1fb58c8a52ac640c6dcd2f038e774f + nokogiri (1.19.3-arm-linux-musl) sha256=9ce1cb6346bb9c67b1550eb537aa183ead91e4b6eadb2f36ade02d8dd2a79fb6 + nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42 + nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976 + nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f + ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912 + parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356 + parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54 + pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6 + prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193 + prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85 + propshaft (1.3.2) sha256=1d56a3e56a92c21bfc29caf07406b5386b00d4c47ddf357cf989a5a234b1389e + psych (5.3.1) sha256=eb7a57cef10c9d70173ff74e739d843ac3b2c019a003de48447b2963d81b1974 + public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623 + puma (8.0.1) sha256=7b94e50c07655718c1fb8ae41a11fc06c7d61293208b3aa608ff71a46d3ad37c + raabro (1.4.0) sha256=d4fa9ff5172391edb92b242eed8be802d1934b1464061ae5e70d80962c5da882 + racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f + rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2 + rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8 + rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463 + rackup (2.3.1) sha256=6c79c26753778e90983761d677a48937ee3192b3ffef6bc963c0950f94688868 + rails (8.1.3) sha256=6d017ba5348c98fc909753a8169b21d44de14d2a0b92d140d1a966834c3c9cd3 + rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d + rails-html-sanitizer (1.7.0) sha256=28b145cceaf9cc214a9874feaa183c3acba036c9592b19886e0e45efc62b1e89 + railties (8.1.3) sha256=913eb0e0cb520aac687ffd74916bd726d48fa21f47833c6292576ef6a286de22 + rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a + rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701 + rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192 + regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb + reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835 + rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142 + rubocop (1.86.2) sha256=bb2e97f635eda42c448f2588f4a6ff78f221b8bdfdf65b1e9b07fbd57521b45d + rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035 + rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834 + rubocop-rails (2.35.2) sha256=088865be9675922a5c8f13c00055a71ab768ea5eed211437cffd2a8b46b64ac2 + rubocop-rails-omakase (1.1.0) sha256=2af73ac8ee5852de2919abbd2618af9c15c19b512c4cfc1f9a5d3b6ef009109d + ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33 + ruby-vips (2.3.0) sha256=e685ec02c13969912debbd98019e50492e12989282da5f37d05f5471442f5374 + rubyzip (3.3.0) sha256=a372fc67892a4f8c0bc8ec906b720353d8e48807a64b2e63adf99b1e3583a034 + securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1 + selenium-webdriver (4.44.0) sha256=6f1df072529af369589c46f0e01132952aabb250cfd683c274d74dc1eb5d8477 + solid_cable (3.0.12) sha256=a168a54731a455d5627af48d8441ea3b554b8c1f6e6cd6074109de493e6b0460 + solid_cache (1.0.10) sha256=bc05a2fb3ac78a6f43cbb5946679cf9db67dd30d22939ededc385cb93e120d41 + solid_queue (1.4.0) sha256=e6a18d196f0b27cb6e3c77c5b31258b05fb634f8ed64fb1866ed164047216c2a + sshkit (1.25.0) sha256=c8c6543cdb60f91f1d277306d585dd11b6a064cb44eab0972827e4311ff96744 + stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06 + stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1 + sys-uname (1.5.1) sha256=784d7e6491b0393c25cbbe5ac38324ac7be9fda083a6094832648af669386d7b + thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 + thruster (0.1.21) sha256=dc67928f36e5894844579a95e45637a5091db7a7ea05468ee8c2c6eb0a3f77cf + thruster (0.1.21-aarch64-linux) sha256=f5aff78fb7a6431ed3d6ab4bde03a89c461e9a73981dbc97d6990d85c3db235c + thruster (0.1.21-arm64-darwin) sha256=bd8db9f57fae2cbb3fe08ebab49cb47fe49608122dac23daf0ce709adfb9bfc8 + thruster (0.1.21-x86_64-linux) sha256=6e2fbcf826540a72d3710ae4db072c2333287ac2ee57e7e52f35bc10900d74a7 + timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb + tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f + turbo-rails (2.0.23) sha256=ee0d90733aafff056cf51ff11e803d65e43cae258cc55f6492020ec1f9f9315f + tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b + unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42 + unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f + uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6 + useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844 + web-console (4.3.0) sha256=e13b71301cdfc2093f155b5aa3a622db80b4672d1f2f713119cc7ec7ac6a6da4 + websocket (1.2.11) sha256=b7e7a74e2410b5e85c25858b26b3322f29161e300935f70a0e0d3c35e0462737 + websocket-driver (0.8.0) sha256=ed0dba4b943c22f17f9a734817e808bc84cdce6a7e22045f5315aa57676d4962 + websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241 + xpath (3.2.0) sha256=6dfda79d91bb3b949b947ecc5919f042ef2f399b904013eb3ef6d20dd3a4082e + zeitwerk (2.8.1) sha256=1c85e0f28954d68cd16e575da37f26846f609b68d80b5942ccfd31030c2449d5 + +BUNDLED WITH + 4.0.10 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000000..9a5ea7383a --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative "config/application" + +Rails.application.load_tasks diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000000..fe93333c0f --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,10 @@ +/* + * This is a manifest file that'll be compiled into application.css. + * + * With Propshaft, assets are served efficiently without preprocessing steps. You can still include + * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard + * cascading order, meaning styles declared later in the document or manifest will override earlier ones, + * depending on specificity. + * + * Consider organizing styles into separate files for maintainability. + */ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000000..c3537563da --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,7 @@ +class ApplicationController < ActionController::Base + # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. + allow_browser versions: :modern + + # Changes to the importmap will invalidate the etag for HTML responses + stale_when_importmap_changes +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000000..de6be7945c --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/javascript/application.js b/app/javascript/application.js new file mode 100644 index 0000000000..0d7b49404c --- /dev/null +++ b/app/javascript/application.js @@ -0,0 +1,3 @@ +// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails +import "@hotwired/turbo-rails" +import "controllers" diff --git a/app/javascript/controllers/application.js b/app/javascript/controllers/application.js new file mode 100644 index 0000000000..1213e85c7a --- /dev/null +++ b/app/javascript/controllers/application.js @@ -0,0 +1,9 @@ +import { Application } from "@hotwired/stimulus" + +const application = Application.start() + +// Configure Stimulus development experience +application.debug = false +window.Stimulus = application + +export { application } diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js new file mode 100644 index 0000000000..5975c0789d --- /dev/null +++ b/app/javascript/controllers/hello_controller.js @@ -0,0 +1,7 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + connect() { + this.element.textContent = "Hello World!" + } +} diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js new file mode 100644 index 0000000000..1156bf8362 --- /dev/null +++ b/app/javascript/controllers/index.js @@ -0,0 +1,4 @@ +// Import and register all your controllers from the importmap via controllers/**/*_controller +import { application } from "controllers/application" +import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" +eagerLoadControllersFrom("controllers", application) diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 0000000000..d394c3d106 --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,7 @@ +class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 0000000000..3c34c8148f --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: "from@example.com" + layout "mailer" +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000000..b63caeb8a5 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + primary_abstract_class +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000000..9e51e3817f --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,29 @@ + + + + <%= content_for(:title) || "Camaar" %> + + + + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= yield :head %> + + <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %> + <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %> + + + + + + <%# Includes all stylesheet files in app/assets/stylesheets %> + <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %> + <%= javascript_importmap_tags %> + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000000..3aac9002ed --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000000..37f0bddbd7 --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/app/views/pwa/manifest.json.erb b/app/views/pwa/manifest.json.erb new file mode 100644 index 0000000000..fca522bbe4 --- /dev/null +++ b/app/views/pwa/manifest.json.erb @@ -0,0 +1,22 @@ +{ + "name": "Camaar", + "icons": [ + { + "src": "/icon.png", + "type": "image/png", + "sizes": "512x512" + }, + { + "src": "/icon.png", + "type": "image/png", + "sizes": "512x512", + "purpose": "maskable" + } + ], + "start_url": "/", + "display": "standalone", + "scope": "/", + "description": "Camaar.", + "theme_color": "red", + "background_color": "red" +} diff --git a/app/views/pwa/service-worker.js b/app/views/pwa/service-worker.js new file mode 100644 index 0000000000..b3a13fb7bb --- /dev/null +++ b/app/views/pwa/service-worker.js @@ -0,0 +1,26 @@ +// Add a service worker for processing Web Push notifications: +// +// self.addEventListener("push", async (event) => { +// const { title, options } = await event.data.json() +// event.waitUntil(self.registration.showNotification(title, options)) +// }) +// +// self.addEventListener("notificationclick", function(event) { +// event.notification.close() +// event.waitUntil( +// clients.matchAll({ type: "window" }).then((clientList) => { +// for (let i = 0; i < clientList.length; i++) { +// let client = clientList[i] +// let clientPath = (new URL(client.url)).pathname +// +// if (clientPath == event.notification.data.path && "focus" in client) { +// return client.focus() +// } +// } +// +// if (clients.openWindow) { +// return clients.openWindow(event.notification.data.path) +// } +// }) +// ) +// }) diff --git a/bin/brakeman b/bin/brakeman new file mode 100755 index 0000000000..ace1c9ba08 --- /dev/null +++ b/bin/brakeman @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +ARGV.unshift("--ensure-latest") + +load Gem.bin_path("brakeman", "brakeman") diff --git a/bin/bundler-audit b/bin/bundler-audit new file mode 100755 index 0000000000..e2ef22690c --- /dev/null +++ b/bin/bundler-audit @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "bundler/audit/cli" + +ARGV.concat %w[ --config config/bundler-audit.yml ] if ARGV.empty? || ARGV.include?("check") +Bundler::Audit::CLI.start diff --git a/bin/ci b/bin/ci new file mode 100755 index 0000000000..4137ad5bb0 --- /dev/null +++ b/bin/ci @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "active_support/continuous_integration" + +CI = ActiveSupport::ContinuousIntegration +require_relative "../config/ci.rb" diff --git a/bin/cucumber b/bin/cucumber new file mode 100755 index 0000000000..eb5e962e86 --- /dev/null +++ b/bin/cucumber @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first +if vendored_cucumber_bin + load File.expand_path(vendored_cucumber_bin) +else + require 'rubygems' unless ENV['NO_RUBYGEMS'] + require 'cucumber' + load Cucumber::BINARY +end diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000000..5f91c20545 --- /dev/null +++ b/bin/dev @@ -0,0 +1,2 @@ +#!/usr/bin/env ruby +exec "./bin/rails", "server", *ARGV diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint new file mode 100755 index 0000000000..ed31659f40 --- /dev/null +++ b/bin/docker-entrypoint @@ -0,0 +1,8 @@ +#!/bin/bash -e + +# If running the rails server then create or migrate existing database +if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then + ./bin/rails db:prepare +fi + +exec "${@}" diff --git a/bin/importmap b/bin/importmap new file mode 100755 index 0000000000..36502ab16c --- /dev/null +++ b/bin/importmap @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +require_relative "../config/application" +require "importmap/commands" diff --git a/bin/jobs b/bin/jobs new file mode 100755 index 0000000000..dcf59f309a --- /dev/null +++ b/bin/jobs @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +require_relative "../config/environment" +require "solid_queue/cli" + +SolidQueue::Cli.start(ARGV) diff --git a/bin/kamal b/bin/kamal new file mode 100755 index 0000000000..d9ba276702 --- /dev/null +++ b/bin/kamal @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'kamal' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("kamal", "kamal") diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000000..efc0377492 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000000..4fbf10b960 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "rake" +Rake.application.run diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000000..5a20504716 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +# Explicit RuboCop config increases performance slightly while avoiding config confusion. +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000000..81be011e87 --- /dev/null +++ b/bin/setup @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +require "fileutils" + +APP_ROOT = File.expand_path("..", __dir__) + +def system!(*args) + system(*args, exception: true) +end + +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. + # Add necessary setup steps to this file. + + puts "== Installing dependencies ==" + system("bundle check") || system!("bundle install") + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" + # end + + puts "\n== Preparing database ==" + system! "bin/rails db:prepare" + system! "bin/rails db:reset" if ARGV.include?("--reset") + + puts "\n== Removing old logs and tempfiles ==" + system! "bin/rails log:clear tmp:clear" + + unless ARGV.include?("--skip-server") + puts "\n== Starting development server ==" + STDOUT.flush # flush the output before exec(2) so that it displays + exec "bin/dev" + end +end diff --git a/bin/thrust b/bin/thrust new file mode 100755 index 0000000000..36bde2d832 --- /dev/null +++ b/bin/thrust @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("thruster", "thrust") diff --git a/config.ru b/config.ru new file mode 100644 index 0000000000..4a3c09a688 --- /dev/null +++ b/config.ru @@ -0,0 +1,6 @@ +# This file is used by Rack-based servers to start the application. + +require_relative "config/environment" + +run Rails.application +Rails.application.load_server diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000000..b4848d838b --- /dev/null +++ b/config/application.rb @@ -0,0 +1,27 @@ +require_relative "boot" + +require "rails/all" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Camaar + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 8.1 + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w[assets tasks]) + + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000000..988a5ddc46 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,4 @@ +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/bundler-audit.yml b/config/bundler-audit.yml new file mode 100644 index 0000000000..e74b3af949 --- /dev/null +++ b/config/bundler-audit.yml @@ -0,0 +1,5 @@ +# Audit all gems listed in the Gemfile for known security problems by running bin/bundler-audit. +# CVEs that are not relevant to the application can be enumerated on the ignore list below. + +ignore: + - CVE-THAT-DOES-NOT-APPLY diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000000..b9adc5aa3a --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,17 @@ +# Async adapter only works within the same process, so for manually triggering cable updates from a console, +# and seeing results in the browser, you must do so from the web console (running inside the dev process), +# not a terminal started via bin/rails console! Add "console" to any action or any ERB template view +# to make the web console appear. +development: + adapter: async + +test: + adapter: test + +production: + adapter: solid_cable + connects_to: + database: + writing: cable + polling_interval: 0.1.seconds + message_retention: 1.day diff --git a/config/cache.yml b/config/cache.yml new file mode 100644 index 0000000000..19d490843b --- /dev/null +++ b/config/cache.yml @@ -0,0 +1,16 @@ +default: &default + store_options: + # Cap age of oldest cache entry to fulfill retention policies + # max_age: <%= 60.days.to_i %> + max_size: <%= 256.megabytes %> + namespace: <%= Rails.env %> + +development: + <<: *default + +test: + <<: *default + +production: + database: cache + <<: *default diff --git a/config/ci.rb b/config/ci.rb new file mode 100644 index 0000000000..1712cc1127 --- /dev/null +++ b/config/ci.rb @@ -0,0 +1,24 @@ +# Run using bin/ci + +CI.run do + step "Setup", "bin/setup --skip-server" + + step "Style: Ruby", "bin/rubocop" + + step "Security: Gem audit", "bin/bundler-audit" + step "Security: Importmap vulnerability audit", "bin/importmap audit" + step "Security: Brakeman code analysis", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error" + step "Tests: Rails", "bin/rails test" + step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant" + + # Optional: Run system tests + # step "Tests: System", "bin/rails test:system" + + # Optional: set a green GitHub commit status to unblock PR merge. + # Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`. + # if success? + # step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff" + # else + # failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again." + # end +end diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 0000000000..09eb287f93 --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +4H8/6nhnfIn9qW6hDXeaYIPA3qXldZwgNhgvx+L1Hn7mBFhEYQcclgYI+WiUqPbhcvtdzm5FkhaDaTb0TfUCfFTkLfIEdJs9kC+pEBilNfOdzMTTT2d6KeVGNO+BSu/dfxec7YQpsiICdabItL3av/dmoSA9KwDP75Ep+RDAQBXllNWAqBy5zIz1Cnb+/q7doDz2oj+F/Or1Go+v32WzZNm7dbJ4AW3EHJw2L8k82sVmawg8x6i2ehcCNHALQZO/lB3nT6IY0ZkkOxzALaUroqVlgEe+695GkTe08bNTPLrE5l4XSs1edC8V47RTO/ieO9EqHxU3hKvpH7Xdot1P0D6WI6G/koAAzzHnE2jvb4VU6UCIkAXs2mp7L954yxqNgEZ9KOymqNOmancSSStMXp7O5KCiiN6BQCx8ydLaNgScImfwC9dWCiquZOv8Km36dAfzE92TbZUNogOxA5Uw7xEIrjH4Jrg7JDBqM34mJnWW1j5ZX+Fz5Zld--9oy00/0iz+TVEIu/--wUtORdaSWiIGCttp56iN7g== \ No newline at end of file diff --git a/config/cucumber.yml b/config/cucumber.yml new file mode 100644 index 0000000000..47a4663ae2 --- /dev/null +++ b/config/cucumber.yml @@ -0,0 +1,8 @@ +<% +rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" +rerun = rerun.strip.gsub /\s/, ' ' +rerun_opts = rerun.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" +std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags 'not @wip'" +%> +default: <%= std_opts %> features +rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags 'not @wip' diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000000..26477427b2 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,74 @@ +# MySQL. Versions 5.6.4 and up are supported. +# +# Install the MySQL driver +# gem install mysql2 +# +# Ensure the MySQL gem is defined in your Gemfile +# gem "mysql2" +# +# And be sure to use new-style password hashing: +# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html +# +default: &default + adapter: mysql2 + encoding: utf8mb4 + max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + username: root + password: + socket: /tmp/mysql.sock + +development: + <<: *default + database: camaar_development + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: camaar_test + +# As with config/credentials.yml, you never want to store sensitive information, +# like your database password, in your source code. If your source code is +# ever seen by anyone, they now have access to your database. +# +# Instead, provide the password or a full connection URL as an environment +# variable when you boot the app. For example: +# +# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" +# +# If the connection URL is provided in the special DATABASE_URL environment +# variable, Rails will automatically merge its configuration values on top of +# the values provided in this file. Alternatively, you can specify a connection +# URL environment variable explicitly: +# +# production: +# url: <%= ENV["MY_APP_DATABASE_URL"] %> +# +# Connection URLs for non-primary databases can also be configured using +# environment variables. The variable name is formed by concatenating the +# connection name with `_DATABASE_URL`. For example: +# +# CACHE_DATABASE_URL="mysql2://cacheuser:cachepass@localhost/cachedatabase" +# +# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database +# for a full overview on how database connection configuration can be specified. +# +production: + primary: &primary_production + <<: *default + database: camaar_production + username: camaar + password: <%= ENV["CAMAAR_DATABASE_PASSWORD"] %> + cache: + <<: *primary_production + database: camaar_production_cache + migrations_paths: db/cache_migrate + queue: + <<: *primary_production + database: camaar_production_queue + migrations_paths: db/queue_migrate + cable: + <<: *primary_production + database: camaar_production_cable + migrations_paths: db/cable_migrate diff --git a/config/deploy.yml b/config/deploy.yml new file mode 100644 index 0000000000..501ac950fe --- /dev/null +++ b/config/deploy.yml @@ -0,0 +1,119 @@ +# Name of your application. Used to uniquely configure containers. +service: camaar + +# Name of the container image (use your-user/app-name on external registries). +image: camaar + +# Deploy to these servers. +servers: + web: + - 192.168.0.1 + # job: + # hosts: + # - 192.168.0.1 + # cmd: bin/jobs + +# Enable SSL auto certification via Let's Encrypt and allow for multiple apps on a single web server. +# If used with Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption. +# +# Using an SSL proxy like this requires turning on config.assume_ssl and config.force_ssl in production.rb! +# +# Don't use this when deploying to multiple web servers (then you have to terminate SSL at your load balancer). +# +# proxy: +# ssl: true +# host: app.example.com + +# Where you keep your container images. +registry: + # Alternatives: hub.docker.com / registry.digitalocean.com / ghcr.io / ... + server: localhost:5555 + + # Needed for authenticated registries. + # username: your-user + + # Always use an access token rather than real password when possible. + # password: + # - KAMAL_REGISTRY_PASSWORD + +# Inject ENV variables into containers (secrets come from .kamal/secrets). +env: + secret: + - RAILS_MASTER_KEY + clear: + # Run the Solid Queue Supervisor inside the web server's Puma process to do jobs. + # When you start using multiple servers, you should split out job processing to a dedicated machine. + SOLID_QUEUE_IN_PUMA: true + + # Set number of processes dedicated to Solid Queue (default: 1) + # JOB_CONCURRENCY: 3 + + # Set number of cores available to the application on each server (default: 1). + # WEB_CONCURRENCY: 2 + + # Match this to any external database server to configure Active Record correctly + # Use camaar-db for a db accessory server on same machine via local kamal docker network. + # DB_HOST: 192.168.0.2 + + # Log everything from Rails + # RAILS_LOG_LEVEL: debug + +# Aliases are triggered with "bin/kamal ". You can overwrite arguments on invocation: +# "bin/kamal logs -r job" will tail logs from the first server in the job section. +aliases: + console: app exec --interactive --reuse "bin/rails console" + shell: app exec --interactive --reuse "bash" + logs: app logs -f + dbc: app exec --interactive --reuse "bin/rails dbconsole --include-password" + +# Use a persistent storage volume for sqlite database files and local Active Storage files. +# Recommended to change this to a mounted volume path that is backed up off server. +volumes: + - "camaar_storage:/rails/storage" + +# Bridge fingerprinted assets, like JS and CSS, between versions to avoid +# hitting 404 on in-flight requests. Combines all files from new and old +# version inside the asset_path. +asset_path: /rails/public/assets + +# Configure the image builder. +builder: + arch: amd64 + + # # Build image via remote server (useful for faster amd64 builds on arm64 computers) + # remote: ssh://docker@docker-builder-server + # + # # Pass arguments and secrets to the Docker build process + # args: + # RUBY_VERSION: 4.0.2 + # secrets: + # - GITHUB_TOKEN + # - RAILS_MASTER_KEY + +# Use a different ssh user than root +# ssh: +# user: app + +# Use accessory services (secrets come from .kamal/secrets). +# accessories: +# db: +# image: mysql:8.0 +# host: 192.168.0.2 +# # Change to 3306 to expose port to the world instead of just local network. +# port: "127.0.0.1:3306:3306" +# env: +# clear: +# MYSQL_ROOT_HOST: '%' +# secret: +# - MYSQL_ROOT_PASSWORD +# files: +# - config/mysql/production.cnf:/etc/mysql/my.cnf +# - db/production.sql:/docker-entrypoint-initdb.d/setup.sql +# directories: +# - data:/var/lib/mysql +# redis: +# image: valkey/valkey:8 +# host: 192.168.0.2 +# port: 6379 +# directories: +# - data:/data diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000000..cac5315775 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000000..7d1b179ef2 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,82 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Configure 'rails notes' to inspect Cucumber files + config.annotations.register_directories('features') + config.annotations.register_extensions('feature') { |tag| /#\s*(#{tag}):?\s*(.*)$/ } + + # Settings specified here will take precedence over those in config/application.rb. + + # Make code changes take effect immediately without server restart. + config.enable_reloading = true + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing. + config.server_timing = true + + # Enable/disable Action Controller caching. By default Action Controller caching is disabled. + # Run rails dev:cache to toggle Action Controller caching. + if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" } + else + config.action_controller.perform_caching = false + end + + # Change to :null_store to avoid any caching. + config.cache_store = :memory_store + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Make template changes take effect immediately. + config.action_mailer.perform_caching = false + + # Set localhost to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "localhost", port: 3000 } + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Append comments with runtime information tags to SQL queries in logs. + config.active_record.query_log_tags_enabled = true + + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + + # Highlight code that triggered redirect in logs. + config.action_dispatch.verbose_redirect_logs = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + config.action_view.annotate_rendered_view_with_filenames = true + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true + + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + # config.generators.apply_rubocop_autocorrect_after_generate! +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000000..f5763e04e5 --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,90 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.enable_reloading = false + + # Eager load code on boot for better performance and memory savings (ignored by Rake tasks). + config.eager_load = true + + # Full error reports are disabled. + config.consider_all_requests_local = false + + # Turn on fragment caching in view templates. + config.action_controller.perform_caching = true + + # Cache assets for far-future expiry since they are all digest stamped. + config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" } + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # config.assume_ssl = true + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } + + # Log to STDOUT with the current request id as a default log tag. + config.log_tags = [ :request_id ] + config.logger = ActiveSupport::TaggedLogging.logger(STDOUT) + + # Change to "debug" to log everything (including potentially personally-identifiable information!). + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + + # Prevent health checks from clogging up the logs. + config.silence_healthcheck_path = "/up" + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Replace the default in-process memory cache store with a durable alternative. + config.cache_store = :solid_cache_store + + # Replace the default in-process and non-durable queuing backend for Active Job. + config.active_job.queue_adapter = :solid_queue + config.solid_queue.connects_to = { database: { writing: :queue } } + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "example.com" } + + # Specify outgoing SMTP server. Remember to add smtp/* credentials via bin/rails credentials:edit. + # config.action_mailer.smtp_settings = { + # user_name: Rails.application.credentials.dig(:smtp, :user_name), + # password: Rails.application.credentials.dig(:smtp, :password), + # address: "smtp.example.com", + # port: 587, + # authentication: :plain + # } + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + # Only use :id for inspections in production. + config.active_record.attributes_for_inspect = [ :id ] + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000000..e6b5c1b020 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,57 @@ +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Configure 'rails notes' to inspect Cucumber files + config.annotations.register_directories('features') + config.annotations.register_extensions('feature') { |tag| /#\s*(#{tag}):?\s*(.*)$/ } + + # Settings specified here will take precedence over those in config/application.rb. + + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false + + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV["CI"].present? + + # Configure public file server for tests with cache-control for performance. + config.public_file_server.headers = { "cache-control" => "public, max-age=3600" } + + # Show full error reports. + config.consider_all_requests_local = true + config.cache_store = :null_store + + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "example.com" } + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true +end diff --git a/config/importmap.rb b/config/importmap.rb new file mode 100644 index 0000000000..909dfc542d --- /dev/null +++ b/config/importmap.rb @@ -0,0 +1,7 @@ +# Pin npm packages by running ./bin/importmap + +pin "application" +pin "@hotwired/turbo-rails", to: "turbo.min.js" +pin "@hotwired/stimulus", to: "stimulus.min.js" +pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" +pin_all_from "app/javascript/controllers", under: "controllers" diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000000..487324424f --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = "1.0" + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 0000000000..d51d713979 --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,29 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src style-src) +# +# # Automatically add `nonce` to `javascript_tag`, `javascript_include_tag`, and `stylesheet_link_tag` +# # if the corresponding directives are specified in `content_security_policy_nonce_directives`. +# # config.content_security_policy_nonce_auto = true +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000000..c0b717f7ec --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. +Rails.application.config.filter_parameters += [ + :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc +] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000000..3860f659ea --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym "RESTful" +# end diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000000..6c349ae5e3 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,31 @@ +# Files in the config/locales directory are used for internationalization and +# are automatically loaded by Rails. If you want to use locales other than +# English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t "hello" +# +# In views, this is aliased to just `t`: +# +# <%= t("hello") %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more about the API, please read the Rails Internationalization guide +# at https://guides.rubyonrails.org/i18n.html. +# +# Be aware that YAML interprets the following case-insensitive strings as +# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings +# must be quoted to be interpreted as strings. For example: +# +# en: +# "yes": yup +# enabled: "ON" + +en: + hello: "Hello world" diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000000..38c4b86596 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,42 @@ +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. +# +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. +# +# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You +# should only set this value when you want to run 2 or more workers. The +# default is already 1. You can set it to `auto` to automatically start a worker +# for each available processor. +# +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# prioritize throughput over latency. +# +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. +# +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. +# +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +port ENV.fetch("PORT", 3000) + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart + +# Run the Solid Queue supervisor inside of Puma for single-server deployments. +plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] + +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +pidfile ENV["PIDFILE"] if ENV["PIDFILE"] diff --git a/config/queue.yml b/config/queue.yml new file mode 100644 index 0000000000..9eace59c41 --- /dev/null +++ b/config/queue.yml @@ -0,0 +1,18 @@ +default: &default + dispatchers: + - polling_interval: 1 + batch_size: 500 + workers: + - queues: "*" + threads: 3 + processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %> + polling_interval: 0.1 + +development: + <<: *default + +test: + <<: *default + +production: + <<: *default diff --git a/config/recurring.yml b/config/recurring.yml new file mode 100644 index 0000000000..b4207f9b07 --- /dev/null +++ b/config/recurring.yml @@ -0,0 +1,15 @@ +# examples: +# periodic_cleanup: +# class: CleanSoftDeletedRecordsJob +# queue: background +# args: [ 1000, { batch_size: 500 } ] +# schedule: every hour +# periodic_cleanup_with_command: +# command: "SoftDeletedRecord.due.delete_all" +# priority: 2 +# schedule: at 5am every day + +production: + clear_solid_queue_finished_jobs: + command: "SolidQueue::Job.clear_finished_in_batches(sleep_between_batches: 0.3)" + schedule: every hour at minute 12 diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000000..48254e88ed --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,14 @@ +Rails.application.routes.draw do + # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html + + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. + # Can be used by load balancers and uptime monitors to verify that the app is live. + get "up" => "rails/health#show", as: :rails_health_check + + # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) + # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest + # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker + + # Defines the root path route ("/") + # root "posts#index" +end diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 0000000000..927dc537c8 --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,27 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket-<%= Rails.env %> + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket-<%= Rails.env %> + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/db/cable_schema.rb b/db/cable_schema.rb new file mode 100644 index 0000000000..23666604a5 --- /dev/null +++ b/db/cable_schema.rb @@ -0,0 +1,11 @@ +ActiveRecord::Schema[7.1].define(version: 1) do + create_table "solid_cable_messages", force: :cascade do |t| + t.binary "channel", limit: 1024, null: false + t.binary "payload", limit: 536870912, null: false + t.datetime "created_at", null: false + t.integer "channel_hash", limit: 8, null: false + t.index ["channel"], name: "index_solid_cable_messages_on_channel" + t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash" + t.index ["created_at"], name: "index_solid_cable_messages_on_created_at" + end +end diff --git a/db/cache_schema.rb b/db/cache_schema.rb new file mode 100644 index 0000000000..81a410d188 --- /dev/null +++ b/db/cache_schema.rb @@ -0,0 +1,12 @@ +ActiveRecord::Schema[7.2].define(version: 1) do + create_table "solid_cache_entries", force: :cascade do |t| + t.binary "key", limit: 1024, null: false + t.binary "value", limit: 536870912, null: false + t.datetime "created_at", null: false + t.integer "key_hash", limit: 8, null: false + t.integer "byte_size", limit: 4, null: false + t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size" + t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size" + t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true + end +end diff --git a/db/queue_schema.rb b/db/queue_schema.rb new file mode 100644 index 0000000000..85194b6a88 --- /dev/null +++ b/db/queue_schema.rb @@ -0,0 +1,129 @@ +ActiveRecord::Schema[7.1].define(version: 1) do + create_table "solid_queue_blocked_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.string "concurrency_key", null: false + t.datetime "expires_at", null: false + t.datetime "created_at", null: false + t.index [ "concurrency_key", "priority", "job_id" ], name: "index_solid_queue_blocked_executions_for_release" + t.index [ "expires_at", "concurrency_key" ], name: "index_solid_queue_blocked_executions_for_maintenance" + t.index [ "job_id" ], name: "index_solid_queue_blocked_executions_on_job_id", unique: true + end + + create_table "solid_queue_claimed_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.bigint "process_id" + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_claimed_executions_on_job_id", unique: true + t.index [ "process_id", "job_id" ], name: "index_solid_queue_claimed_executions_on_process_id_and_job_id" + end + + create_table "solid_queue_failed_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.text "error" + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_failed_executions_on_job_id", unique: true + end + + create_table "solid_queue_jobs", force: :cascade do |t| + t.string "queue_name", null: false + t.string "class_name", null: false + t.text "arguments" + t.integer "priority", default: 0, null: false + t.string "active_job_id" + t.datetime "scheduled_at" + t.datetime "finished_at" + t.string "concurrency_key" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index [ "active_job_id" ], name: "index_solid_queue_jobs_on_active_job_id" + t.index [ "class_name" ], name: "index_solid_queue_jobs_on_class_name" + t.index [ "finished_at" ], name: "index_solid_queue_jobs_on_finished_at" + t.index [ "queue_name", "finished_at" ], name: "index_solid_queue_jobs_for_filtering" + t.index [ "scheduled_at", "finished_at" ], name: "index_solid_queue_jobs_for_alerting" + end + + create_table "solid_queue_pauses", force: :cascade do |t| + t.string "queue_name", null: false + t.datetime "created_at", null: false + t.index [ "queue_name" ], name: "index_solid_queue_pauses_on_queue_name", unique: true + end + + create_table "solid_queue_processes", force: :cascade do |t| + t.string "kind", null: false + t.datetime "last_heartbeat_at", null: false + t.bigint "supervisor_id" + t.integer "pid", null: false + t.string "hostname" + t.text "metadata" + t.datetime "created_at", null: false + t.string "name", null: false + t.index [ "last_heartbeat_at" ], name: "index_solid_queue_processes_on_last_heartbeat_at" + t.index [ "name", "supervisor_id" ], name: "index_solid_queue_processes_on_name_and_supervisor_id", unique: true + t.index [ "supervisor_id" ], name: "index_solid_queue_processes_on_supervisor_id" + end + + create_table "solid_queue_ready_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_ready_executions_on_job_id", unique: true + t.index [ "priority", "job_id" ], name: "index_solid_queue_poll_all" + t.index [ "queue_name", "priority", "job_id" ], name: "index_solid_queue_poll_by_queue" + end + + create_table "solid_queue_recurring_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "task_key", null: false + t.datetime "run_at", null: false + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_recurring_executions_on_job_id", unique: true + t.index [ "task_key", "run_at" ], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true + end + + create_table "solid_queue_recurring_tasks", force: :cascade do |t| + t.string "key", null: false + t.string "schedule", null: false + t.string "command", limit: 2048 + t.string "class_name" + t.text "arguments" + t.string "queue_name" + t.integer "priority", default: 0 + t.boolean "static", default: true, null: false + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index [ "key" ], name: "index_solid_queue_recurring_tasks_on_key", unique: true + t.index [ "static" ], name: "index_solid_queue_recurring_tasks_on_static" + end + + create_table "solid_queue_scheduled_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.datetime "scheduled_at", null: false + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_scheduled_executions_on_job_id", unique: true + t.index [ "scheduled_at", "priority", "job_id" ], name: "index_solid_queue_dispatch_all" + end + + create_table "solid_queue_semaphores", force: :cascade do |t| + t.string "key", null: false + t.integer "value", default: 1, null: false + t.datetime "expires_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index [ "expires_at" ], name: "index_solid_queue_semaphores_on_expires_at" + t.index [ "key", "value" ], name: "index_solid_queue_semaphores_on_key_and_value" + t.index [ "key" ], name: "index_solid_queue_semaphores_on_key", unique: true + end + + add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_failed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000000..4fbd6ed970 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,9 @@ +# This file should ensure the existence of records required to run the application in every environment (production, +# development, test). The code here should be idempotent so that it can be executed at any point in every environment. +# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). +# +# Example: +# +# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| +# MovieGenre.find_or_create_by!(name: genre_name) +# end diff --git a/features/step_definitions/.keep b/features/step_definitions/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000000..3b97d14087 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,53 @@ +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. +# It is recommended to regenerate this file in the future when you upgrade to a +# newer version of cucumber-rails. Consider adding your own code to a new file +# instead of editing this one. Cucumber will automatically load all features/**/*.rb +# files. + + +require 'cucumber/rails' + +# By default, any exception happening in your Rails application will bubble up +# to Cucumber so that your scenario will fail. This is a different from how +# your application behaves in the production environment, where an error page will +# be rendered instead. +# +# Sometimes we want to override this default behaviour and allow Rails to rescue +# exceptions and display an error page (just like when the app is running in production). +# Typical scenarios where you want to do this is when you test your error pages. +# There are two ways to allow Rails to rescue exceptions: +# +# 1) Tag your scenario (or feature) with @allow-rescue +# +# 2) Set the value below to true. Beware that doing this globally is not +# recommended as it will mask a lot of errors for you! +# +ActionController::Base.allow_rescue = false + +# Remove/comment out the lines below if your app doesn't have a database. +# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. +begin + DatabaseCleaner.strategy = :transaction +rescue NameError + raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." +end + +# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. +# See the DatabaseCleaner documentation for details. Example: +# +# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do +# # { except: [:widgets] } may not do what you expect here +# # as Cucumber::Rails::Database.javascript_strategy overrides +# # this setting. +# DatabaseCleaner.strategy = :truncation +# end +# +# Before('not @no-txn', 'not @selenium', 'not @culerity', 'not @celerity', 'not @javascript') do +# DatabaseCleaner.strategy = :transaction +# end +# + +# Possible values are :truncation and :transaction +# The :transaction strategy is faster, but might give you threading problems. +# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature +Cucumber::Rails::Database.javascript_strategy = :truncation diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake new file mode 100644 index 0000000000..0caa4d2553 --- /dev/null +++ b/lib/tasks/cucumber.rake @@ -0,0 +1,69 @@ +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. +# It is recommended to regenerate this file in the future when you upgrade to a +# newer version of cucumber-rails. Consider adding your own code to a new file +# instead of editing this one. Cucumber will automatically load all features/**/*.rb +# files. + + +unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks + +vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first +$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? + +begin + require 'cucumber/rake/task' + + namespace :cucumber do + Cucumber::Rake::Task.new({ok: 'test:prepare'}, 'Run features that should pass') do |t| + t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. + t.fork = true # You may get faster startup if you set this to false + t.profile = 'default' + end + + Cucumber::Rake::Task.new({wip: 'test:prepare'}, 'Run features that are being worked on') do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = 'wip' + end + + Cucumber::Rake::Task.new({rerun: 'test:prepare'}, 'Record failing features and run only them if any exist') do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = 'rerun' + end + + desc 'Run all features' + task all: [:ok, :wip] + + task :statsetup do + require 'rails/code_statistics' + ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features') + ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features') + end + + end + + desc 'Alias for cucumber:ok' + task cucumber: 'cucumber:ok' + + task default: :cucumber + + task features: :cucumber do + STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" + end + + # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon. + task 'test:prepare' do + end + + task stats: 'cucumber:statsetup' + + +rescue LoadError + desc 'cucumber rake task not available (cucumber not installed)' + task :cucumber do + abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' + end +end + +end diff --git a/log/.keep b/log/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/400.html b/public/400.html new file mode 100644 index 0000000000..640de03397 --- /dev/null +++ b/public/400.html @@ -0,0 +1,135 @@ + + + + + + + The server cannot process the request due to a client error (400 Bad Request) + + + + + + + + + + + + + +
+
+ +
+
+

The server cannot process the request due to a client error. Please check the request and try again. If you're the application owner check the logs for more information.

+
+
+ + + + diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000000..d7f0f14222 --- /dev/null +++ b/public/404.html @@ -0,0 +1,135 @@ + + + + + + + The page you were looking for doesn't exist (404 Not found) + + + + + + + + + + + + + +
+
+ +
+
+

The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved. If you're the application owner check the logs for more information.

+
+
+ + + + diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html new file mode 100644 index 0000000000..43d2811e8c --- /dev/null +++ b/public/406-unsupported-browser.html @@ -0,0 +1,135 @@ + + + + + + + Your browser is not supported (406 Not Acceptable) + + + + + + + + + + + + + +
+
+ +
+
+

Your browser is not supported.
Please upgrade your browser to continue.

+
+
+ + + + diff --git a/public/422.html b/public/422.html new file mode 100644 index 0000000000..f12fb4aa17 --- /dev/null +++ b/public/422.html @@ -0,0 +1,135 @@ + + + + + + + The change you wanted was rejected (422 Unprocessable Entity) + + + + + + + + + + + + + +
+
+ +
+
+

The change you wanted was rejected. Maybe you tried to change something you didn't have access to. If you're the application owner check the logs for more information.

+
+
+ + + + diff --git a/public/500.html b/public/500.html new file mode 100644 index 0000000000..e4eb18a759 --- /dev/null +++ b/public/500.html @@ -0,0 +1,135 @@ + + + + + + + We're sorry, but something went wrong (500 Internal Server Error) + + + + + + + + + + + + + +
+
+ +
+
+

We're sorry, but something went wrong.
If you're the application owner check the logs for more information.

+
+
+ + + + diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c4c9dbfbbd2f7c1421ffd5727188146213abbcef GIT binary patch literal 4166 zcmd6qU;WFw?|v@m)Sk^&NvB8tcujdV-r1b=i(NJxn&7{KTb zX$3(M+3TP2o^#KAo{#tIjl&t~(8D-k004kqPglzn0HFG(Q~(I*AKsD#M*g7!XK0T7 zN6P7j>HcT8rZgKl$v!xr806dyN19Bd4C0x_R*I-a?#zsTvb_89cyhuC&T**i|Rc zq5b8M;+{8KvoJ~uj9`u~d_f6`V&3+&ZX9x5pc8s)d175;@pjm(?dapmBcm0&vl9+W zx1ZD2o^nuyUHWj|^A8r>lUorO`wFF;>9XL-Jy!P}UXC{(z!FO%SH~8k`#|9;Q|eue zqWL0^Bp(fg_+Pkm!fDKRSY;+^@BF?AJE zCUWpXPst~hi_~u)SzYBDZroR+Z4xeHIlm_3Yc_9nZ(o_gg!jDgVa=E}Y8uDgem9`b zf=mfJ_@(BXSkW53B)F2s!&?_R4ptb1fYXlF++@vPhd=marQgEGRZS@B4g1Mu?euknL= z67P~tZ?*>-Hmi7GwlisNHHJDku-dSm7g@!=a}9cSL6Pa^w^2?&?$Oi8ibrr>w)xqx zOH_EMU@m05)9kuNR>>4@H%|){U$^yvVQ(YgOlh;5oU_-vivG-p4=LrN-k7D?*?u1u zsWly%tfAzKd6Fb=`eU2un_uaTXmcT#tlOL+aRS=kZZf}A7qT8lvcTx~7j` z*b>=z)mwg7%B2_!D0!1IZ?Nq{^Y$uI4Qx*6T!E2Col&2{k?ImCO=dD~A&9f9diXy^$x{6CwkBimn|1E09 zAMSezYtiL?O6hS37KpvDM?22&d{l)7h-!F)C-d3j8Z`c@($?mfd{R82)H>Qe`h{~G z!I}(2j(|49{LR?w4Jspl_i!(4T{31|dqCOpI52r5NhxYV+cDAu(xp*4iqZ2e-$YP= zoFOPmm|u*7C?S{Fp43y+V;>~@FFR76bCl@pTtyB93vNWy5yf;HKr8^0d7&GVIslYm zo3Tgt@M!`8B6IW&lK{Xk>%zp41G%`(DR&^u z5^pwD4>E6-w<8Kl2DzJ%a@~QDE$(e87lNhy?-Qgep!$b?5f7+&EM7$e>|WrX+=zCb z=!f5P>MxFyy;mIRxjc(H*}mceXw5a*IpC0PEYJ8Y3{JdoIW)@t97{wcUB@u+$FCCO z;s2Qe(d~oJC^`m$7DE-dsha`glrtu&v&93IZadvl_yjp!c89>zo;Krk+d&DEG4?x$ zufC1n+c1XD7dolX1q|7}uelR$`pT0Z)1jun<39$Sn2V5g&|(j~Z!wOddfYiZo7)A< z!dK`aBHOOk+-E_xbWCA3VR-+o$i5eO9`rMI#p_0xQ}rjEpGW;U!&&PKnivOcG(|m9 z!C8?WC6nCXw25WVa*eew)zQ=h45k8jSIPbq&?VE{oG%?4>9rwEeB4&qe#?-y_es4c|7ufw%+H5EY#oCgv!Lzv291#-oNlX~X+Jl5(riC~r z=0M|wMOP)Tt8@hNg&%V@Z9@J|Q#K*hE>sr6@oguas9&6^-=~$*2Gs%h#GF@h)i=Im z^iKk~ipWJg1VrvKS;_2lgs3n1zvNvxb27nGM=NXE!D4C!U`f*K2B@^^&ij9y}DTLB*FI zEnBL6y{jc?JqXWbkIZd7I16hA>(f9T!iwbIxJj~bKPfrO;>%*5nk&Lf?G@c2wvGrY&41$W{7HM9+b@&XY@>NZM5s|EK_Dp zQX60CBuantx>|d#DsaZ*8MW(we|#KTYZ=vNa#d*DJQe6hr~J6{_rI#?wi@s|&O}FR zG$kfPxheXh1?IZ{bDT-CWB4FTvO-k5scW^mi8?iY5Q`f8JcnnCxiy@m@D-%lO;y0pTLhh6i6l@x52j=#^$5_U^os}OFg zzdHbo(QI`%9#o*r8GCW~T3UdV`szO#~)^&X_(VW>o~umY9-ns9-V4lf~j z`QBD~pJ4a#b`*6bJ^3RS5y?RAgF7K5$ll97Y8#WZduZ`j?IEY~H(s^doZg>7-tk*t z4_QE1%%bb^p~4F5SB$t2i1>DBG1cIo;2(xTaj*Y~hlM{tSDHojL-QPg%Mo%6^7FrpB*{ z4G0@T{-77Por4DCMF zB_5Y~Phv%EQ64W8^GS6h?x6xh;w2{z3$rhC;m+;uD&pR74j+i22P5DS-tE8ABvH(U~indEbBUTAAAXfHZg5QpB@TgV9eI<)JrAkOI z8!TSOgfAJiWAXeM&vR4Glh;VxH}WG&V$bVb`a`g}GSpwggti*&)taV1@Ak|{WrV|5 zmNYx)Ans=S{c52qv@+jmGQ&vd6>6yX6IKq9O$3r&0xUTdZ!m1!irzn`SY+F23Rl6# zFRxws&gV-kM1NX(3(gnKpGi0Q)Dxi~#?nyzOR9!en;Ij>YJZVFAL*=R%7y%Mz9hU% zs>+ZB?qRmZ)nISx7wxY)y#cd$iaC~{k0avD>BjyF1q^mNQ1QcwsxiTySe<6C&cC6P zE`vwO9^k-d`9hZ!+r@Jnr+MF*2;2l8WjZ}DrwDUHzSF{WoG zucbSWguA!3KgB3MU%HH`R;XqVv0CcaGq?+;v_A5A2kpmk5V%qZE3yzQ7R5XWhq=eR zyUezH=@V)y>L9T-M-?tW(PQYTRBKZSVb_!$^H-Pn%ea;!vS_?M<~Tm>_rWIW43sPW z=!lY&fWc1g7+r?R)0p8(%zp&vl+FK4HRkns%BW+Up&wK8!lQ2~bja|9bD12WrKn#M zK)Yl9*8$SI7MAwSK$%)dMd>o+1UD<2&aQMhyjS5R{-vV+M;Q4bzl~Z~=4HFj_#2V9 zB)Gfzx3ncy@uzx?yzi}6>d%-?WE}h7v*w)Jr_gBl!2P&F3DX>j_1#--yjpL%<;JMR z*b70Gr)MMIBWDo~#<5F^Q0$VKI;SBIRneuR7)yVsN~A9I@gZTXe)E?iVII+X5h0~H zx^c(fP&4>!*q>fb6dAOC?MI>Cz3kld#J*;uik+Ps49cwm1B4 zZc1|ZxYyTv;{Z!?qS=D)sgRKx^1AYf%;y_V&VgZglfU>d+Ufk5&LV$sKv}Hoj+s; xK3FZRYdhbXT_@RW*ff3@`D1#ps#~H)p+y&j#(J|vk^lW{fF9OJt5(B-_&*Xgn9~3N literal 0 HcmV?d00001 diff --git a/public/icon.svg b/public/icon.svg new file mode 100644 index 0000000000..04b34bf83f --- /dev/null +++ b/public/icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000000..c19f78ab68 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1 @@ +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/script/.keep b/script/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/storage/.keep b/storage/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000000..0c22470ec1 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,15 @@ +ENV["RAILS_ENV"] ||= "test" +require_relative "../config/environment" +require "rails/test_help" + +module ActiveSupport + class TestCase + # Run tests in parallel with specified workers + parallelize(workers: :number_of_processors) + + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... + end +end diff --git a/tmp/.keep b/tmp/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tmp/pids/.keep b/tmp/pids/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tmp/storage/.keep b/tmp/storage/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vendor/.keep b/vendor/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vendor/javascript/.keep b/vendor/javascript/.keep new file mode 100644 index 0000000000..e69de29bb2 From a4f61b0b74ef69f626db88f29254d8844ddde705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Wed, 20 May 2026 08:35:34 -0300 Subject: [PATCH 02/55] :broom: cleanup: tirando a pasta .idea --- .gitignore | 3 + .idea/CAMAAR.iml | 115 ------------------ .idea/vcs.xml | 6 - .idea/workspace.xml | 280 -------------------------------------------- 4 files changed, 3 insertions(+), 401 deletions(-) delete mode 100644 .idea/CAMAAR.iml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.gitignore b/.gitignore index fbcab405eb..d1811d6ec7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ # belong in git's global ignore instead: # `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore` +# Ignore system/IDE folders +.idea/ + # Ignore bundler config. /.bundle diff --git a/.idea/CAMAAR.iml b/.idea/CAMAAR.iml deleted file mode 100644 index 282e3a1610..0000000000 --- a/.idea/CAMAAR.iml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - file://$MODULE_DIR$/app - - - file://$MODULE_DIR$/app/assets - - - file://$MODULE_DIR$/app/channels - - - file://$MODULE_DIR$/app/controllers - - - file://$MODULE_DIR$/app/helpers - - - file://$MODULE_DIR$/app/mailers - - - file://$MODULE_DIR$/app/models - - - file://$MODULE_DIR$/app/views - - - file://$MODULE_DIR$/config - - - file://$MODULE_DIR$/config/cable.yml - - - file://$MODULE_DIR$/config/cache.yml - - - file://$MODULE_DIR$/config/database.yml - - - file://$MODULE_DIR$/config/environment.rb - - - file://$MODULE_DIR$/config/environments - - - file://$MODULE_DIR$/config/initializers - - - file://$MODULE_DIR$/config/locales - - - file://$MODULE_DIR$/config/routes - - - file://$MODULE_DIR$/config/routes.rb - - - file://$MODULE_DIR$/config/solid_cache.yml - - - file://$MODULE_DIR$/db - - - file://$MODULE_DIR$/db/migrate - - - file://$MODULE_DIR$/db/seeds.rb - - - file://$MODULE_DIR$/lib - - - file://$MODULE_DIR$/lib/assets - - - file://$MODULE_DIR$/lib/tasks - - - file://$MODULE_DIR$/lib/templates - - - file://$MODULE_DIR$/log/development.log - - - file://$MODULE_DIR$/public - - - file://$MODULE_DIR$/public/javascripts - - - file://$MODULE_DIR$/public/stylesheets - - - file://$MODULE_DIR$/test/mailers/previews - file://$MODULE_DIR$/test/mailers/previews - - - file://$MODULE_DIR$/tmp - - - file://$MODULE_DIR$/vendor - - - file://$MODULE_DIR$/vendor/assets - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddfbb..0000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 42de37f639..0000000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - { - "lastFilter": { - "state": "OPEN", - "assignee": "neatzzy" - } -} - { - "selectedUrlAndAccountId": { - "url": "https://github.com/gusfring41/CAMAAR.git", - "accountId": "16cd7249-73f1-4476-a633-ea508292c1bb" - } -} - { - "associatedIndex": 7, - "fromUser": false -} - - - - { - "keyToString": { - "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true", - "RunOnceActivity.git.unshallow": "true", - "RunOnceActivity.ruby.rubocop.migration.global.runOnSaveToExternalFormatter": "true", - "RunOnceActivity.typescript.service.memoryLimit.init": "true", - "SHARE_PROJECT_CONFIGURATION_FILES": "true", - "codeWithMe.voiceChat.enabledByDefault": "false", - "git-widget-placeholder": "main", - "nodejs_package_manager_path": "npm", - "ruby.structure.view.model.defaults.configured": "true", - "vue.rearranger.settings.migration": "true" - } -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1779276211683 - - - - - - \ No newline at end of file From 5c7381322b3d7cca192eafc0240df16ca0455aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Wed, 20 May 2026 09:05:51 -0300 Subject: [PATCH 03/55] :test_tube: test: Criada feature BDD do login --- features/login.feature | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 features/login.feature diff --git a/features/login.feature b/features/login.feature new file mode 100644 index 0000000000..54fef641b1 --- /dev/null +++ b/features/login.feature @@ -0,0 +1,37 @@ +#encoding : UTF-8 +# language: pt + +Funcionalidade: Login no sistema + Eu, como usuário do sistema + Quero acessar o sistema utilizando um e-mail ou matrícula cadastrada + A fim de responder formulários ou gerenciar o sistema + + Cenário: Login realizado com sucesso usando e-mail válido + Dado que meu e-mail "usuario@teste.com" está cadastrado no sistema + Quando eu tento fazer login com as credenciais corretas + Então vejo a mensagem "Login realizado com sucesso." + E sou direcionado para a página inicial + + Cenário: Login realizado com sucesso usando matrícula válida + Dado que minha matrícula "261067676" está cadastrada no sistema + Quando eu tento fazer login com as credenciais corretas + Então vejo a mensagem "Login realizado com sucesso." + E sou direcionado para a página inicial + + Cenário: Tentativa de login com a senha errada + Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123." + Quando eu tento realizar o login com o email correto e a senha "Senha123" + Entao vejo a mensagem "Falha no login: senha incorreta" + E permaneço na página de login + + Cenário: Tentativa de login com senha em branco + Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123." + Quando eu tento realizar o login sem informar minha senha + Entao vejo a mensagem "Falha no login: informe a sua senha" + E permaneço na página de login + + Cenário: Tentativa de login com usuário não cadastrado + Dado que meu email "usuario@teste.com" não está cadastrado no sistema + Quando eu tento realizar o login com este email + Entao vejo a mensagem "Falha no login: usuário não encontrado" + E permaneço na página de login \ No newline at end of file From 149dfb120b68c96fc284a04ad41ff6adeabb6bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Wed, 20 May 2026 09:14:38 -0300 Subject: [PATCH 04/55] =?UTF-8?q?=F0=9F=96=8C=EF=B8=8Fstyle:=20conserto=20?= =?UTF-8?q?das=20frescuras=20do=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 4 +-- config/environments/development.rb | 4 +-- config/environments/test.rb | 4 +-- lib/tasks/cucumber.rake | 43 +++++++++++++++--------------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/Gemfile b/Gemfile index 92bb4366f4..a16307b940 100644 --- a/Gemfile +++ b/Gemfile @@ -63,6 +63,6 @@ group :test do # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] gem "capybara" gem "selenium-webdriver" - gem 'cucumber-rails', require: false - gem 'database_cleaner' + gem "cucumber-rails", require: false + gem "database_cleaner" end diff --git a/config/environments/development.rb b/config/environments/development.rb index 7d1b179ef2..4a6ea19c9c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -2,8 +2,8 @@ Rails.application.configure do # Configure 'rails notes' to inspect Cucumber files - config.annotations.register_directories('features') - config.annotations.register_extensions('feature') { |tag| /#\s*(#{tag}):?\s*(.*)$/ } + config.annotations.register_directories("features") + config.annotations.register_extensions("feature") { |tag| /#\s*(#{tag}):?\s*(.*)$/ } # Settings specified here will take precedence over those in config/application.rb. diff --git a/config/environments/test.rb b/config/environments/test.rb index e6b5c1b020..29d195b837 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -5,8 +5,8 @@ Rails.application.configure do # Configure 'rails notes' to inspect Cucumber files - config.annotations.register_directories('features') - config.annotations.register_extensions('feature') { |tag| /#\s*(#{tag}):?\s*(.*)$/ } + config.annotations.register_directories("features") + config.annotations.register_extensions("feature") { |tag| /#\s*(#{tag}):?\s*(.*)$/ } # Settings specified here will take precedence over those in config/application.rb. diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake index 0caa4d2553..b790c4d483 100644 --- a/lib/tasks/cucumber.rake +++ b/lib/tasks/cucumber.rake @@ -5,46 +5,45 @@ # files. -unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks +unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first -$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil? +$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + "/../lib") unless vendored_cucumber_bin.nil? begin - require 'cucumber/rake/task' + require "cucumber/rake/task" namespace :cucumber do - Cucumber::Rake::Task.new({ok: 'test:prepare'}, 'Run features that should pass') do |t| + Cucumber::Rake::Task.new({ ok: "test:prepare" }, "Run features that should pass") do |t| t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. t.fork = true # You may get faster startup if you set this to false - t.profile = 'default' + t.profile = "default" end - Cucumber::Rake::Task.new({wip: 'test:prepare'}, 'Run features that are being worked on') do |t| + Cucumber::Rake::Task.new({ wip: "test:prepare" }, "Run features that are being worked on") do |t| t.binary = vendored_cucumber_bin t.fork = true # You may get faster startup if you set this to false - t.profile = 'wip' + t.profile = "wip" end - Cucumber::Rake::Task.new({rerun: 'test:prepare'}, 'Record failing features and run only them if any exist') do |t| + Cucumber::Rake::Task.new({ rerun: "test:prepare" }, "Record failing features and run only them if any exist") do |t| t.binary = vendored_cucumber_bin t.fork = true # You may get faster startup if you set this to false - t.profile = 'rerun' + t.profile = "rerun" end - desc 'Run all features' - task all: [:ok, :wip] + desc "Run all features" + task all: [ :ok, :wip ] task :statsetup do - require 'rails/code_statistics' - ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features') - ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features') + require "rails/code_statistics" + ::STATS_DIRECTORIES << %w[Cucumber\ features features] if File.exist?("features") + ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?("features") end - end - desc 'Alias for cucumber:ok' - task cucumber: 'cucumber:ok' + desc "Alias for cucumber:ok" + task cucumber: "cucumber:ok" task default: :cucumber @@ -53,16 +52,16 @@ begin end # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon. - task 'test:prepare' do + task "test:prepare" do end - task stats: 'cucumber:statsetup' + task stats: "cucumber:statsetup" + - rescue LoadError - desc 'cucumber rake task not available (cucumber not installed)' + desc "cucumber rake task not available (cucumber not installed)" task :cucumber do - abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin' + abort "Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin" end end From d38173eb0cfdae76024202e22a71c5f8ff3a5d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Wed, 20 May 2026 10:27:24 -0300 Subject: [PATCH 05/55] =?UTF-8?q?:heavy=5Fplus=5Fsign:=20build:=20adiciond?= =?UTF-8?q?a=20a=20depend=C3=AAncia=20do=20rspec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 ++ Gemfile.lock | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Gemfile b/Gemfile index a16307b940..c8d2dce83a 100644 --- a/Gemfile +++ b/Gemfile @@ -57,6 +57,7 @@ end group :development do # Use console on exceptions pages [https://github.com/rails/web-console] gem "web-console" + gem "rspec-rails" end group :test do @@ -65,4 +66,5 @@ group :test do gem "selenium-webdriver" gem "cucumber-rails", require: false gem "database_cleaner" + gem "rspec-rails" end diff --git a/Gemfile.lock b/Gemfile.lock index 591d95f42b..c4e981735c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -314,6 +314,23 @@ GEM reline (0.6.3) io-console (~> 0.5) rexml (3.4.4) + rspec-core (3.13.6) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.8) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-rails (8.0.4) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) + rspec-core (>= 3.13.0, < 5.0.0) + rspec-expectations (>= 3.13.0, < 5.0.0) + rspec-mocks (>= 3.13.0, < 5.0.0) + rspec-support (>= 3.13.0, < 5.0.0) + rspec-support (3.13.7) rubocop (1.86.2) json (~> 2.3) language_server-protocol (~> 3.17.0.2) @@ -440,6 +457,7 @@ DEPENDENCIES propshaft puma (>= 5.0) rails (~> 8.1.3) + rspec-rails rubocop-rails-omakase selenium-webdriver solid_cable @@ -571,6 +589,11 @@ CHECKSUMS regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835 rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142 + rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d + rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836 + rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47 + rspec-rails (8.0.4) sha256=06235692fc0892683d3d34977e081db867434b3a24ae0dd0c6f3516bad4e22df + rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c rubocop (1.86.2) sha256=bb2e97f635eda42c448f2588f4a6ff78f221b8bdfdf65b1e9b07fbd57521b45d rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035 rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834 From a20b7a9799ded10a70359ff94bf92fd772e56f55 Mon Sep 17 00:00:00 2001 From: Liferoijrm Date: Fri, 22 May 2026 22:18:23 -0300 Subject: [PATCH 06/55] =?UTF-8?q?:construction:feat:=20hist=C3=B3rias=20de?= =?UTF-8?q?=20usu=C3=A1rio=20e=20step=20definitions=20de=20login=20e=20cad?= =?UTF-8?q?astro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/cadastro_sigaa.feature | 13 +++++ features/login.feature | 53 ++++++++++++-------- features/step_definitions/cadastro_steps.rb | 16 ++++++ features/step_definitions/login_steps.rb | 54 +++++++++++++++++++++ 4 files changed, 115 insertions(+), 21 deletions(-) create mode 100644 features/cadastro_sigaa.feature create mode 100644 features/step_definitions/cadastro_steps.rb create mode 100644 features/step_definitions/login_steps.rb diff --git a/features/cadastro_sigaa.feature b/features/cadastro_sigaa.feature new file mode 100644 index 0000000000..9f169a5f07 --- /dev/null +++ b/features/cadastro_sigaa.feature @@ -0,0 +1,13 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Cadastrar usuários do sistema + Eu, como Administrador + Quero cadastrar participantes de turmas do SIGAA ao importar dados de usuarios novos para o sistema + A fim de que eles acessem o sistema CAMAAR + + Cenário: Cadastro de usuário importado do SIGAA (happy path) + Dado que estou na página de gerenciamento + Dado que eu importei os dados do SIGAA com sucesso + Então o e-mail de usuário "usuario@teste.com" está cadastrado no sistema com senha indefinida + E um email de definição de senha é enviado para o email "usuario@teste.com" \ No newline at end of file diff --git a/features/login.feature b/features/login.feature index 54fef641b1..51c1f73be2 100644 --- a/features/login.feature +++ b/features/login.feature @@ -1,37 +1,48 @@ -#encoding : UTF-8 +# encoding : UTF-8 # language: pt Funcionalidade: Login no sistema - Eu, como usuário do sistema - Quero acessar o sistema utilizando um e-mail ou matrícula cadastrada - A fim de responder formulários ou gerenciar o sistema + Eu, como usuário do sistema + Quero acessar o sistema utilizando um e-mail ou matrícula cadastrada + A fim de responder formulários ou gerenciar o sistema - Cenário: Login realizado com sucesso usando e-mail válido - Dado que meu e-mail "usuario@teste.com" está cadastrado no sistema - Quando eu tento fazer login com as credenciais corretas + Cenário: Login realizado com sucesso usando e-mail válido (happy path) + Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123" + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" Então vejo a mensagem "Login realizado com sucesso." E sou direcionado para a página inicial - Cenário: Login realizado com sucesso usando matrícula válida - Dado que minha matrícula "261067676" está cadastrada no sistema - Quando eu tento fazer login com as credenciais corretas + Cenário: Login realizado com sucesso usando matrícula válida (happy path) + Dado que minha matrícula "261067676" está cadastrada no sistema e senha "Senha123" + Quando eu tento realizar o login com matrícula "261067676" e a senha "Senha123" Então vejo a mensagem "Login realizado com sucesso." E sou direcionado para a página inicial - Cenário: Tentativa de login com a senha errada - Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123." - Quando eu tento realizar o login com o email correto e a senha "Senha123" - Entao vejo a mensagem "Falha no login: senha incorreta" + Cenário: Tentativa de login com a senha errada (sad path) + Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123" + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123." + Então vejo a mensagem "Falha no login: senha incorreta" E permaneço na página de login - Cenário: Tentativa de login com senha em branco - Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123." - Quando eu tento realizar o login sem informar minha senha - Entao vejo a mensagem "Falha no login: informe a sua senha" + Cenário: Tentativa de login com usuário em branco (sad path) + Quando eu tento realizar o login sem informar meu email ou matrícula e com senha "Senha123" + Então vejo a mensagem "Falha no login: informe seu email ou matrícula" E permaneço na página de login - Cenário: Tentativa de login com usuário não cadastrado + Cenário: Tentativa de login com senha em branco (sad path) + Quando eu tento realizar o login com email "usuario@teste.com" sem informar minha senha + Então vejo a mensagem "Falha no login: informe a sua senha" + E permaneço na página de login + + Cenário: Tentativa de login com usuário com cadastro não efetivado (sad path) + Dado que meu usuário está cadastrado com o email "usuario@teste.com" + Dado que minha senha para "usuario@teste.com" não está definida + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" + Então vejo a mensagem "Falha no login: usuário existente deve efetivar o seu cadastro por email" + E permaneço na página de login + + Cenário: Tentativa de login com usuário não cadastrado (sad path) Dado que meu email "usuario@teste.com" não está cadastrado no sistema - Quando eu tento realizar o login com este email - Entao vejo a mensagem "Falha no login: usuário não encontrado" + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" + Então vejo a mensagem "Falha no login: usuário não encontrado" E permaneço na página de login \ No newline at end of file diff --git a/features/step_definitions/cadastro_steps.rb b/features/step_definitions/cadastro_steps.rb new file mode 100644 index 0000000000..de5fe32d6e --- /dev/null +++ b/features/step_definitions/cadastro_steps.rb @@ -0,0 +1,16 @@ +Dado('que estou na página de gerenciamento') do + # expect(page).to have_current_path(gerenciamento_path) + # implementar quando o nome da rota for determinado +end + +Dado('que eu importei os dados do SIGAA com sucesso') do + # implementar a partir da feature de importar dados +end + +Então('o e-mail de usuário {string} está cadastrado no sistema com senha indefinida') do |email| + # implementar quando definir models +end + +Então('um email de definição de senha é enviado para o email {string}') do |email| + # implementar quando definir models (vai ser um método do model) +end \ No newline at end of file diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb new file mode 100644 index 0000000000..213109e6e0 --- /dev/null +++ b/features/step_definitions/login_steps.rb @@ -0,0 +1,54 @@ +Dado('que meu usuário está cadastrado com o email {string}') do |email| + # Implementar quando definir models +end + +Dado('que meu email {string} não está cadastrado no sistema') do |email| + # Implementar quando definir models +end + +Dado('que meu usuário está cadastrado com o email {string} e senha {string}') do |email, senha| + # Implementar quando definir models +end + +Dado('que minha matrícula {string} está cadastrada no sistema e senha {string}') do |matricula, senha| + # Implementar quando definir models +end + +Dado('que minha senha para {string} não está definida') do |email| + # Implementar quando definir models +end + +Quando('eu tento realizar o login com o email {string} e a senha {string}') do |email_usuario, senha_usuario| + fill_in "login", with: email_usuario + fill_in "senha", with: senha_usuario + click_button "Entrar" +end + +Quando('eu tento realizar o login com matrícula {string} e a senha {string}') do |matricula_usuario, senha_usuario| + fill_in "login", with: matricula_usuario + fill_in "senha", with: senha_usuario + click_button "Entrar" +end + +Quando('eu tento realizar o login sem informar meu email ou matrícula e com senha {string}') do |senha_usuario| + fill_in "senha", with: senha_usuario + click_button "Entrar" +end + +Quando('eu tento realizar o login com email {string} sem informar minha senha') do |email_usuario| + fill_in "login", with: email_usuario + click_button "Entrar" +end + +Então('vejo a mensagem {string}') do |string| + expect(page).to have_content(string) +end + +Então('permaneço na página de login') do + expect(page).to have_current_path(root_path) +end + +Então('sou direcionado para a página inicial') do + # expect(page).to have_current_path(avaliacoes_path) + # implementar quando o nome da rota for determinado +end \ No newline at end of file From b731eaa706315e275b86a63f69d50b288b198ed6 Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Mon, 25 May 2026 10:25:21 -0300 Subject: [PATCH 07/55] feat: template tests --- features/step_definitions/template_steps.rb | 0 features/template/create_template.feature | 60 +++++++++++++++++++ .../template/edit_delete_template.feature | 60 +++++++++++++++++++ features/template/view_template.feature | 24 ++++++++ 4 files changed, 144 insertions(+) create mode 100644 features/step_definitions/template_steps.rb create mode 100644 features/template/create_template.feature create mode 100644 features/template/edit_delete_template.feature create mode 100644 features/template/view_template.feature diff --git a/features/step_definitions/template_steps.rb b/features/step_definitions/template_steps.rb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/features/template/create_template.feature b/features/template/create_template.feature new file mode 100644 index 0000000000..113a061868 --- /dev/null +++ b/features/template/create_template.feature @@ -0,0 +1,60 @@ +Feature: Create Template + + Eu como Administrador + Quero criar um template de formulário contendo as questões do formulário + A fim de gerar formulários de avaliações para avaliar o desempenho das turmas + + Background: + Given I Am authenticated as an "Administrador" + Given I Am on the home page + And I follow "Adicionar novo template" + And I am on the "Criar novo template" page + + Scenario: Create a template successfully(happy path) + + # Teste de matematica, multipla escolha + And I have added the template + | titulo | Template Prova Matemática 2º semestre | + And I add the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 2(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 3(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão 4(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão desafio(1 ponto): | multipla_escolha | a: b: c: d: | + When I press "Salvar" + Then I should see a success message "Template criado com sucesso!" + + # Teste de portugues, discursivo + When I follow "Adicionar novo template" + Given I have added the template + | titulo | Template Prova Português 2º semestre | + And I add the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1(2.5 pontos): | campo_de_texto | Resposta: | + | Questão 2(2.5 pontos): | campo_de_texto | Resposta: | + | Questão 3(2.5 pontos): | campo_de_texto | Resposta: | + | Questão 4(2.5 pontos): | campo_de_texto | Resposta: | + | Questão desafio(1 ponto): | campo_de_texto | Resposta: | + When I press "Salvar" + Then I should see a success message "Template criado com sucesso!" + + # verificacao final (visualizacao) + And the template "Template Prova Matemática 2º semestre" should be listed in my templates + And the template "Template Prova Português 2º semestre" should be listed in my templates + + Scenario: Attempt to create a template without a title(sad path) + Given I have added the template + | titulo | "" | + And I add the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1: | multipla_escolha | a: b: c: d: | + When I press "Salvar" + Then I should see an error message "Título não pode ficar em branco!" + + Scenario: Attempt to create a template without questions(sad path) + Given I have added the template + | titulo | Template Prova Matemática 2º semestre | + And I dont add elementos + When I press "Salvar" + Then I should see an error message "Template deve ter pelo menos um elemento!" diff --git a/features/template/edit_delete_template.feature b/features/template/edit_delete_template.feature new file mode 100644 index 0000000000..761af40070 --- /dev/null +++ b/features/template/edit_delete_template.feature @@ -0,0 +1,60 @@ +Feature: Edit and/or delete template + + Eu como Administrador + Quero editar e/ou deletar um template que eu criei sem afetar os formulários já criados + A fim de organizar os templates existentes + + Background: + Given I am authenticated as an "Administrador" + + # criar + Scenario: Edit a template title successfully(happy path) + + # setup inicial + Given I have the following templates saved: + | titulo | + | Template Prova Matemática 2º semestre | + And the template "Template Prova Matemática 2º semestre" has the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 2(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 3(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão 4(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão desafio(1 ponto): | multipla_escolha | a: b: c: d: | + When I go to the "Meus Templates" page + And I follow "Editar" for "Template Prova Matemática 2º semestre" + + And I change the "titulo" to "Template Matemática Atualizado" + And I change the elemento "Questão desafio(1 ponto): " to "" + And I press "Salvar" + Then I should see a success message "Template atualizado com sucesso!" + And I should see "Template Matemática Atualizado" + But I should not see "Template Prova Matemática 2º semestre" + And the template "Template Matemática Atualizado" should have the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 2(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 3(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão 4(3 pontos): | multipla_escolha | a: b: c: d: | + + Scenario: Attempt to edit a template with a blank title(sad path) + Given I have the following templates saved: + | titulo | + | Template Prova Matemática 2º semestre | + When I go to the "Meus Templates" page + And I follow "Editar" for "Template Prova Matemática 2º semestre" + And I change the "titulo" to "" + And I press "Salvar" + Then I should see an error message "Título não pode ficar em branco!" + + # deletar + Scenario: Delete a template successfully(happy path) + Given I have the following templates saved: + | titulo | + | Template Prova Matemática 2º semestre | + When I go to the "Meus Templates" page + And I follow "Deletar" for "Template Prova Matemática 2º semestre" + And I confirm the deletion + Then I should see a success message "Template deletado com sucesso!" + And I should not see "Template Prova Matemática 2º semestre" + diff --git a/features/template/view_template.feature b/features/template/view_template.feature new file mode 100644 index 0000000000..27a1f82f20 --- /dev/null +++ b/features/template/view_template.feature @@ -0,0 +1,24 @@ +Feature: View Template + + Eu como Administrador + Quero visualizar os templates criados + A fim de poder editar e/ou deletar um template que eu criei + + Background: + Given I am authenticated as an "Administrador" + + Scenario: View template list successfully(happy path) + Given I have the following templates saved: + | titulo | + | Template Prova Matemática 2º semestre | + | Template Prova Português 2º semestre | + When I go to the "Meus Templates" page + Then I should see "Template Prova Matemática 2º semestre" + And I should see "Template Prova Português 2º semestre" + And I should see options to "Editar" and "Deletar" for each template + + Scenario: View empty template list(sad path) + Given I have no templates saved + When I go to the "Meus Templates" page + Then I should see the message "Nenhum template encontrado." + And I should see a button "Criar novo template" \ No newline at end of file From 6ccc31d3c71c3e4a3f7d37aa80073749011e998f Mon Sep 17 00:00:00 2001 From: Leo3107 Date: Mon, 25 May 2026 16:23:19 -0300 Subject: [PATCH 08/55] =?UTF-8?q?Implementa=C3=A7=C3=A3o:=20BDDs=20=20-=20?= =?UTF-8?q?Happy=20e=20Sad=20Path.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 22 +++++++--- features/criar_formulario.feature | 23 ++++++++++ features/responder_formulario.feature | 25 +++++++++++ .../criar_formulario_steps.rb | 38 ++++++++++++++++ .../responder_formulario_steps.rb | 43 +++++++++++++++++++ 5 files changed, 144 insertions(+), 7 deletions(-) create mode 100644 features/criar_formulario.feature create mode 100644 features/responder_formulario.feature create mode 100644 features/step_definitions/criar_formulario_steps.rb create mode 100644 features/step_definitions/responder_formulario_steps.rb diff --git a/Gemfile.lock b/Gemfile.lock index c4e981735c..e159082878 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -153,7 +153,7 @@ GEM ffi (1.17.4-aarch64-linux-musl) ffi (1.17.4-arm-linux-gnu) ffi (1.17.4-arm-linux-musl) - ffi (1.17.4-arm64-darwin) + ffi (1.17.4-x64-mingw-ucrt) ffi (1.17.4-x86_64-linux-gnu) ffi (1.17.4-x86_64-linux-musl) fugit (1.12.1) @@ -239,7 +239,7 @@ GEM racc (~> 1.4) nokogiri (1.19.3-arm-linux-musl) racc (~> 1.4) - nokogiri (1.19.3-arm64-darwin) + nokogiri (1.19.3-x64-mingw-ucrt) racc (~> 1.4) nokogiri (1.19.3-x86_64-linux-gnu) racc (~> 1.4) @@ -400,10 +400,13 @@ GEM sys-uname (1.5.1) ffi (~> 1.1) memoist3 (~> 1.0.0) + sys-uname (1.5.1-universal-mingw32) + ffi (~> 1.1) + memoist3 (~> 1.0.0) + win32ole thor (1.5.0) thruster (0.1.21) thruster (0.1.21-aarch64-linux) - thruster (0.1.21-arm64-darwin) thruster (0.1.21-x86_64-linux) timeout (0.6.1) tsort (0.2.0) @@ -412,6 +415,8 @@ GEM railties (>= 7.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + tzinfo-data (1.2026.2) + tzinfo (>= 1.0.0) unicode-display_width (3.2.0) unicode-emoji (~> 4.1) unicode-emoji (4.2.0) @@ -426,6 +431,7 @@ GEM base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + win32ole (1.9.3) xpath (3.2.0) nokogiri (~> 1.8) zeitwerk (2.8.1) @@ -436,7 +442,7 @@ PLATFORMS aarch64-linux-musl arm-linux-gnu arm-linux-musl - arm64-darwin-25 + x64-mingw-ucrt x86_64-linux x86_64-linux-gnu x86_64-linux-musl @@ -521,7 +527,7 @@ CHECKSUMS ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39 ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564 ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95 - ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b + ffi (1.17.4-x64-mingw-ucrt) sha256=f6ff9618cfccc494138bddade27aa06c74c6c7bc367a1ea1103d80c2fcb9ed35 ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e fugit (1.12.1) sha256=5898f478ede9b415f0804e42b8f3fd53f814bd85eebffceebdbc34e1107aaf68 @@ -560,7 +566,7 @@ CHECKSUMS nokogiri (1.19.3-aarch64-linux-musl) sha256=8392dfdcd21be7a94dbbe9ccc138dea01b97b24cb2dc02a114ca98bfb1d9a0b7 nokogiri (1.19.3-arm-linux-gnu) sha256=3919d5ffc334ad778a4a9eb88fda7dcb8b1fb58c8a52ac640c6dcd2f038e774f nokogiri (1.19.3-arm-linux-musl) sha256=9ce1cb6346bb9c67b1550eb537aa183ead91e4b6eadb2f36ade02d8dd2a79fb6 - nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42 + nokogiri (1.19.3-x64-mingw-ucrt) sha256=8bb7132cad356c879a1286eaabcb5e68326cb2490317984280fbc62f456d506a nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976 nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912 @@ -611,15 +617,16 @@ CHECKSUMS stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06 stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1 sys-uname (1.5.1) sha256=784d7e6491b0393c25cbbe5ac38324ac7be9fda083a6094832648af669386d7b + sys-uname (1.5.1-universal-mingw32) sha256=aceb618e3276da5eae0ce368e9f6fae8c1f3e9ef23a0595cb88db7b6ecd45f62 thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 thruster (0.1.21) sha256=dc67928f36e5894844579a95e45637a5091db7a7ea05468ee8c2c6eb0a3f77cf thruster (0.1.21-aarch64-linux) sha256=f5aff78fb7a6431ed3d6ab4bde03a89c461e9a73981dbc97d6990d85c3db235c - thruster (0.1.21-arm64-darwin) sha256=bd8db9f57fae2cbb3fe08ebab49cb47fe49608122dac23daf0ce709adfb9bfc8 thruster (0.1.21-x86_64-linux) sha256=6e2fbcf826540a72d3710ae4db072c2333287ac2ee57e7e52f35bc10900d74a7 timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f turbo-rails (2.0.23) sha256=ee0d90733aafff056cf51ff11e803d65e43cae258cc55f6492020ec1f9f9315f tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b + tzinfo-data (1.2026.2) sha256=7db0d3d3d53b8d7601fc183fccc8c6d056a3004e14eb59ea995bf6aec4ae10bc unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42 unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6 @@ -628,6 +635,7 @@ CHECKSUMS websocket (1.2.11) sha256=b7e7a74e2410b5e85c25858b26b3322f29161e300935f70a0e0d3c35e0462737 websocket-driver (0.8.0) sha256=ed0dba4b943c22f17f9a734817e808bc84cdce6a7e22045f5315aa57676d4962 websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241 + win32ole (1.9.3) sha256=01f43dc5dc13806e6e58204f538b4a28f3d85968ea89074abc9a3cd118e94d96 xpath (3.2.0) sha256=6dfda79d91bb3b949b947ecc5919f042ef2f399b904013eb3ef6d20dd3a4082e zeitwerk (2.8.1) sha256=1c85e0f28954d68cd16e575da37f26846f609b68d80b5942ccfd31030c2449d5 diff --git a/features/criar_formulario.feature b/features/criar_formulario.feature new file mode 100644 index 0000000000..7ebcad2ffd --- /dev/null +++ b/features/criar_formulario.feature @@ -0,0 +1,23 @@ +# language: pt + +Funcionalidade: Criar formulário de avaliação + Como um professor ou administrador + Quero poder criar um formulário de avaliação + Para que os alunos possam avaliar a disciplina ou turma + + Contexto: + Dado que eu estou logado como professor + E eu estou na página de criação de formulários + + Cenário: Criação de formulário com sucesso (Happy Path) + Quando eu preencho o título com "Avaliação de Turma 2026.1" + E eu adiciono uma pergunta do tipo "Múltipla Escolha" com o texto "Como você avalia o professor?" + E eu clico em "Salvar Formulário" + Então eu devo ver a mensagem "Formulário criado com sucesso" + E eu devo ver o formulário "Avaliação de Turma 2026.1" na lista de formulários + + Cenário: Tentativa de criação sem título (Sad Path) + Quando eu deixo o título em branco + E eu adiciono uma pergunta do tipo "Texto" com o texto "Quais suas sugestões?" + E eu clico em "Salvar Formulário" + Então eu devo ver a mensagem "Título não pode ficar em branco" diff --git a/features/responder_formulario.feature b/features/responder_formulario.feature new file mode 100644 index 0000000000..1b15384111 --- /dev/null +++ b/features/responder_formulario.feature @@ -0,0 +1,25 @@ +# language: pt + +Funcionalidade: Visualizar e responder formulário de avaliação + Como um aluno + Quero poder visualizar e responder a um formulário de avaliação + Para dar feedback sobre a turma ou disciplina + + Contexto: + Dado que eu estou logado como aluno + E existe um formulário ativo chamado "Avaliação de Turma 2026.1" + E eu estou na página de formulários disponíveis + + Cenário: Resposta completa ao formulário com sucesso (Happy Path) + Quando eu clico para responder o formulário "Avaliação de Turma 2026.1" + Então eu devo visualizar os detalhes e perguntas pertinentes a ele + Quando eu respondo a pergunta "Como você avalia o professor?" com a opção "Ótimo" + E eu clico no botão "Enviar Avaliação" + Então eu devo ver a mensagem "Avaliação enviada com sucesso" + E o formulário "Avaliação de Turma 2026.1" não deve mais aparecer na minha lista de pendentes + + Cenário: Tentativa de envio com perguntas obrigatórias em branco (Sad Path) + Quando eu clico para responder o formulário "Avaliação de Turma 2026.1" + E eu deixo a pergunta obrigatória "Como você avalia o professor?" em branco + E eu clico no botão "Enviar Avaliação" + Então eu devo ver a mensagem "Por favor, responda todas as perguntas obrigatórias" diff --git a/features/step_definitions/criar_formulario_steps.rb b/features/step_definitions/criar_formulario_steps.rb new file mode 100644 index 0000000000..f30c817a7e --- /dev/null +++ b/features/step_definitions/criar_formulario_steps.rb @@ -0,0 +1,38 @@ +Dado('que eu estou logado como professor') do + # Implementar quando definir models e autenticação + # visit '/login' + # fill_in 'Email', with: 'professor@ufpe.br' + # fill_in 'Senha', with: 'senha123' + # click_button 'Entrar' +end + +Dado('eu estou na página de criação de formulários') do + visit '/forms/new' +end + +Quando('eu preencho o título com {string}') do |titulo| + fill_in 'Título do Formulário', with: titulo +end + +Quando('eu deixo o título em branco') do + fill_in 'Título do Formulário', with: '' +end + +Quando('eu adiciono uma pergunta do tipo {string} com o texto {string}') do |tipo, texto| + # Ajustar a interação com os botões/selects dinâmicos na tela quando desenvolvidos + select tipo, from: 'Tipo de Pergunta' + fill_in 'Texto da Pergunta', with: texto + click_button 'Adicionar Pergunta' +end + +Quando('eu clico em {string}') do |nome_botao| + click_button nome_botao +end + +Então('eu devo ver a mensagem {string}') do |mensagem| + expect(page).to have_content(mensagem) +end + +Então('eu devo ver o formulário {string} na lista de formulários') do |nome_formulario| + expect(page).to have_content(nome_formulario) +end diff --git a/features/step_definitions/responder_formulario_steps.rb b/features/step_definitions/responder_formulario_steps.rb new file mode 100644 index 0000000000..d6186e19f1 --- /dev/null +++ b/features/step_definitions/responder_formulario_steps.rb @@ -0,0 +1,43 @@ +Dado('que eu estou logado como aluno') do + # Implementar quando definir models e autenticação + # visit '/login' + # fill_in 'Email', with: 'aluno@ufpe.br' + # fill_in 'Senha', with: 'senha123' + # click_button 'Entrar' +end + +Dado('existe um formulário ativo chamado {string}') do |nome_formulario| + # Implementar a criação desse registro (Form/Evaluation) no banco usando Factory/ActiveRecord +end + +Dado('eu estou na página de formulários disponíveis') do + visit '/forms/pending' +end + +Quando('eu clico para responder o formulário {string}') do |nome_formulario| + # Ajustar seletor dependendo da interface, por exemplo, achar o escopo do texto ou tr + click_link "Responder" +end + +Então('eu devo visualizar os detalhes e perguntas pertinentes a ele') do + # Assumindo que a classe .form-question existirá na view + expect(page).to have_selector('.form-question') +end + +Quando('eu respondo a pergunta {string} com a opção {string}') do |pergunta, opcao| + # Ajustar conformidade de input visual (radio, select, text) + choose opcao +end + +Quando('eu deixo a pergunta obrigatória {string} em branco') do |pergunta| + # O comportamento de deixar em branco pode ser simplesmente não preencher, logo, nenhum click extra. +end + +Quando('eu clico no botão {string}') do |nome_botao| + click_button nome_botao +end + +Então('o formulário {string} não deve mais aparecer na minha lista de pendentes') do |nome_formulario| + visit '/forms/pending' + expect(page).not_to have_content(nome_formulario) +end From 1ac237f1d6c35ca8df6a7b4e3f499a995069360b Mon Sep 17 00:00:00 2001 From: neatzzy Date: Mon, 25 May 2026 17:12:24 -0300 Subject: [PATCH 09/55] :test_tube: test: criados os BDDs das issues #1 e #11 --- features/atualizar_dados_sigaa.feature | 27 ++++++++++++++++++++++++ features/importar_dados_sigaa.feature | 29 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 features/atualizar_dados_sigaa.feature create mode 100644 features/importar_dados_sigaa.feature diff --git a/features/atualizar_dados_sigaa.feature b/features/atualizar_dados_sigaa.feature new file mode 100644 index 0000000000..97087df8ac --- /dev/null +++ b/features/atualizar_dados_sigaa.feature @@ -0,0 +1,27 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Atualizar base de dados do sistema com dados do SIGAA + Eu, como Administrador + Quero atualizar os dados de turmas, matérias e participantes do sistema com os dados atuais do SIGAA + A fim de corrigir a base de dados do sistema + +Contexto: + Dado que estou na página de gerenciamento + E que os dados do SIGAA foram importados com sucesso + +Cenário: Atualização de dados do SIGAA (happy path) + Dado que os dados do SIGAA foram atualizados com sucesso + Então as turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA + +Cenário: Atualização de dados do SIGAA com falha (sad path) + Dado que eu tentei atualizar os dados do SIGAA mas ocorreu um erro + Então uma mensagem de erro é exibida informando que a atualização falhou + +Cenário: Atualização de dados do SIGAA com dados já atualizados (sad path) + Dado que os dados do SIGAA já estão atualizados na base de dados do sistema + Então uma mensagem é exibida informando que os dados já estão atualizados e não serão atualizados novamente + +Cenário: Atualização de dados do SIGAA com dados parcialmente atualizados (sad path) + Dado que alguns dados do SIGAA já estão atualizados na base de dados do sistema + Então uma mensagem é exibida informando que alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso diff --git a/features/importar_dados_sigaa.feature b/features/importar_dados_sigaa.feature new file mode 100644 index 0000000000..829cb1212a --- /dev/null +++ b/features/importar_dados_sigaa.feature @@ -0,0 +1,29 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Importar dados do SIGAA + Eu, como Administrador + Quero importar dados de turmas, matérias e participantes do SIGAA (caso não existam na base de dados atual + A fim de alimentar a base de dados do sistema + P.S. utilizar os JSONs presentes no repositório + +Contexto: + Dado que estou na página de gerenciamento + E que os dados do SIGAA estão disponíveis para importação + +Cenário: Importação de dados do SIGAA (happy path) + Dado que os dados do SIGAA foram importados com sucesso + Então as turmas, matérias e participantes do SIGAA estão presentes no sistema + +Cenário: Importação de dados do SIGAA com falha (sad path) + Dado que eu tentei importar os dados do SIGAA mas ocorreu um erro + Então uma mensagem de erro é exibida informando que a importação falhou + +Cenário: Importação de dados do SIGAA com dados já existentes (sad path) + Dado que os dados do SIGAA já existem na base de dados do sistema + Então uma mensagem é exibida informando que os dados já foram importados e não serão importados novamente + +Cenário: Importação de dados do SIGAA com dados parcialmente existentes (sad path) + Dado que alguns dados do SIGAA já existem na base de dados do sistema + Então uma mensagem é exibida informando que alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso + From dc2dbf84ef9dcae2912d45f45f8e68b96f08fa55 Mon Sep 17 00:00:00 2001 From: leitaonerd Date: Mon, 25 May 2026 18:29:01 -0300 Subject: [PATCH 10/55] test: criados os BDDs das issues #8 e #10 --- features/definicao_senha.feature | 32 +++++++++++++++ features/redefinicao_senha.feature | 63 ++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 features/definicao_senha.feature create mode 100644 features/redefinicao_senha.feature diff --git a/features/definicao_senha.feature b/features/definicao_senha.feature new file mode 100644 index 0000000000..898b69805d --- /dev/null +++ b/features/definicao_senha.feature @@ -0,0 +1,32 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Definição de senha (primeiro acesso) + Eu, como usuário importado do SIGAA + Quero definir minha senha a partir de um link enviado por e-mail + A fim de efetivar meu cadastro e acessar o sistema + + Contexto: + Dado que o e-mail de usuário "usuario@teste.com" está cadastrado no sistema com senha indefinida + E um email de definição de senha é enviado para o email "usuario@teste.com" + + Cenário: Definir senha com sucesso (happy path) + Quando eu acesso o link de definição de senha recebido por e-mail + E eu informo a nova senha "Senha123" e confirmo a senha "Senha123" + E eu confirmo a definição de senha + Então vejo a mensagem "Senha definida com sucesso." + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" + Então vejo a mensagem "Login realizado com sucesso." + E sou direcionado para a página inicial + + Cenário: Definição de senha com confirmação diferente (sad path) + Quando eu acesso o link de definição de senha recebido por e-mail + E eu informo a nova senha "Senha123" e confirmo a senha "Senha321" + E eu confirmo a definição de senha + Então vejo a mensagem "Falha na definição de senha: confirmação não confere" + + Cenário: Definição de senha com senha inválida (sad path) + Quando eu acesso o link de definição de senha recebido por e-mail + E eu informo a nova senha "123" e confirmo a senha "123" + E eu confirmo a definição de senha + Então vejo a mensagem "Falha na definição de senha: senha inválida" diff --git a/features/redefinicao_senha.feature b/features/redefinicao_senha.feature new file mode 100644 index 0000000000..0f9d17ff33 --- /dev/null +++ b/features/redefinicao_senha.feature @@ -0,0 +1,63 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Redefinição de senha + Eu, como usuário cadastrado + Quero redefinir minha senha quando eu a esquecer + A fim de recuperar meu acesso ao sistema + + Contexto: + Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123" + + Cenário: Solicitar redefinição de senha com sucesso (happy path) + Quando eu clico em "Esqueci minha senha" + E eu informo o email "usuario@teste.com" + E eu solicito a redefinição de senha + Então vejo a mensagem "Solicitação de redefinição de senha enviada." + E um email de redefinição de senha é enviado para o email "usuario@teste.com" + + Cenário: Redefinir senha com sucesso através do link (happy path) + Dado que eu solicitei a redefinição de senha para o email "usuario@teste.com" + Quando eu acesso o link de redefinição de senha recebido por e-mail + E eu informo a nova senha "NovaSenha123" e confirmo a senha "NovaSenha123" + E eu confirmo a redefinição de senha + Então vejo a mensagem "Senha redefinida com sucesso." + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "NovaSenha123" + Então vejo a mensagem "Login realizado com sucesso." + E sou direcionado para a página inicial + + Cenário: Após redefinir a senha, a senha antiga deixa de funcionar (sad path) + Dado que eu solicitei a redefinição de senha para o email "usuario@teste.com" + Quando eu acesso o link de redefinição de senha recebido por e-mail + E eu informo a nova senha "NovaSenha123" e confirmo a senha "NovaSenha123" + E eu confirmo a redefinição de senha + Então vejo a mensagem "Senha redefinida com sucesso." + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" + Então vejo a mensagem "Falha no login: senha incorreta" + E permaneço na página de login + + Cenário: Solicitar redefinição para email não cadastrado (sad path) + Dado que meu email "naoexiste@teste.com" não está cadastrado no sistema + Quando eu clico em "Esqueci minha senha" + E eu informo o email "naoexiste@teste.com" + E eu solicito a redefinição de senha + Então vejo a mensagem "Falha na redefinição de senha: usuário não encontrado" + + Cenário: Solicitar redefinição sem informar email (sad path) + Quando eu clico em "Esqueci minha senha" + E eu solicito a redefinição de senha sem informar meu email + Então vejo a mensagem "Falha na redefinição de senha: informe seu email" + + Cenário: Redefinição com confirmação diferente (sad path) + Dado que eu solicitei a redefinição de senha para o email "usuario@teste.com" + Quando eu acesso o link de redefinição de senha recebido por e-mail + E eu informo a nova senha "NovaSenha123" e confirmo a senha "NovaSenha321" + E eu confirmo a redefinição de senha + Então vejo a mensagem "Falha na redefinição de senha: confirmação não confere" + + Cenário: Redefinição com senha inválida (sad path) + Dado que eu solicitei a redefinição de senha para o email "usuario@teste.com" + Quando eu acesso o link de redefinição de senha recebido por e-mail + E eu informo a nova senha "123" e confirmo a senha "123" + E eu confirmo a redefinição de senha + Então vejo a mensagem "Falha na redefinição de senha: senha inválida" From a90b97df39665eff76df7523f66d7039b8b583c2 Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Wed, 27 May 2026 21:40:34 -0300 Subject: [PATCH 11/55] feat/ setup sprint-2 --- .gitignore | 1 + Gemfile.lock | 4 +- app/controllers/campo_forms_controller.rb | 70 ++++++++ app/controllers/campos_controller.rb | 70 ++++++++ app/controllers/cursos_controller.rb | 70 ++++++++ app/controllers/departamentos_controller.rb | 70 ++++++++ app/controllers/discentes_controller.rb | 70 ++++++++ app/controllers/disciplinas_controller.rb | 70 ++++++++ app/controllers/docentes_controller.rb | 70 ++++++++ app/controllers/elemento_forms_controller.rb | 70 ++++++++ app/controllers/elementos_controller.rb | 70 ++++++++ app/controllers/formularios_controller.rb | 70 ++++++++ app/controllers/resposta_elems_controller.rb | 70 ++++++++ app/controllers/resposta_forms_controller.rb | 70 ++++++++ app/controllers/templates_controller.rb | 70 ++++++++ app/controllers/turmas_controller.rb | 70 ++++++++ app/controllers/usuarios_controller.rb | 70 ++++++++ app/helpers/campo_forms_helper.rb | 2 + app/helpers/campos_helper.rb | 2 + app/helpers/cursos_helper.rb | 2 + app/helpers/departamentos_helper.rb | 2 + app/helpers/discentes_helper.rb | 2 + app/helpers/disciplinas_helper.rb | 2 + app/helpers/docentes_helper.rb | 2 + app/helpers/elemento_forms_helper.rb | 2 + app/helpers/elementos_helper.rb | 2 + app/helpers/formularios_helper.rb | 2 + app/helpers/resposta_elems_helper.rb | 2 + app/helpers/resposta_forms_helper.rb | 2 + app/helpers/templates_helper.rb | 2 + app/helpers/turmas_helper.rb | 2 + app/helpers/usuarios_helper.rb | 2 + app/models/administrador.rb | 3 + app/models/campo.rb | 6 + app/models/campo_form.rb | 5 + app/models/curso.rb | 6 + app/models/departamento.rb | 7 + app/models/discente.rb | 4 + app/models/disciplina.rb | 6 + app/models/docente.rb | 4 + app/models/elemento.rb | 6 + app/models/elemento_form.rb | 5 + app/models/formulario.rb | 5 + app/models/resposta_elem.rb | 6 + app/models/resposta_form.rb | 9 + app/models/template.rb | 4 + app/models/turma.rb | 11 ++ app/models/usuario.rb | 7 + app/views/campo_forms/_campo_form.html.erb | 17 ++ .../campo_forms/_campo_form.json.jbuilder | 2 + app/views/campo_forms/_form.html.erb | 32 ++++ app/views/campo_forms/edit.html.erb | 12 ++ app/views/campo_forms/index.html.erb | 16 ++ app/views/campo_forms/index.json.jbuilder | 1 + app/views/campo_forms/new.html.erb | 11 ++ app/views/campo_forms/show.html.erb | 10 ++ app/views/campo_forms/show.json.jbuilder | 1 + app/views/campos/_campo.html.erb | 22 +++ app/views/campos/_campo.json.jbuilder | 2 + app/views/campos/_form.html.erb | 37 ++++ app/views/campos/edit.html.erb | 12 ++ app/views/campos/index.html.erb | 16 ++ app/views/campos/index.json.jbuilder | 1 + app/views/campos/new.html.erb | 11 ++ app/views/campos/show.html.erb | 10 ++ app/views/campos/show.json.jbuilder | 1 + app/views/cursos/_curso.html.erb | 17 ++ app/views/cursos/_curso.json.jbuilder | 2 + app/views/cursos/_form.html.erb | 32 ++++ app/views/cursos/edit.html.erb | 12 ++ app/views/cursos/index.html.erb | 16 ++ app/views/cursos/index.json.jbuilder | 1 + app/views/cursos/new.html.erb | 11 ++ app/views/cursos/show.html.erb | 10 ++ app/views/cursos/show.json.jbuilder | 1 + .../departamentos/_departamento.html.erb | 12 ++ .../departamentos/_departamento.json.jbuilder | 2 + app/views/departamentos/_form.html.erb | 27 +++ app/views/departamentos/edit.html.erb | 12 ++ app/views/departamentos/index.html.erb | 16 ++ app/views/departamentos/index.json.jbuilder | 1 + app/views/departamentos/new.html.erb | 11 ++ app/views/departamentos/show.html.erb | 10 ++ app/views/departamentos/show.json.jbuilder | 1 + app/views/discentes/_discente.html.erb | 27 +++ app/views/discentes/_discente.json.jbuilder | 2 + app/views/discentes/_form.html.erb | 42 +++++ app/views/discentes/edit.html.erb | 12 ++ app/views/discentes/index.html.erb | 16 ++ app/views/discentes/index.json.jbuilder | 1 + app/views/discentes/new.html.erb | 11 ++ app/views/discentes/show.html.erb | 10 ++ app/views/discentes/show.json.jbuilder | 1 + app/views/disciplinas/_disciplina.html.erb | 17 ++ .../disciplinas/_disciplina.json.jbuilder | 2 + app/views/disciplinas/_form.html.erb | 32 ++++ app/views/disciplinas/edit.html.erb | 12 ++ app/views/disciplinas/index.html.erb | 16 ++ app/views/disciplinas/index.json.jbuilder | 1 + app/views/disciplinas/new.html.erb | 11 ++ app/views/disciplinas/show.html.erb | 10 ++ app/views/disciplinas/show.json.jbuilder | 1 + app/views/docentes/_docente.html.erb | 22 +++ app/views/docentes/_docente.json.jbuilder | 2 + app/views/docentes/_form.html.erb | 37 ++++ app/views/docentes/edit.html.erb | 12 ++ app/views/docentes/index.html.erb | 16 ++ app/views/docentes/index.json.jbuilder | 1 + app/views/docentes/new.html.erb | 11 ++ app/views/docentes/show.html.erb | 10 ++ app/views/docentes/show.json.jbuilder | 1 + .../elemento_forms/_elemento_form.html.erb | 17 ++ .../_elemento_form.json.jbuilder | 2 + app/views/elemento_forms/_form.html.erb | 32 ++++ app/views/elemento_forms/edit.html.erb | 12 ++ app/views/elemento_forms/index.html.erb | 16 ++ app/views/elemento_forms/index.json.jbuilder | 1 + app/views/elemento_forms/new.html.erb | 11 ++ app/views/elemento_forms/show.html.erb | 10 ++ app/views/elemento_forms/show.json.jbuilder | 1 + app/views/elementos/_elemento.html.erb | 17 ++ app/views/elementos/_elemento.json.jbuilder | 2 + app/views/elementos/_form.html.erb | 32 ++++ app/views/elementos/edit.html.erb | 12 ++ app/views/elementos/index.html.erb | 16 ++ app/views/elementos/index.json.jbuilder | 1 + app/views/elementos/new.html.erb | 11 ++ app/views/elementos/show.html.erb | 10 ++ app/views/elementos/show.json.jbuilder | 1 + app/views/formularios/_form.html.erb | 22 +++ app/views/formularios/_formulario.html.erb | 7 + .../formularios/_formulario.json.jbuilder | 2 + app/views/formularios/edit.html.erb | 12 ++ app/views/formularios/index.html.erb | 16 ++ app/views/formularios/index.json.jbuilder | 1 + app/views/formularios/new.html.erb | 11 ++ app/views/formularios/show.html.erb | 10 ++ app/views/formularios/show.json.jbuilder | 1 + app/views/resposta_elems/_form.html.erb | 37 ++++ .../resposta_elems/_resposta_elem.html.erb | 22 +++ .../_resposta_elem.json.jbuilder | 2 + app/views/resposta_elems/edit.html.erb | 12 ++ app/views/resposta_elems/index.html.erb | 16 ++ app/views/resposta_elems/index.json.jbuilder | 1 + app/views/resposta_elems/new.html.erb | 11 ++ app/views/resposta_elems/show.html.erb | 10 ++ app/views/resposta_elems/show.json.jbuilder | 1 + app/views/resposta_forms/_form.html.erb | 32 ++++ .../resposta_forms/_resposta_form.html.erb | 17 ++ .../_resposta_form.json.jbuilder | 2 + app/views/resposta_forms/edit.html.erb | 12 ++ app/views/resposta_forms/index.html.erb | 16 ++ app/views/resposta_forms/index.json.jbuilder | 1 + app/views/resposta_forms/new.html.erb | 11 ++ app/views/resposta_forms/show.html.erb | 10 ++ app/views/resposta_forms/show.json.jbuilder | 1 + app/views/templates/_form.html.erb | 22 +++ app/views/templates/_template.html.erb | 7 + app/views/templates/_template.json.jbuilder | 2 + app/views/templates/edit.html.erb | 12 ++ app/views/templates/index.html.erb | 16 ++ app/views/templates/index.json.jbuilder | 1 + app/views/templates/new.html.erb | 11 ++ app/views/templates/show.html.erb | 10 ++ app/views/templates/show.json.jbuilder | 1 + app/views/turmas/_form.html.erb | 37 ++++ app/views/turmas/_turma.html.erb | 22 +++ app/views/turmas/_turma.json.jbuilder | 2 + app/views/turmas/edit.html.erb | 12 ++ app/views/turmas/index.html.erb | 16 ++ app/views/turmas/index.json.jbuilder | 1 + app/views/turmas/new.html.erb | 11 ++ app/views/turmas/show.html.erb | 10 ++ app/views/turmas/show.json.jbuilder | 1 + app/views/usuarios/_form.html.erb | 42 +++++ app/views/usuarios/_usuario.html.erb | 27 +++ app/views/usuarios/_usuario.json.jbuilder | 2 + app/views/usuarios/edit.html.erb | 12 ++ app/views/usuarios/index.html.erb | 16 ++ app/views/usuarios/index.json.jbuilder | 1 + app/views/usuarios/new.html.erb | 11 ++ app/views/usuarios/show.html.erb | 10 ++ app/views/usuarios/show.json.jbuilder | 1 + config/database.yml | 6 +- config/routes.rb | 15 ++ .../20260527234832_create_departamentos.rb | 11 ++ db/migrate/20260527234834_create_cursos.rb | 12 ++ .../20260527234836_create_disciplinas.rb | 12 ++ db/migrate/20260527234838_create_turmas.rb | 12 ++ db/migrate/20260527235010_create_usuarios.rb | 17 ++ db/migrate/20260527235026_create_templates.rb | 9 + db/migrate/20260527235028_create_elementos.rb | 11 ++ db/migrate/20260527235031_create_campos.rb | 12 ++ .../20260527235053_create_formularios.rb | 9 + .../20260527235055_create_elemento_forms.rb | 11 ++ .../20260527235057_create_campo_forms.rb | 11 ++ .../20260527235101_create_resposta_forms.rb | 11 ++ .../20260527235104_create_resposta_elems.rb | 12 ++ ...000107_create_join_table_discente_turma.rb | 8 + ...8000109_create_join_table_docente_turma.rb | 8 + .../20260528002258_ajusta_nulos_para_sti.rb | 7 + db/schema.rb | 165 ++++++++++++++++++ spec/helpers/campo_forms_helper_spec.rb | 15 ++ spec/helpers/campos_helper_spec.rb | 15 ++ spec/helpers/cursos_helper_spec.rb | 15 ++ spec/helpers/departamentos_helper_spec.rb | 15 ++ spec/helpers/discentes_helper_spec.rb | 15 ++ spec/helpers/disciplinas_helper_spec.rb | 15 ++ spec/helpers/docentes_helper_spec.rb | 15 ++ spec/helpers/elemento_forms_helper_spec.rb | 15 ++ spec/helpers/elementos_helper_spec.rb | 15 ++ spec/helpers/formularios_helper_spec.rb | 15 ++ spec/helpers/resposta_elems_helper_spec.rb | 15 ++ spec/helpers/resposta_forms_helper_spec.rb | 15 ++ spec/helpers/templates_helper_spec.rb | 15 ++ spec/helpers/turmas_helper_spec.rb | 15 ++ spec/helpers/usuarios_helper_spec.rb | 15 ++ spec/models/campo_form_spec.rb | 5 + spec/models/campo_spec.rb | 5 + spec/models/curso_spec.rb | 5 + spec/models/departamento_spec.rb | 5 + spec/models/disciplina_spec.rb | 5 + spec/models/elemento_form_spec.rb | 5 + spec/models/elemento_spec.rb | 5 + spec/models/formulario_spec.rb | 5 + spec/models/resposta_elem_spec.rb | 5 + spec/models/resposta_form_spec.rb | 5 + spec/models/template_spec.rb | 5 + spec/models/turma_spec.rb | 5 + spec/models/usuario_spec.rb | 5 + spec/requests/campo_forms_spec.rb | 131 ++++++++++++++ spec/requests/campos_spec.rb | 131 ++++++++++++++ spec/requests/cursos_spec.rb | 131 ++++++++++++++ spec/requests/departamentos_spec.rb | 131 ++++++++++++++ spec/requests/discentes_spec.rb | 131 ++++++++++++++ spec/requests/disciplinas_spec.rb | 131 ++++++++++++++ spec/requests/docentes_spec.rb | 131 ++++++++++++++ spec/requests/elemento_forms_spec.rb | 131 ++++++++++++++ spec/requests/elementos_spec.rb | 131 ++++++++++++++ spec/requests/formularios_spec.rb | 131 ++++++++++++++ spec/requests/resposta_elems_spec.rb | 131 ++++++++++++++ spec/requests/resposta_forms_spec.rb | 131 ++++++++++++++ spec/requests/templates_spec.rb | 131 ++++++++++++++ spec/requests/turmas_spec.rb | 131 ++++++++++++++ spec/requests/usuarios_spec.rb | 131 ++++++++++++++ spec/routing/campo_forms_routing_spec.rb | 38 ++++ spec/routing/campos_routing_spec.rb | 38 ++++ spec/routing/cursos_routing_spec.rb | 38 ++++ spec/routing/departamentos_routing_spec.rb | 38 ++++ spec/routing/discentes_routing_spec.rb | 38 ++++ spec/routing/disciplinas_routing_spec.rb | 38 ++++ spec/routing/docentes_routing_spec.rb | 38 ++++ spec/routing/elemento_forms_routing_spec.rb | 38 ++++ spec/routing/elementos_routing_spec.rb | 38 ++++ spec/routing/formularios_routing_spec.rb | 38 ++++ spec/routing/resposta_elems_routing_spec.rb | 38 ++++ spec/routing/resposta_forms_routing_spec.rb | 38 ++++ spec/routing/templates_routing_spec.rb | 38 ++++ spec/routing/turmas_routing_spec.rb | 38 ++++ spec/routing/usuarios_routing_spec.rb | 38 ++++ spec/views/campo_forms/edit.html.erb_spec.rb | 28 +++ spec/views/campo_forms/index.html.erb_spec.rb | 26 +++ spec/views/campo_forms/new.html.erb_spec.rb | 24 +++ spec/views/campo_forms/show.html.erb_spec.rb | 18 ++ spec/views/campos/edit.html.erb_spec.rb | 31 ++++ spec/views/campos/index.html.erb_spec.rb | 29 +++ spec/views/campos/new.html.erb_spec.rb | 27 +++ spec/views/campos/show.html.erb_spec.rb | 20 +++ spec/views/cursos/edit.html.erb_spec.rb | 28 +++ spec/views/cursos/index.html.erb_spec.rb | 26 +++ spec/views/cursos/new.html.erb_spec.rb | 24 +++ spec/views/cursos/show.html.erb_spec.rb | 18 ++ .../views/departamentos/edit.html.erb_spec.rb | 25 +++ .../departamentos/index.html.erb_spec.rb | 23 +++ spec/views/departamentos/new.html.erb_spec.rb | 21 +++ .../views/departamentos/show.html.erb_spec.rb | 16 ++ spec/views/discentes/edit.html.erb_spec.rb | 34 ++++ spec/views/discentes/index.html.erb_spec.rb | 32 ++++ spec/views/discentes/new.html.erb_spec.rb | 30 ++++ spec/views/discentes/show.html.erb_spec.rb | 22 +++ spec/views/disciplinas/edit.html.erb_spec.rb | 28 +++ spec/views/disciplinas/index.html.erb_spec.rb | 26 +++ spec/views/disciplinas/new.html.erb_spec.rb | 24 +++ spec/views/disciplinas/show.html.erb_spec.rb | 18 ++ spec/views/docentes/edit.html.erb_spec.rb | 31 ++++ spec/views/docentes/index.html.erb_spec.rb | 29 +++ spec/views/docentes/new.html.erb_spec.rb | 27 +++ spec/views/docentes/show.html.erb_spec.rb | 20 +++ .../elemento_forms/edit.html.erb_spec.rb | 28 +++ .../elemento_forms/index.html.erb_spec.rb | 26 +++ .../views/elemento_forms/new.html.erb_spec.rb | 24 +++ .../elemento_forms/show.html.erb_spec.rb | 18 ++ spec/views/elementos/edit.html.erb_spec.rb | 28 +++ spec/views/elementos/index.html.erb_spec.rb | 26 +++ spec/views/elementos/new.html.erb_spec.rb | 24 +++ spec/views/elementos/show.html.erb_spec.rb | 18 ++ spec/views/formularios/edit.html.erb_spec.rb | 22 +++ spec/views/formularios/index.html.erb_spec.rb | 20 +++ spec/views/formularios/new.html.erb_spec.rb | 18 ++ spec/views/formularios/show.html.erb_spec.rb | 14 ++ .../resposta_elems/edit.html.erb_spec.rb | 31 ++++ .../resposta_elems/index.html.erb_spec.rb | 29 +++ .../views/resposta_elems/new.html.erb_spec.rb | 27 +++ .../resposta_elems/show.html.erb_spec.rb | 20 +++ .../resposta_forms/edit.html.erb_spec.rb | 25 +++ .../resposta_forms/index.html.erb_spec.rb | 23 +++ .../views/resposta_forms/new.html.erb_spec.rb | 21 +++ .../resposta_forms/show.html.erb_spec.rb | 16 ++ spec/views/templates/edit.html.erb_spec.rb | 22 +++ spec/views/templates/index.html.erb_spec.rb | 20 +++ spec/views/templates/new.html.erb_spec.rb | 18 ++ spec/views/templates/show.html.erb_spec.rb | 14 ++ spec/views/turmas/edit.html.erb_spec.rb | 31 ++++ spec/views/turmas/index.html.erb_spec.rb | 29 +++ spec/views/turmas/new.html.erb_spec.rb | 27 +++ spec/views/turmas/show.html.erb_spec.rb | 20 +++ spec/views/usuarios/edit.html.erb_spec.rb | 34 ++++ spec/views/usuarios/index.html.erb_spec.rb | 32 ++++ spec/views/usuarios/new.html.erb_spec.rb | 30 ++++ spec/views/usuarios/show.html.erb_spec.rb | 22 +++ 320 files changed, 7380 insertions(+), 5 deletions(-) create mode 100644 app/controllers/campo_forms_controller.rb create mode 100644 app/controllers/campos_controller.rb create mode 100644 app/controllers/cursos_controller.rb create mode 100644 app/controllers/departamentos_controller.rb create mode 100644 app/controllers/discentes_controller.rb create mode 100644 app/controllers/disciplinas_controller.rb create mode 100644 app/controllers/docentes_controller.rb create mode 100644 app/controllers/elemento_forms_controller.rb create mode 100644 app/controllers/elementos_controller.rb create mode 100644 app/controllers/formularios_controller.rb create mode 100644 app/controllers/resposta_elems_controller.rb create mode 100644 app/controllers/resposta_forms_controller.rb create mode 100644 app/controllers/templates_controller.rb create mode 100644 app/controllers/turmas_controller.rb create mode 100644 app/controllers/usuarios_controller.rb create mode 100644 app/helpers/campo_forms_helper.rb create mode 100644 app/helpers/campos_helper.rb create mode 100644 app/helpers/cursos_helper.rb create mode 100644 app/helpers/departamentos_helper.rb create mode 100644 app/helpers/discentes_helper.rb create mode 100644 app/helpers/disciplinas_helper.rb create mode 100644 app/helpers/docentes_helper.rb create mode 100644 app/helpers/elemento_forms_helper.rb create mode 100644 app/helpers/elementos_helper.rb create mode 100644 app/helpers/formularios_helper.rb create mode 100644 app/helpers/resposta_elems_helper.rb create mode 100644 app/helpers/resposta_forms_helper.rb create mode 100644 app/helpers/templates_helper.rb create mode 100644 app/helpers/turmas_helper.rb create mode 100644 app/helpers/usuarios_helper.rb create mode 100644 app/models/administrador.rb create mode 100644 app/models/campo.rb create mode 100644 app/models/campo_form.rb create mode 100644 app/models/curso.rb create mode 100644 app/models/departamento.rb create mode 100644 app/models/discente.rb create mode 100644 app/models/disciplina.rb create mode 100644 app/models/docente.rb create mode 100644 app/models/elemento.rb create mode 100644 app/models/elemento_form.rb create mode 100644 app/models/formulario.rb create mode 100644 app/models/resposta_elem.rb create mode 100644 app/models/resposta_form.rb create mode 100644 app/models/template.rb create mode 100644 app/models/turma.rb create mode 100644 app/models/usuario.rb create mode 100644 app/views/campo_forms/_campo_form.html.erb create mode 100644 app/views/campo_forms/_campo_form.json.jbuilder create mode 100644 app/views/campo_forms/_form.html.erb create mode 100644 app/views/campo_forms/edit.html.erb create mode 100644 app/views/campo_forms/index.html.erb create mode 100644 app/views/campo_forms/index.json.jbuilder create mode 100644 app/views/campo_forms/new.html.erb create mode 100644 app/views/campo_forms/show.html.erb create mode 100644 app/views/campo_forms/show.json.jbuilder create mode 100644 app/views/campos/_campo.html.erb create mode 100644 app/views/campos/_campo.json.jbuilder create mode 100644 app/views/campos/_form.html.erb create mode 100644 app/views/campos/edit.html.erb create mode 100644 app/views/campos/index.html.erb create mode 100644 app/views/campos/index.json.jbuilder create mode 100644 app/views/campos/new.html.erb create mode 100644 app/views/campos/show.html.erb create mode 100644 app/views/campos/show.json.jbuilder create mode 100644 app/views/cursos/_curso.html.erb create mode 100644 app/views/cursos/_curso.json.jbuilder create mode 100644 app/views/cursos/_form.html.erb create mode 100644 app/views/cursos/edit.html.erb create mode 100644 app/views/cursos/index.html.erb create mode 100644 app/views/cursos/index.json.jbuilder create mode 100644 app/views/cursos/new.html.erb create mode 100644 app/views/cursos/show.html.erb create mode 100644 app/views/cursos/show.json.jbuilder create mode 100644 app/views/departamentos/_departamento.html.erb create mode 100644 app/views/departamentos/_departamento.json.jbuilder create mode 100644 app/views/departamentos/_form.html.erb create mode 100644 app/views/departamentos/edit.html.erb create mode 100644 app/views/departamentos/index.html.erb create mode 100644 app/views/departamentos/index.json.jbuilder create mode 100644 app/views/departamentos/new.html.erb create mode 100644 app/views/departamentos/show.html.erb create mode 100644 app/views/departamentos/show.json.jbuilder create mode 100644 app/views/discentes/_discente.html.erb create mode 100644 app/views/discentes/_discente.json.jbuilder create mode 100644 app/views/discentes/_form.html.erb create mode 100644 app/views/discentes/edit.html.erb create mode 100644 app/views/discentes/index.html.erb create mode 100644 app/views/discentes/index.json.jbuilder create mode 100644 app/views/discentes/new.html.erb create mode 100644 app/views/discentes/show.html.erb create mode 100644 app/views/discentes/show.json.jbuilder create mode 100644 app/views/disciplinas/_disciplina.html.erb create mode 100644 app/views/disciplinas/_disciplina.json.jbuilder create mode 100644 app/views/disciplinas/_form.html.erb create mode 100644 app/views/disciplinas/edit.html.erb create mode 100644 app/views/disciplinas/index.html.erb create mode 100644 app/views/disciplinas/index.json.jbuilder create mode 100644 app/views/disciplinas/new.html.erb create mode 100644 app/views/disciplinas/show.html.erb create mode 100644 app/views/disciplinas/show.json.jbuilder create mode 100644 app/views/docentes/_docente.html.erb create mode 100644 app/views/docentes/_docente.json.jbuilder create mode 100644 app/views/docentes/_form.html.erb create mode 100644 app/views/docentes/edit.html.erb create mode 100644 app/views/docentes/index.html.erb create mode 100644 app/views/docentes/index.json.jbuilder create mode 100644 app/views/docentes/new.html.erb create mode 100644 app/views/docentes/show.html.erb create mode 100644 app/views/docentes/show.json.jbuilder create mode 100644 app/views/elemento_forms/_elemento_form.html.erb create mode 100644 app/views/elemento_forms/_elemento_form.json.jbuilder create mode 100644 app/views/elemento_forms/_form.html.erb create mode 100644 app/views/elemento_forms/edit.html.erb create mode 100644 app/views/elemento_forms/index.html.erb create mode 100644 app/views/elemento_forms/index.json.jbuilder create mode 100644 app/views/elemento_forms/new.html.erb create mode 100644 app/views/elemento_forms/show.html.erb create mode 100644 app/views/elemento_forms/show.json.jbuilder create mode 100644 app/views/elementos/_elemento.html.erb create mode 100644 app/views/elementos/_elemento.json.jbuilder create mode 100644 app/views/elementos/_form.html.erb create mode 100644 app/views/elementos/edit.html.erb create mode 100644 app/views/elementos/index.html.erb create mode 100644 app/views/elementos/index.json.jbuilder create mode 100644 app/views/elementos/new.html.erb create mode 100644 app/views/elementos/show.html.erb create mode 100644 app/views/elementos/show.json.jbuilder create mode 100644 app/views/formularios/_form.html.erb create mode 100644 app/views/formularios/_formulario.html.erb create mode 100644 app/views/formularios/_formulario.json.jbuilder create mode 100644 app/views/formularios/edit.html.erb create mode 100644 app/views/formularios/index.html.erb create mode 100644 app/views/formularios/index.json.jbuilder create mode 100644 app/views/formularios/new.html.erb create mode 100644 app/views/formularios/show.html.erb create mode 100644 app/views/formularios/show.json.jbuilder create mode 100644 app/views/resposta_elems/_form.html.erb create mode 100644 app/views/resposta_elems/_resposta_elem.html.erb create mode 100644 app/views/resposta_elems/_resposta_elem.json.jbuilder create mode 100644 app/views/resposta_elems/edit.html.erb create mode 100644 app/views/resposta_elems/index.html.erb create mode 100644 app/views/resposta_elems/index.json.jbuilder create mode 100644 app/views/resposta_elems/new.html.erb create mode 100644 app/views/resposta_elems/show.html.erb create mode 100644 app/views/resposta_elems/show.json.jbuilder create mode 100644 app/views/resposta_forms/_form.html.erb create mode 100644 app/views/resposta_forms/_resposta_form.html.erb create mode 100644 app/views/resposta_forms/_resposta_form.json.jbuilder create mode 100644 app/views/resposta_forms/edit.html.erb create mode 100644 app/views/resposta_forms/index.html.erb create mode 100644 app/views/resposta_forms/index.json.jbuilder create mode 100644 app/views/resposta_forms/new.html.erb create mode 100644 app/views/resposta_forms/show.html.erb create mode 100644 app/views/resposta_forms/show.json.jbuilder create mode 100644 app/views/templates/_form.html.erb create mode 100644 app/views/templates/_template.html.erb create mode 100644 app/views/templates/_template.json.jbuilder create mode 100644 app/views/templates/edit.html.erb create mode 100644 app/views/templates/index.html.erb create mode 100644 app/views/templates/index.json.jbuilder create mode 100644 app/views/templates/new.html.erb create mode 100644 app/views/templates/show.html.erb create mode 100644 app/views/templates/show.json.jbuilder create mode 100644 app/views/turmas/_form.html.erb create mode 100644 app/views/turmas/_turma.html.erb create mode 100644 app/views/turmas/_turma.json.jbuilder create mode 100644 app/views/turmas/edit.html.erb create mode 100644 app/views/turmas/index.html.erb create mode 100644 app/views/turmas/index.json.jbuilder create mode 100644 app/views/turmas/new.html.erb create mode 100644 app/views/turmas/show.html.erb create mode 100644 app/views/turmas/show.json.jbuilder create mode 100644 app/views/usuarios/_form.html.erb create mode 100644 app/views/usuarios/_usuario.html.erb create mode 100644 app/views/usuarios/_usuario.json.jbuilder create mode 100644 app/views/usuarios/edit.html.erb create mode 100644 app/views/usuarios/index.html.erb create mode 100644 app/views/usuarios/index.json.jbuilder create mode 100644 app/views/usuarios/new.html.erb create mode 100644 app/views/usuarios/show.html.erb create mode 100644 app/views/usuarios/show.json.jbuilder create mode 100644 db/migrate/20260527234832_create_departamentos.rb create mode 100644 db/migrate/20260527234834_create_cursos.rb create mode 100644 db/migrate/20260527234836_create_disciplinas.rb create mode 100644 db/migrate/20260527234838_create_turmas.rb create mode 100644 db/migrate/20260527235010_create_usuarios.rb create mode 100644 db/migrate/20260527235026_create_templates.rb create mode 100644 db/migrate/20260527235028_create_elementos.rb create mode 100644 db/migrate/20260527235031_create_campos.rb create mode 100644 db/migrate/20260527235053_create_formularios.rb create mode 100644 db/migrate/20260527235055_create_elemento_forms.rb create mode 100644 db/migrate/20260527235057_create_campo_forms.rb create mode 100644 db/migrate/20260527235101_create_resposta_forms.rb create mode 100644 db/migrate/20260527235104_create_resposta_elems.rb create mode 100644 db/migrate/20260528000107_create_join_table_discente_turma.rb create mode 100644 db/migrate/20260528000109_create_join_table_docente_turma.rb create mode 100644 db/migrate/20260528002258_ajusta_nulos_para_sti.rb create mode 100644 db/schema.rb create mode 100644 spec/helpers/campo_forms_helper_spec.rb create mode 100644 spec/helpers/campos_helper_spec.rb create mode 100644 spec/helpers/cursos_helper_spec.rb create mode 100644 spec/helpers/departamentos_helper_spec.rb create mode 100644 spec/helpers/discentes_helper_spec.rb create mode 100644 spec/helpers/disciplinas_helper_spec.rb create mode 100644 spec/helpers/docentes_helper_spec.rb create mode 100644 spec/helpers/elemento_forms_helper_spec.rb create mode 100644 spec/helpers/elementos_helper_spec.rb create mode 100644 spec/helpers/formularios_helper_spec.rb create mode 100644 spec/helpers/resposta_elems_helper_spec.rb create mode 100644 spec/helpers/resposta_forms_helper_spec.rb create mode 100644 spec/helpers/templates_helper_spec.rb create mode 100644 spec/helpers/turmas_helper_spec.rb create mode 100644 spec/helpers/usuarios_helper_spec.rb create mode 100644 spec/models/campo_form_spec.rb create mode 100644 spec/models/campo_spec.rb create mode 100644 spec/models/curso_spec.rb create mode 100644 spec/models/departamento_spec.rb create mode 100644 spec/models/disciplina_spec.rb create mode 100644 spec/models/elemento_form_spec.rb create mode 100644 spec/models/elemento_spec.rb create mode 100644 spec/models/formulario_spec.rb create mode 100644 spec/models/resposta_elem_spec.rb create mode 100644 spec/models/resposta_form_spec.rb create mode 100644 spec/models/template_spec.rb create mode 100644 spec/models/turma_spec.rb create mode 100644 spec/models/usuario_spec.rb create mode 100644 spec/requests/campo_forms_spec.rb create mode 100644 spec/requests/campos_spec.rb create mode 100644 spec/requests/cursos_spec.rb create mode 100644 spec/requests/departamentos_spec.rb create mode 100644 spec/requests/discentes_spec.rb create mode 100644 spec/requests/disciplinas_spec.rb create mode 100644 spec/requests/docentes_spec.rb create mode 100644 spec/requests/elemento_forms_spec.rb create mode 100644 spec/requests/elementos_spec.rb create mode 100644 spec/requests/formularios_spec.rb create mode 100644 spec/requests/resposta_elems_spec.rb create mode 100644 spec/requests/resposta_forms_spec.rb create mode 100644 spec/requests/templates_spec.rb create mode 100644 spec/requests/turmas_spec.rb create mode 100644 spec/requests/usuarios_spec.rb create mode 100644 spec/routing/campo_forms_routing_spec.rb create mode 100644 spec/routing/campos_routing_spec.rb create mode 100644 spec/routing/cursos_routing_spec.rb create mode 100644 spec/routing/departamentos_routing_spec.rb create mode 100644 spec/routing/discentes_routing_spec.rb create mode 100644 spec/routing/disciplinas_routing_spec.rb create mode 100644 spec/routing/docentes_routing_spec.rb create mode 100644 spec/routing/elemento_forms_routing_spec.rb create mode 100644 spec/routing/elementos_routing_spec.rb create mode 100644 spec/routing/formularios_routing_spec.rb create mode 100644 spec/routing/resposta_elems_routing_spec.rb create mode 100644 spec/routing/resposta_forms_routing_spec.rb create mode 100644 spec/routing/templates_routing_spec.rb create mode 100644 spec/routing/turmas_routing_spec.rb create mode 100644 spec/routing/usuarios_routing_spec.rb create mode 100644 spec/views/campo_forms/edit.html.erb_spec.rb create mode 100644 spec/views/campo_forms/index.html.erb_spec.rb create mode 100644 spec/views/campo_forms/new.html.erb_spec.rb create mode 100644 spec/views/campo_forms/show.html.erb_spec.rb create mode 100644 spec/views/campos/edit.html.erb_spec.rb create mode 100644 spec/views/campos/index.html.erb_spec.rb create mode 100644 spec/views/campos/new.html.erb_spec.rb create mode 100644 spec/views/campos/show.html.erb_spec.rb create mode 100644 spec/views/cursos/edit.html.erb_spec.rb create mode 100644 spec/views/cursos/index.html.erb_spec.rb create mode 100644 spec/views/cursos/new.html.erb_spec.rb create mode 100644 spec/views/cursos/show.html.erb_spec.rb create mode 100644 spec/views/departamentos/edit.html.erb_spec.rb create mode 100644 spec/views/departamentos/index.html.erb_spec.rb create mode 100644 spec/views/departamentos/new.html.erb_spec.rb create mode 100644 spec/views/departamentos/show.html.erb_spec.rb create mode 100644 spec/views/discentes/edit.html.erb_spec.rb create mode 100644 spec/views/discentes/index.html.erb_spec.rb create mode 100644 spec/views/discentes/new.html.erb_spec.rb create mode 100644 spec/views/discentes/show.html.erb_spec.rb create mode 100644 spec/views/disciplinas/edit.html.erb_spec.rb create mode 100644 spec/views/disciplinas/index.html.erb_spec.rb create mode 100644 spec/views/disciplinas/new.html.erb_spec.rb create mode 100644 spec/views/disciplinas/show.html.erb_spec.rb create mode 100644 spec/views/docentes/edit.html.erb_spec.rb create mode 100644 spec/views/docentes/index.html.erb_spec.rb create mode 100644 spec/views/docentes/new.html.erb_spec.rb create mode 100644 spec/views/docentes/show.html.erb_spec.rb create mode 100644 spec/views/elemento_forms/edit.html.erb_spec.rb create mode 100644 spec/views/elemento_forms/index.html.erb_spec.rb create mode 100644 spec/views/elemento_forms/new.html.erb_spec.rb create mode 100644 spec/views/elemento_forms/show.html.erb_spec.rb create mode 100644 spec/views/elementos/edit.html.erb_spec.rb create mode 100644 spec/views/elementos/index.html.erb_spec.rb create mode 100644 spec/views/elementos/new.html.erb_spec.rb create mode 100644 spec/views/elementos/show.html.erb_spec.rb create mode 100644 spec/views/formularios/edit.html.erb_spec.rb create mode 100644 spec/views/formularios/index.html.erb_spec.rb create mode 100644 spec/views/formularios/new.html.erb_spec.rb create mode 100644 spec/views/formularios/show.html.erb_spec.rb create mode 100644 spec/views/resposta_elems/edit.html.erb_spec.rb create mode 100644 spec/views/resposta_elems/index.html.erb_spec.rb create mode 100644 spec/views/resposta_elems/new.html.erb_spec.rb create mode 100644 spec/views/resposta_elems/show.html.erb_spec.rb create mode 100644 spec/views/resposta_forms/edit.html.erb_spec.rb create mode 100644 spec/views/resposta_forms/index.html.erb_spec.rb create mode 100644 spec/views/resposta_forms/new.html.erb_spec.rb create mode 100644 spec/views/resposta_forms/show.html.erb_spec.rb create mode 100644 spec/views/templates/edit.html.erb_spec.rb create mode 100644 spec/views/templates/index.html.erb_spec.rb create mode 100644 spec/views/templates/new.html.erb_spec.rb create mode 100644 spec/views/templates/show.html.erb_spec.rb create mode 100644 spec/views/turmas/edit.html.erb_spec.rb create mode 100644 spec/views/turmas/index.html.erb_spec.rb create mode 100644 spec/views/turmas/new.html.erb_spec.rb create mode 100644 spec/views/turmas/show.html.erb_spec.rb create mode 100644 spec/views/usuarios/edit.html.erb_spec.rb create mode 100644 spec/views/usuarios/index.html.erb_spec.rb create mode 100644 spec/views/usuarios/new.html.erb_spec.rb create mode 100644 spec/views/usuarios/show.html.erb_spec.rb diff --git a/.gitignore b/.gitignore index d1811d6ec7..7158ded4dd 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ # Ignore key files for decrypting credentials and more. /config/*.key +/vendor/bundle diff --git a/Gemfile.lock b/Gemfile.lock index e159082878..56c83cb28b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -246,7 +246,7 @@ GEM nokogiri (1.19.3-x86_64-linux-musl) racc (~> 1.4) ostruct (0.6.3) - parallel (2.1.0) + parallel (1.28.0) parser (3.3.11.1) ast (~> 2.4.1) racc @@ -570,7 +570,7 @@ CHECKSUMS nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976 nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912 - parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356 + parallel (1.28.0) sha256=33e6de1484baf2524792d178b0913fc8eb94c628d6cfe45599ad4458c638c970 parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54 pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6 prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193 diff --git a/app/controllers/campo_forms_controller.rb b/app/controllers/campo_forms_controller.rb new file mode 100644 index 0000000000..de491c59e0 --- /dev/null +++ b/app/controllers/campo_forms_controller.rb @@ -0,0 +1,70 @@ +class CampoFormsController < ApplicationController + before_action :set_campo_form, only: %i[ show edit update destroy ] + + # GET /campo_forms or /campo_forms.json + def index + @campo_forms = CampoForm.all + end + + # GET /campo_forms/1 or /campo_forms/1.json + def show + end + + # GET /campo_forms/new + def new + @campo_form = CampoForm.new + end + + # GET /campo_forms/1/edit + def edit + end + + # POST /campo_forms or /campo_forms.json + def create + @campo_form = CampoForm.new(campo_form_params) + + respond_to do |format| + if @campo_form.save + format.html { redirect_to @campo_form, notice: "Campo form was successfully created." } + format.json { render :show, status: :created, location: @campo_form } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @campo_form.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /campo_forms/1 or /campo_forms/1.json + def update + respond_to do |format| + if @campo_form.update(campo_form_params) + format.html { redirect_to @campo_form, notice: "Campo form was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @campo_form } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @campo_form.errors, status: :unprocessable_content } + end + end + end + + # DELETE /campo_forms/1 or /campo_forms/1.json + def destroy + @campo_form.destroy! + + respond_to do |format| + format.html { redirect_to campo_forms_path, notice: "Campo form was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_campo_form + @campo_form = CampoForm.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def campo_form_params + params.expect(campo_form: [ :ordem, :enunciado, :elemento_form_id ]) + end +end diff --git a/app/controllers/campos_controller.rb b/app/controllers/campos_controller.rb new file mode 100644 index 0000000000..cabefcb40d --- /dev/null +++ b/app/controllers/campos_controller.rb @@ -0,0 +1,70 @@ +class CamposController < ApplicationController + before_action :set_campo, only: %i[ show edit update destroy ] + + # GET /campos or /campos.json + def index + @campos = Campo.all + end + + # GET /campos/1 or /campos/1.json + def show + end + + # GET /campos/new + def new + @campo = Campo.new + end + + # GET /campos/1/edit + def edit + end + + # POST /campos or /campos.json + def create + @campo = Campo.new(campo_params) + + respond_to do |format| + if @campo.save + format.html { redirect_to @campo, notice: "Campo was successfully created." } + format.json { render :show, status: :created, location: @campo } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @campo.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /campos/1 or /campos/1.json + def update + respond_to do |format| + if @campo.update(campo_params) + format.html { redirect_to @campo, notice: "Campo was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @campo } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @campo.errors, status: :unprocessable_content } + end + end + end + + # DELETE /campos/1 or /campos/1.json + def destroy + @campo.destroy! + + respond_to do |format| + format.html { redirect_to campos_path, notice: "Campo was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_campo + @campo = Campo.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def campo_params + params.expect(campo: [ :ordem, :enunciado, :tipo_elemento, :elemento_id ]) + end +end diff --git a/app/controllers/cursos_controller.rb b/app/controllers/cursos_controller.rb new file mode 100644 index 0000000000..afdf4d6e91 --- /dev/null +++ b/app/controllers/cursos_controller.rb @@ -0,0 +1,70 @@ +class CursosController < ApplicationController + before_action :set_curso, only: %i[ show edit update destroy ] + + # GET /cursos or /cursos.json + def index + @cursos = Curso.all + end + + # GET /cursos/1 or /cursos/1.json + def show + end + + # GET /cursos/new + def new + @curso = Curso.new + end + + # GET /cursos/1/edit + def edit + end + + # POST /cursos or /cursos.json + def create + @curso = Curso.new(curso_params) + + respond_to do |format| + if @curso.save + format.html { redirect_to @curso, notice: "Curso was successfully created." } + format.json { render :show, status: :created, location: @curso } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @curso.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /cursos/1 or /cursos/1.json + def update + respond_to do |format| + if @curso.update(curso_params) + format.html { redirect_to @curso, notice: "Curso was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @curso } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @curso.errors, status: :unprocessable_content } + end + end + end + + # DELETE /cursos/1 or /cursos/1.json + def destroy + @curso.destroy! + + respond_to do |format| + format.html { redirect_to cursos_path, notice: "Curso was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_curso + @curso = Curso.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def curso_params + params.expect(curso: [ :codigo, :nome, :departamento_id ]) + end +end diff --git a/app/controllers/departamentos_controller.rb b/app/controllers/departamentos_controller.rb new file mode 100644 index 0000000000..106c61bf2b --- /dev/null +++ b/app/controllers/departamentos_controller.rb @@ -0,0 +1,70 @@ +class DepartamentosController < ApplicationController + before_action :set_departamento, only: %i[ show edit update destroy ] + + # GET /departamentos or /departamentos.json + def index + @departamentos = Departamento.all + end + + # GET /departamentos/1 or /departamentos/1.json + def show + end + + # GET /departamentos/new + def new + @departamento = Departamento.new + end + + # GET /departamentos/1/edit + def edit + end + + # POST /departamentos or /departamentos.json + def create + @departamento = Departamento.new(departamento_params) + + respond_to do |format| + if @departamento.save + format.html { redirect_to @departamento, notice: "Departamento was successfully created." } + format.json { render :show, status: :created, location: @departamento } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @departamento.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /departamentos/1 or /departamentos/1.json + def update + respond_to do |format| + if @departamento.update(departamento_params) + format.html { redirect_to @departamento, notice: "Departamento was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @departamento } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @departamento.errors, status: :unprocessable_content } + end + end + end + + # DELETE /departamentos/1 or /departamentos/1.json + def destroy + @departamento.destroy! + + respond_to do |format| + format.html { redirect_to departamentos_path, notice: "Departamento was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_departamento + @departamento = Departamento.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def departamento_params + params.expect(departamento: [ :codigo, :nome ]) + end +end diff --git a/app/controllers/discentes_controller.rb b/app/controllers/discentes_controller.rb new file mode 100644 index 0000000000..08d886207d --- /dev/null +++ b/app/controllers/discentes_controller.rb @@ -0,0 +1,70 @@ +class DiscentesController < ApplicationController + before_action :set_discente, only: %i[ show edit update destroy ] + + # GET /discentes or /discentes.json + def index + @discentes = Discente.all + end + + # GET /discentes/1 or /discentes/1.json + def show + end + + # GET /discentes/new + def new + @discente = Discente.new + end + + # GET /discentes/1/edit + def edit + end + + # POST /discentes or /discentes.json + def create + @discente = Discente.new(discente_params) + + respond_to do |format| + if @discente.save + format.html { redirect_to @discente, notice: "Discente was successfully created." } + format.json { render :show, status: :created, location: @discente } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @discente.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /discentes/1 or /discentes/1.json + def update + respond_to do |format| + if @discente.update(discente_params) + format.html { redirect_to @discente, notice: "Discente was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @discente } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @discente.errors, status: :unprocessable_content } + end + end + end + + # DELETE /discentes/1 or /discentes/1.json + def destroy + @discente.destroy! + + respond_to do |format| + format.html { redirect_to discentes_path, notice: "Discente was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_discente + @discente = Discente.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def discente_params + params.expect(discente: [ :matricula, :email, :nome, :formacao, :curso_id ]) + end +end diff --git a/app/controllers/disciplinas_controller.rb b/app/controllers/disciplinas_controller.rb new file mode 100644 index 0000000000..5938a50d91 --- /dev/null +++ b/app/controllers/disciplinas_controller.rb @@ -0,0 +1,70 @@ +class DisciplinasController < ApplicationController + before_action :set_disciplina, only: %i[ show edit update destroy ] + + # GET /disciplinas or /disciplinas.json + def index + @disciplinas = Disciplina.all + end + + # GET /disciplinas/1 or /disciplinas/1.json + def show + end + + # GET /disciplinas/new + def new + @disciplina = Disciplina.new + end + + # GET /disciplinas/1/edit + def edit + end + + # POST /disciplinas or /disciplinas.json + def create + @disciplina = Disciplina.new(disciplina_params) + + respond_to do |format| + if @disciplina.save + format.html { redirect_to @disciplina, notice: "Disciplina was successfully created." } + format.json { render :show, status: :created, location: @disciplina } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @disciplina.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /disciplinas/1 or /disciplinas/1.json + def update + respond_to do |format| + if @disciplina.update(disciplina_params) + format.html { redirect_to @disciplina, notice: "Disciplina was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @disciplina } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @disciplina.errors, status: :unprocessable_content } + end + end + end + + # DELETE /disciplinas/1 or /disciplinas/1.json + def destroy + @disciplina.destroy! + + respond_to do |format| + format.html { redirect_to disciplinas_path, notice: "Disciplina was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_disciplina + @disciplina = Disciplina.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def disciplina_params + params.expect(disciplina: [ :codigo, :nome, :departamento_id ]) + end +end diff --git a/app/controllers/docentes_controller.rb b/app/controllers/docentes_controller.rb new file mode 100644 index 0000000000..2fc30c57d8 --- /dev/null +++ b/app/controllers/docentes_controller.rb @@ -0,0 +1,70 @@ +class DocentesController < ApplicationController + before_action :set_docente, only: %i[ show edit update destroy ] + + # GET /docentes or /docentes.json + def index + @docentes = Docente.all + end + + # GET /docentes/1 or /docentes/1.json + def show + end + + # GET /docentes/new + def new + @docente = Docente.new + end + + # GET /docentes/1/edit + def edit + end + + # POST /docentes or /docentes.json + def create + @docente = Docente.new(docente_params) + + respond_to do |format| + if @docente.save + format.html { redirect_to @docente, notice: "Docente was successfully created." } + format.json { render :show, status: :created, location: @docente } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @docente.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /docentes/1 or /docentes/1.json + def update + respond_to do |format| + if @docente.update(docente_params) + format.html { redirect_to @docente, notice: "Docente was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @docente } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @docente.errors, status: :unprocessable_content } + end + end + end + + # DELETE /docentes/1 or /docentes/1.json + def destroy + @docente.destroy! + + respond_to do |format| + format.html { redirect_to docentes_path, notice: "Docente was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_docente + @docente = Docente.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def docente_params + params.expect(docente: [ :matricula, :email, :nome, :formacao ]) + end +end diff --git a/app/controllers/elemento_forms_controller.rb b/app/controllers/elemento_forms_controller.rb new file mode 100644 index 0000000000..355d9573ff --- /dev/null +++ b/app/controllers/elemento_forms_controller.rb @@ -0,0 +1,70 @@ +class ElementoFormsController < ApplicationController + before_action :set_elemento_form, only: %i[ show edit update destroy ] + + # GET /elemento_forms or /elemento_forms.json + def index + @elemento_forms = ElementoForm.all + end + + # GET /elemento_forms/1 or /elemento_forms/1.json + def show + end + + # GET /elemento_forms/new + def new + @elemento_form = ElementoForm.new + end + + # GET /elemento_forms/1/edit + def edit + end + + # POST /elemento_forms or /elemento_forms.json + def create + @elemento_form = ElementoForm.new(elemento_form_params) + + respond_to do |format| + if @elemento_form.save + format.html { redirect_to @elemento_form, notice: "Elemento form was successfully created." } + format.json { render :show, status: :created, location: @elemento_form } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @elemento_form.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /elemento_forms/1 or /elemento_forms/1.json + def update + respond_to do |format| + if @elemento_form.update(elemento_form_params) + format.html { redirect_to @elemento_form, notice: "Elemento form was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @elemento_form } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @elemento_form.errors, status: :unprocessable_content } + end + end + end + + # DELETE /elemento_forms/1 or /elemento_forms/1.json + def destroy + @elemento_form.destroy! + + respond_to do |format| + format.html { redirect_to elemento_forms_path, notice: "Elemento form was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_elemento_form + @elemento_form = ElementoForm.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def elemento_form_params + params.expect(elemento_form: [ :ordem, :enunciado, :formulario_id ]) + end +end diff --git a/app/controllers/elementos_controller.rb b/app/controllers/elementos_controller.rb new file mode 100644 index 0000000000..4357f9c17a --- /dev/null +++ b/app/controllers/elementos_controller.rb @@ -0,0 +1,70 @@ +class ElementosController < ApplicationController + before_action :set_elemento, only: %i[ show edit update destroy ] + + # GET /elementos or /elementos.json + def index + @elementos = Elemento.all + end + + # GET /elementos/1 or /elementos/1.json + def show + end + + # GET /elementos/new + def new + @elemento = Elemento.new + end + + # GET /elementos/1/edit + def edit + end + + # POST /elementos or /elementos.json + def create + @elemento = Elemento.new(elemento_params) + + respond_to do |format| + if @elemento.save + format.html { redirect_to @elemento, notice: "Elemento was successfully created." } + format.json { render :show, status: :created, location: @elemento } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @elemento.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /elementos/1 or /elementos/1.json + def update + respond_to do |format| + if @elemento.update(elemento_params) + format.html { redirect_to @elemento, notice: "Elemento was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @elemento } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @elemento.errors, status: :unprocessable_content } + end + end + end + + # DELETE /elementos/1 or /elementos/1.json + def destroy + @elemento.destroy! + + respond_to do |format| + format.html { redirect_to elementos_path, notice: "Elemento was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_elemento + @elemento = Elemento.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def elemento_params + params.expect(elemento: [ :ordem, :enunciado, :template_id ]) + end +end diff --git a/app/controllers/formularios_controller.rb b/app/controllers/formularios_controller.rb new file mode 100644 index 0000000000..d50b937cf0 --- /dev/null +++ b/app/controllers/formularios_controller.rb @@ -0,0 +1,70 @@ +class FormulariosController < ApplicationController + before_action :set_formulario, only: %i[ show edit update destroy ] + + # GET /formularios or /formularios.json + def index + @formularios = Formulario.all + end + + # GET /formularios/1 or /formularios/1.json + def show + end + + # GET /formularios/new + def new + @formulario = Formulario.new + end + + # GET /formularios/1/edit + def edit + end + + # POST /formularios or /formularios.json + def create + @formulario = Formulario.new(formulario_params) + + respond_to do |format| + if @formulario.save + format.html { redirect_to @formulario, notice: "Formulario was successfully created." } + format.json { render :show, status: :created, location: @formulario } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @formulario.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /formularios/1 or /formularios/1.json + def update + respond_to do |format| + if @formulario.update(formulario_params) + format.html { redirect_to @formulario, notice: "Formulario was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @formulario } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @formulario.errors, status: :unprocessable_content } + end + end + end + + # DELETE /formularios/1 or /formularios/1.json + def destroy + @formulario.destroy! + + respond_to do |format| + format.html { redirect_to formularios_path, notice: "Formulario was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_formulario + @formulario = Formulario.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def formulario_params + params.expect(formulario: [ :turma_id ]) + end +end diff --git a/app/controllers/resposta_elems_controller.rb b/app/controllers/resposta_elems_controller.rb new file mode 100644 index 0000000000..ebb155db99 --- /dev/null +++ b/app/controllers/resposta_elems_controller.rb @@ -0,0 +1,70 @@ +class RespostaElemsController < ApplicationController + before_action :set_resposta_elem, only: %i[ show edit update destroy ] + + # GET /resposta_elems or /resposta_elems.json + def index + @resposta_elems = RespostaElem.all + end + + # GET /resposta_elems/1 or /resposta_elems/1.json + def show + end + + # GET /resposta_elems/new + def new + @resposta_elem = RespostaElem.new + end + + # GET /resposta_elems/1/edit + def edit + end + + # POST /resposta_elems or /resposta_elems.json + def create + @resposta_elem = RespostaElem.new(resposta_elem_params) + + respond_to do |format| + if @resposta_elem.save + format.html { redirect_to @resposta_elem, notice: "Resposta elem was successfully created." } + format.json { render :show, status: :created, location: @resposta_elem } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @resposta_elem.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /resposta_elems/1 or /resposta_elems/1.json + def update + respond_to do |format| + if @resposta_elem.update(resposta_elem_params) + format.html { redirect_to @resposta_elem, notice: "Resposta elem was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @resposta_elem } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @resposta_elem.errors, status: :unprocessable_content } + end + end + end + + # DELETE /resposta_elems/1 or /resposta_elems/1.json + def destroy + @resposta_elem.destroy! + + respond_to do |format| + format.html { redirect_to resposta_elems_path, notice: "Resposta elem was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_resposta_elem + @resposta_elem = RespostaElem.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def resposta_elem_params + params.expect(resposta_elem: [ :texto_resposta, :resposta_form_id, :elemento_form_id, :campo_form_id ]) + end +end diff --git a/app/controllers/resposta_forms_controller.rb b/app/controllers/resposta_forms_controller.rb new file mode 100644 index 0000000000..16b541a220 --- /dev/null +++ b/app/controllers/resposta_forms_controller.rb @@ -0,0 +1,70 @@ +class RespostaFormsController < ApplicationController + before_action :set_resposta_form, only: %i[ show edit update destroy ] + + # GET /resposta_forms or /resposta_forms.json + def index + @resposta_forms = RespostaForm.all + end + + # GET /resposta_forms/1 or /resposta_forms/1.json + def show + end + + # GET /resposta_forms/new + def new + @resposta_form = RespostaForm.new + end + + # GET /resposta_forms/1/edit + def edit + end + + # POST /resposta_forms or /resposta_forms.json + def create + @resposta_form = RespostaForm.new(resposta_form_params) + + respond_to do |format| + if @resposta_form.save + format.html { redirect_to @resposta_form, notice: "Resposta form was successfully created." } + format.json { render :show, status: :created, location: @resposta_form } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @resposta_form.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /resposta_forms/1 or /resposta_forms/1.json + def update + respond_to do |format| + if @resposta_form.update(resposta_form_params) + format.html { redirect_to @resposta_form, notice: "Resposta form was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @resposta_form } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @resposta_form.errors, status: :unprocessable_content } + end + end + end + + # DELETE /resposta_forms/1 or /resposta_forms/1.json + def destroy + @resposta_form.destroy! + + respond_to do |format| + format.html { redirect_to resposta_forms_path, notice: "Resposta form was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_resposta_form + @resposta_form = RespostaForm.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def resposta_form_params + params.expect(resposta_form: [ :data_submissao, :formulario_id, :usuario_id ]) + end +end diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb new file mode 100644 index 0000000000..82c191cb0b --- /dev/null +++ b/app/controllers/templates_controller.rb @@ -0,0 +1,70 @@ +class TemplatesController < ApplicationController + before_action :set_template, only: %i[ show edit update destroy ] + + # GET /templates or /templates.json + def index + @templates = Template.all + end + + # GET /templates/1 or /templates/1.json + def show + end + + # GET /templates/new + def new + @template = Template.new + end + + # GET /templates/1/edit + def edit + end + + # POST /templates or /templates.json + def create + @template = Template.new(template_params) + + respond_to do |format| + if @template.save + format.html { redirect_to @template, notice: "Template was successfully created." } + format.json { render :show, status: :created, location: @template } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @template.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /templates/1 or /templates/1.json + def update + respond_to do |format| + if @template.update(template_params) + format.html { redirect_to @template, notice: "Template was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @template } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @template.errors, status: :unprocessable_content } + end + end + end + + # DELETE /templates/1 or /templates/1.json + def destroy + @template.destroy! + + respond_to do |format| + format.html { redirect_to templates_path, notice: "Template was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_template + @template = Template.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def template_params + params.expect(template: [ :nome ]) + end +end diff --git a/app/controllers/turmas_controller.rb b/app/controllers/turmas_controller.rb new file mode 100644 index 0000000000..5ba8d974ef --- /dev/null +++ b/app/controllers/turmas_controller.rb @@ -0,0 +1,70 @@ +class TurmasController < ApplicationController + before_action :set_turma, only: %i[ show edit update destroy ] + + # GET /turmas or /turmas.json + def index + @turmas = Turma.all + end + + # GET /turmas/1 or /turmas/1.json + def show + end + + # GET /turmas/new + def new + @turma = Turma.new + end + + # GET /turmas/1/edit + def edit + end + + # POST /turmas or /turmas.json + def create + @turma = Turma.new(turma_params) + + respond_to do |format| + if @turma.save + format.html { redirect_to @turma, notice: "Turma was successfully created." } + format.json { render :show, status: :created, location: @turma } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @turma.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /turmas/1 or /turmas/1.json + def update + respond_to do |format| + if @turma.update(turma_params) + format.html { redirect_to @turma, notice: "Turma was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @turma } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @turma.errors, status: :unprocessable_content } + end + end + end + + # DELETE /turmas/1 or /turmas/1.json + def destroy + @turma.destroy! + + respond_to do |format| + format.html { redirect_to turmas_path, notice: "Turma was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_turma + @turma = Turma.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def turma_params + params.expect(turma: [ :numero_da_turma, :semestre, :horario, :disciplina_id ]) + end +end diff --git a/app/controllers/usuarios_controller.rb b/app/controllers/usuarios_controller.rb new file mode 100644 index 0000000000..997075c07a --- /dev/null +++ b/app/controllers/usuarios_controller.rb @@ -0,0 +1,70 @@ +class UsuariosController < ApplicationController + before_action :set_usuario, only: %i[ show edit update destroy ] + + # GET /usuarios or /usuarios.json + def index + @usuarios = Usuario.all + end + + # GET /usuarios/1 or /usuarios/1.json + def show + end + + # GET /usuarios/new + def new + @usuario = Usuario.new + end + + # GET /usuarios/1/edit + def edit + end + + # POST /usuarios or /usuarios.json + def create + @usuario = Usuario.new(usuario_params) + + respond_to do |format| + if @usuario.save + format.html { redirect_to @usuario, notice: "Usuario was successfully created." } + format.json { render :show, status: :created, location: @usuario } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @usuario.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /usuarios/1 or /usuarios/1.json + def update + respond_to do |format| + if @usuario.update(usuario_params) + format.html { redirect_to @usuario, notice: "Usuario was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @usuario } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @usuario.errors, status: :unprocessable_content } + end + end + end + + # DELETE /usuarios/1 or /usuarios/1.json + def destroy + @usuario.destroy! + + respond_to do |format| + format.html { redirect_to usuarios_path, notice: "Usuario was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_usuario + @usuario = Usuario.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def usuario_params + params.expect(usuario: [ :matricula, :email, :nome, :formacao, :type ]) + end +end diff --git a/app/helpers/campo_forms_helper.rb b/app/helpers/campo_forms_helper.rb new file mode 100644 index 0000000000..4748406894 --- /dev/null +++ b/app/helpers/campo_forms_helper.rb @@ -0,0 +1,2 @@ +module CampoFormsHelper +end diff --git a/app/helpers/campos_helper.rb b/app/helpers/campos_helper.rb new file mode 100644 index 0000000000..dec4f22ced --- /dev/null +++ b/app/helpers/campos_helper.rb @@ -0,0 +1,2 @@ +module CamposHelper +end diff --git a/app/helpers/cursos_helper.rb b/app/helpers/cursos_helper.rb new file mode 100644 index 0000000000..4921eff347 --- /dev/null +++ b/app/helpers/cursos_helper.rb @@ -0,0 +1,2 @@ +module CursosHelper +end diff --git a/app/helpers/departamentos_helper.rb b/app/helpers/departamentos_helper.rb new file mode 100644 index 0000000000..df3b94bfda --- /dev/null +++ b/app/helpers/departamentos_helper.rb @@ -0,0 +1,2 @@ +module DepartamentosHelper +end diff --git a/app/helpers/discentes_helper.rb b/app/helpers/discentes_helper.rb new file mode 100644 index 0000000000..14d20c14c6 --- /dev/null +++ b/app/helpers/discentes_helper.rb @@ -0,0 +1,2 @@ +module DiscentesHelper +end diff --git a/app/helpers/disciplinas_helper.rb b/app/helpers/disciplinas_helper.rb new file mode 100644 index 0000000000..30b225dd00 --- /dev/null +++ b/app/helpers/disciplinas_helper.rb @@ -0,0 +1,2 @@ +module DisciplinasHelper +end diff --git a/app/helpers/docentes_helper.rb b/app/helpers/docentes_helper.rb new file mode 100644 index 0000000000..390c207243 --- /dev/null +++ b/app/helpers/docentes_helper.rb @@ -0,0 +1,2 @@ +module DocentesHelper +end diff --git a/app/helpers/elemento_forms_helper.rb b/app/helpers/elemento_forms_helper.rb new file mode 100644 index 0000000000..93783c1bcf --- /dev/null +++ b/app/helpers/elemento_forms_helper.rb @@ -0,0 +1,2 @@ +module ElementoFormsHelper +end diff --git a/app/helpers/elementos_helper.rb b/app/helpers/elementos_helper.rb new file mode 100644 index 0000000000..2f69e37c5b --- /dev/null +++ b/app/helpers/elementos_helper.rb @@ -0,0 +1,2 @@ +module ElementosHelper +end diff --git a/app/helpers/formularios_helper.rb b/app/helpers/formularios_helper.rb new file mode 100644 index 0000000000..3b96bb2209 --- /dev/null +++ b/app/helpers/formularios_helper.rb @@ -0,0 +1,2 @@ +module FormulariosHelper +end diff --git a/app/helpers/resposta_elems_helper.rb b/app/helpers/resposta_elems_helper.rb new file mode 100644 index 0000000000..cd6826fefc --- /dev/null +++ b/app/helpers/resposta_elems_helper.rb @@ -0,0 +1,2 @@ +module RespostaElemsHelper +end diff --git a/app/helpers/resposta_forms_helper.rb b/app/helpers/resposta_forms_helper.rb new file mode 100644 index 0000000000..800820446a --- /dev/null +++ b/app/helpers/resposta_forms_helper.rb @@ -0,0 +1,2 @@ +module RespostaFormsHelper +end diff --git a/app/helpers/templates_helper.rb b/app/helpers/templates_helper.rb new file mode 100644 index 0000000000..888093b832 --- /dev/null +++ b/app/helpers/templates_helper.rb @@ -0,0 +1,2 @@ +module TemplatesHelper +end diff --git a/app/helpers/turmas_helper.rb b/app/helpers/turmas_helper.rb new file mode 100644 index 0000000000..617e1373e9 --- /dev/null +++ b/app/helpers/turmas_helper.rb @@ -0,0 +1,2 @@ +module TurmasHelper +end diff --git a/app/helpers/usuarios_helper.rb b/app/helpers/usuarios_helper.rb new file mode 100644 index 0000000000..1f233ed026 --- /dev/null +++ b/app/helpers/usuarios_helper.rb @@ -0,0 +1,2 @@ +module UsuariosHelper +end diff --git a/app/models/administrador.rb b/app/models/administrador.rb new file mode 100644 index 0000000000..9746052fd7 --- /dev/null +++ b/app/models/administrador.rb @@ -0,0 +1,3 @@ +class Administrador < Usuario + validates :departamento_id, presence: true +end \ No newline at end of file diff --git a/app/models/campo.rb b/app/models/campo.rb new file mode 100644 index 0000000000..c57f3f257d --- /dev/null +++ b/app/models/campo.rb @@ -0,0 +1,6 @@ +class Campo < ApplicationRecord + belongs_to :elemento + validates :ordem, presence: true + validates :ordem, uniqueness: { scope: :elemento_id } + validates :tipo_elemento, presence: true +end \ No newline at end of file diff --git a/app/models/campo_form.rb b/app/models/campo_form.rb new file mode 100644 index 0000000000..fa1fbef3cf --- /dev/null +++ b/app/models/campo_form.rb @@ -0,0 +1,5 @@ +class CampoForm < ApplicationRecord + belongs_to :elemento_form + has_many :resposta_elems, dependent: :destroy + validates :ordem, presence: true +end \ No newline at end of file diff --git a/app/models/curso.rb b/app/models/curso.rb new file mode 100644 index 0000000000..181d343c9a --- /dev/null +++ b/app/models/curso.rb @@ -0,0 +1,6 @@ +class Curso < ApplicationRecord + belongs_to :departamento + has_many :discentes + validates :codigo, presence: true, uniqueness: true + validates :nome, presence: true +end \ No newline at end of file diff --git a/app/models/departamento.rb b/app/models/departamento.rb new file mode 100644 index 0000000000..651ac1294d --- /dev/null +++ b/app/models/departamento.rb @@ -0,0 +1,7 @@ +class Departamento < ApplicationRecord + has_many :cursos, dependent: :restrict_with_error + has_many :disciplinas, dependent: :restrict_with_error + has_many :administradores + validates :codigo, presence: true, uniqueness: true + validates :nome, presence: true +end \ No newline at end of file diff --git a/app/models/discente.rb b/app/models/discente.rb new file mode 100644 index 0000000000..d06b0b7772 --- /dev/null +++ b/app/models/discente.rb @@ -0,0 +1,4 @@ +class Discente < Usuario + validates :curso_id, presence: true + has_and_belongs_to_many :turmas +end \ No newline at end of file diff --git a/app/models/disciplina.rb b/app/models/disciplina.rb new file mode 100644 index 0000000000..f92d5a2f37 --- /dev/null +++ b/app/models/disciplina.rb @@ -0,0 +1,6 @@ +class Disciplina < ApplicationRecord + belongs_to :departamento + has_many :turmas, dependent: :destroy + validates :codigo, presence: true, uniqueness: true + validates :nome, presence: true +end \ No newline at end of file diff --git a/app/models/docente.rb b/app/models/docente.rb new file mode 100644 index 0000000000..bd48475299 --- /dev/null +++ b/app/models/docente.rb @@ -0,0 +1,4 @@ +class Docente < Usuario + validates :formacao, presence: true + has_and_belongs_to_many :turmas +end \ No newline at end of file diff --git a/app/models/elemento.rb b/app/models/elemento.rb new file mode 100644 index 0000000000..04b87fa8ac --- /dev/null +++ b/app/models/elemento.rb @@ -0,0 +1,6 @@ +class Elemento < ApplicationRecord + belongs_to :template + has_many :campos, dependent: :destroy + validates :ordem, presence: true + validates :ordem, uniqueness: { scope: :template_id } +end \ No newline at end of file diff --git a/app/models/elemento_form.rb b/app/models/elemento_form.rb new file mode 100644 index 0000000000..087bb0bdd0 --- /dev/null +++ b/app/models/elemento_form.rb @@ -0,0 +1,5 @@ +class ElementoForm < ApplicationRecord + belongs_to :formulario + has_many :campo_forms, dependent: :destroy + validates :ordem, presence: true +end \ No newline at end of file diff --git a/app/models/formulario.rb b/app/models/formulario.rb new file mode 100644 index 0000000000..f1dc656bfc --- /dev/null +++ b/app/models/formulario.rb @@ -0,0 +1,5 @@ +class Formulario < ApplicationRecord + belongs_to :turma + has_many :elemento_forms, dependent: :destroy + has_many :resposta_forms, dependent: :destroy +end \ No newline at end of file diff --git a/app/models/resposta_elem.rb b/app/models/resposta_elem.rb new file mode 100644 index 0000000000..5d17384907 --- /dev/null +++ b/app/models/resposta_elem.rb @@ -0,0 +1,6 @@ +class RespostaElem < ApplicationRecord + belongs_to :resposta_form + belongs_to :elemento_form + belongs_to :campo_form, optional: true + validates :texto_resposta, presence: true +end \ No newline at end of file diff --git a/app/models/resposta_form.rb b/app/models/resposta_form.rb new file mode 100644 index 0000000000..d36024340b --- /dev/null +++ b/app/models/resposta_form.rb @@ -0,0 +1,9 @@ +class RespostaForm < ApplicationRecord + belongs_to :formulario + belongs_to :usuario + has_many :resposta_elems, dependent: :destroy + validates :data_submissao, presence: true + validates :usuario_id, uniqueness: { + scope: :formulario_id, + } +end \ No newline at end of file diff --git a/app/models/template.rb b/app/models/template.rb new file mode 100644 index 0000000000..95b585e4d9 --- /dev/null +++ b/app/models/template.rb @@ -0,0 +1,4 @@ +class Template < ApplicationRecord + has_many :elementos, dependent: :destroy + validates :nome, presence: true +end \ No newline at end of file diff --git a/app/models/turma.rb b/app/models/turma.rb new file mode 100644 index 0000000000..e189be5359 --- /dev/null +++ b/app/models/turma.rb @@ -0,0 +1,11 @@ +class Turma < ApplicationRecord + belongs_to :disciplina + has_many :formularios, dependent: :destroy + has_and_belongs_to_many :discentes + has_and_belongs_to_many :docentes + + validates :numero_da_turma, presence: true, uniqueness: { + scope: [:semestre, :disciplina_id], + } + validates :semestre, presence: true +end \ No newline at end of file diff --git a/app/models/usuario.rb b/app/models/usuario.rb new file mode 100644 index 0000000000..0cae5cc929 --- /dev/null +++ b/app/models/usuario.rb @@ -0,0 +1,7 @@ +class Usuario < ApplicationRecord + belongs_to :curso, optional: true + belongs_to :departamento, optional: true + validates :matricula, presence: true, uniqueness: true + validates :email, presence: true, uniqueness: true + validates :nome, presence: true +end \ No newline at end of file diff --git a/app/views/campo_forms/_campo_form.html.erb b/app/views/campo_forms/_campo_form.html.erb new file mode 100644 index 0000000000..017c946779 --- /dev/null +++ b/app/views/campo_forms/_campo_form.html.erb @@ -0,0 +1,17 @@ +
+
+ Ordem: + <%= campo_form.ordem %> +
+ +
+ Enunciado: + <%= campo_form.enunciado %> +
+ +
+ Elemento form: + <%= campo_form.elemento_form_id %> +
+ +
diff --git a/app/views/campo_forms/_campo_form.json.jbuilder b/app/views/campo_forms/_campo_form.json.jbuilder new file mode 100644 index 0000000000..8c75eb97e0 --- /dev/null +++ b/app/views/campo_forms/_campo_form.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! campo_form, :id, :ordem, :enunciado, :elemento_form_id, :created_at, :updated_at +json.url campo_form_url(campo_form, format: :json) diff --git a/app/views/campo_forms/_form.html.erb b/app/views/campo_forms/_form.html.erb new file mode 100644 index 0000000000..a425f8b8fb --- /dev/null +++ b/app/views/campo_forms/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: campo_form) do |form| %> + <% if campo_form.errors.any? %> +
+

<%= pluralize(campo_form.errors.count, "error") %> prohibited this campo_form from being saved:

+ +
    + <% campo_form.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :ordem, style: "display: block" %> + <%= form.number_field :ordem %> +
+ +
+ <%= form.label :enunciado, style: "display: block" %> + <%= form.text_field :enunciado %> +
+ +
+ <%= form.label :elemento_form_id, style: "display: block" %> + <%= form.text_field :elemento_form_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/campo_forms/edit.html.erb b/app/views/campo_forms/edit.html.erb new file mode 100644 index 0000000000..6fcbe94956 --- /dev/null +++ b/app/views/campo_forms/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing campo form" %> + +

Editing campo form

+ +<%= render "form", campo_form: @campo_form %> + +
+ +
+ <%= link_to "Show this campo form", @campo_form %> | + <%= link_to "Back to campo forms", campo_forms_path %> +
diff --git a/app/views/campo_forms/index.html.erb b/app/views/campo_forms/index.html.erb new file mode 100644 index 0000000000..8daeea2454 --- /dev/null +++ b/app/views/campo_forms/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Campo forms" %> + +

Campo forms

+ +
+ <% @campo_forms.each do |campo_form| %> + <%= render campo_form %> +

+ <%= link_to "Show this campo form", campo_form %> +

+ <% end %> +
+ +<%= link_to "New campo form", new_campo_form_path %> diff --git a/app/views/campo_forms/index.json.jbuilder b/app/views/campo_forms/index.json.jbuilder new file mode 100644 index 0000000000..eb30da75b2 --- /dev/null +++ b/app/views/campo_forms/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @campo_forms, partial: "campo_forms/campo_form", as: :campo_form diff --git a/app/views/campo_forms/new.html.erb b/app/views/campo_forms/new.html.erb new file mode 100644 index 0000000000..7b29b045a6 --- /dev/null +++ b/app/views/campo_forms/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New campo form" %> + +

New campo form

+ +<%= render "form", campo_form: @campo_form %> + +
+ +
+ <%= link_to "Back to campo forms", campo_forms_path %> +
diff --git a/app/views/campo_forms/show.html.erb b/app/views/campo_forms/show.html.erb new file mode 100644 index 0000000000..8e6d73f6e0 --- /dev/null +++ b/app/views/campo_forms/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @campo_form %> + +
+ <%= link_to "Edit this campo form", edit_campo_form_path(@campo_form) %> | + <%= link_to "Back to campo forms", campo_forms_path %> + + <%= button_to "Destroy this campo form", @campo_form, method: :delete %> +
diff --git a/app/views/campo_forms/show.json.jbuilder b/app/views/campo_forms/show.json.jbuilder new file mode 100644 index 0000000000..08aeeb5981 --- /dev/null +++ b/app/views/campo_forms/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "campo_forms/campo_form", campo_form: @campo_form diff --git a/app/views/campos/_campo.html.erb b/app/views/campos/_campo.html.erb new file mode 100644 index 0000000000..16889ffbca --- /dev/null +++ b/app/views/campos/_campo.html.erb @@ -0,0 +1,22 @@ +
+
+ Ordem: + <%= campo.ordem %> +
+ +
+ Enunciado: + <%= campo.enunciado %> +
+ +
+ Tipo elemento: + <%= campo.tipo_elemento %> +
+ +
+ Elemento: + <%= campo.elemento_id %> +
+ +
diff --git a/app/views/campos/_campo.json.jbuilder b/app/views/campos/_campo.json.jbuilder new file mode 100644 index 0000000000..91c37792b6 --- /dev/null +++ b/app/views/campos/_campo.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! campo, :id, :ordem, :enunciado, :tipo_elemento, :elemento_id, :created_at, :updated_at +json.url campo_url(campo, format: :json) diff --git a/app/views/campos/_form.html.erb b/app/views/campos/_form.html.erb new file mode 100644 index 0000000000..d240daebc8 --- /dev/null +++ b/app/views/campos/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: campo) do |form| %> + <% if campo.errors.any? %> +
+

<%= pluralize(campo.errors.count, "error") %> prohibited this campo from being saved:

+ +
    + <% campo.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :ordem, style: "display: block" %> + <%= form.number_field :ordem %> +
+ +
+ <%= form.label :enunciado, style: "display: block" %> + <%= form.text_field :enunciado %> +
+ +
+ <%= form.label :tipo_elemento, style: "display: block" %> + <%= form.text_field :tipo_elemento %> +
+ +
+ <%= form.label :elemento_id, style: "display: block" %> + <%= form.text_field :elemento_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/campos/edit.html.erb b/app/views/campos/edit.html.erb new file mode 100644 index 0000000000..f7bf25cf92 --- /dev/null +++ b/app/views/campos/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing campo" %> + +

Editing campo

+ +<%= render "form", campo: @campo %> + +
+ +
+ <%= link_to "Show this campo", @campo %> | + <%= link_to "Back to campos", campos_path %> +
diff --git a/app/views/campos/index.html.erb b/app/views/campos/index.html.erb new file mode 100644 index 0000000000..d3f9dd8b6b --- /dev/null +++ b/app/views/campos/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Campos" %> + +

Campos

+ +
+ <% @campos.each do |campo| %> + <%= render campo %> +

+ <%= link_to "Show this campo", campo %> +

+ <% end %> +
+ +<%= link_to "New campo", new_campo_path %> diff --git a/app/views/campos/index.json.jbuilder b/app/views/campos/index.json.jbuilder new file mode 100644 index 0000000000..3c0e743402 --- /dev/null +++ b/app/views/campos/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @campos, partial: "campos/campo", as: :campo diff --git a/app/views/campos/new.html.erb b/app/views/campos/new.html.erb new file mode 100644 index 0000000000..96fe844c6e --- /dev/null +++ b/app/views/campos/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New campo" %> + +

New campo

+ +<%= render "form", campo: @campo %> + +
+ +
+ <%= link_to "Back to campos", campos_path %> +
diff --git a/app/views/campos/show.html.erb b/app/views/campos/show.html.erb new file mode 100644 index 0000000000..3535330c82 --- /dev/null +++ b/app/views/campos/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @campo %> + +
+ <%= link_to "Edit this campo", edit_campo_path(@campo) %> | + <%= link_to "Back to campos", campos_path %> + + <%= button_to "Destroy this campo", @campo, method: :delete %> +
diff --git a/app/views/campos/show.json.jbuilder b/app/views/campos/show.json.jbuilder new file mode 100644 index 0000000000..bdb6307753 --- /dev/null +++ b/app/views/campos/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "campos/campo", campo: @campo diff --git a/app/views/cursos/_curso.html.erb b/app/views/cursos/_curso.html.erb new file mode 100644 index 0000000000..4542c6c387 --- /dev/null +++ b/app/views/cursos/_curso.html.erb @@ -0,0 +1,17 @@ +
+
+ Codigo: + <%= curso.codigo %> +
+ +
+ Nome: + <%= curso.nome %> +
+ +
+ Departamento: + <%= curso.departamento_id %> +
+ +
diff --git a/app/views/cursos/_curso.json.jbuilder b/app/views/cursos/_curso.json.jbuilder new file mode 100644 index 0000000000..fc8ea66f22 --- /dev/null +++ b/app/views/cursos/_curso.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! curso, :id, :codigo, :nome, :departamento_id, :created_at, :updated_at +json.url curso_url(curso, format: :json) diff --git a/app/views/cursos/_form.html.erb b/app/views/cursos/_form.html.erb new file mode 100644 index 0000000000..8e110c66e9 --- /dev/null +++ b/app/views/cursos/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: curso) do |form| %> + <% if curso.errors.any? %> +
+

<%= pluralize(curso.errors.count, "error") %> prohibited this curso from being saved:

+ +
    + <% curso.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :codigo, style: "display: block" %> + <%= form.text_field :codigo %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :departamento_id, style: "display: block" %> + <%= form.text_field :departamento_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/cursos/edit.html.erb b/app/views/cursos/edit.html.erb new file mode 100644 index 0000000000..146b27780b --- /dev/null +++ b/app/views/cursos/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing curso" %> + +

Editing curso

+ +<%= render "form", curso: @curso %> + +
+ +
+ <%= link_to "Show this curso", @curso %> | + <%= link_to "Back to cursos", cursos_path %> +
diff --git a/app/views/cursos/index.html.erb b/app/views/cursos/index.html.erb new file mode 100644 index 0000000000..24626172a0 --- /dev/null +++ b/app/views/cursos/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Cursos" %> + +

Cursos

+ +
+ <% @cursos.each do |curso| %> + <%= render curso %> +

+ <%= link_to "Show this curso", curso %> +

+ <% end %> +
+ +<%= link_to "New curso", new_curso_path %> diff --git a/app/views/cursos/index.json.jbuilder b/app/views/cursos/index.json.jbuilder new file mode 100644 index 0000000000..2e39c23019 --- /dev/null +++ b/app/views/cursos/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @cursos, partial: "cursos/curso", as: :curso diff --git a/app/views/cursos/new.html.erb b/app/views/cursos/new.html.erb new file mode 100644 index 0000000000..f4f7bec9ba --- /dev/null +++ b/app/views/cursos/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New curso" %> + +

New curso

+ +<%= render "form", curso: @curso %> + +
+ +
+ <%= link_to "Back to cursos", cursos_path %> +
diff --git a/app/views/cursos/show.html.erb b/app/views/cursos/show.html.erb new file mode 100644 index 0000000000..3f0601c157 --- /dev/null +++ b/app/views/cursos/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @curso %> + +
+ <%= link_to "Edit this curso", edit_curso_path(@curso) %> | + <%= link_to "Back to cursos", cursos_path %> + + <%= button_to "Destroy this curso", @curso, method: :delete %> +
diff --git a/app/views/cursos/show.json.jbuilder b/app/views/cursos/show.json.jbuilder new file mode 100644 index 0000000000..74b378ecab --- /dev/null +++ b/app/views/cursos/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "cursos/curso", curso: @curso diff --git a/app/views/departamentos/_departamento.html.erb b/app/views/departamentos/_departamento.html.erb new file mode 100644 index 0000000000..b4e3907c9a --- /dev/null +++ b/app/views/departamentos/_departamento.html.erb @@ -0,0 +1,12 @@ +
+
+ Codigo: + <%= departamento.codigo %> +
+ +
+ Nome: + <%= departamento.nome %> +
+ +
diff --git a/app/views/departamentos/_departamento.json.jbuilder b/app/views/departamentos/_departamento.json.jbuilder new file mode 100644 index 0000000000..2145ba20c5 --- /dev/null +++ b/app/views/departamentos/_departamento.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! departamento, :id, :codigo, :nome, :created_at, :updated_at +json.url departamento_url(departamento, format: :json) diff --git a/app/views/departamentos/_form.html.erb b/app/views/departamentos/_form.html.erb new file mode 100644 index 0000000000..a8ed55c8f4 --- /dev/null +++ b/app/views/departamentos/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_with(model: departamento) do |form| %> + <% if departamento.errors.any? %> +
+

<%= pluralize(departamento.errors.count, "error") %> prohibited this departamento from being saved:

+ +
    + <% departamento.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :codigo, style: "display: block" %> + <%= form.text_field :codigo %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/departamentos/edit.html.erb b/app/views/departamentos/edit.html.erb new file mode 100644 index 0000000000..f63ef9cac0 --- /dev/null +++ b/app/views/departamentos/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing departamento" %> + +

Editing departamento

+ +<%= render "form", departamento: @departamento %> + +
+ +
+ <%= link_to "Show this departamento", @departamento %> | + <%= link_to "Back to departamentos", departamentos_path %> +
diff --git a/app/views/departamentos/index.html.erb b/app/views/departamentos/index.html.erb new file mode 100644 index 0000000000..a05d2b04fa --- /dev/null +++ b/app/views/departamentos/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Departamentos" %> + +

Departamentos

+ +
+ <% @departamentos.each do |departamento| %> + <%= render departamento %> +

+ <%= link_to "Show this departamento", departamento %> +

+ <% end %> +
+ +<%= link_to "New departamento", new_departamento_path %> diff --git a/app/views/departamentos/index.json.jbuilder b/app/views/departamentos/index.json.jbuilder new file mode 100644 index 0000000000..030ab748d1 --- /dev/null +++ b/app/views/departamentos/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @departamentos, partial: "departamentos/departamento", as: :departamento diff --git a/app/views/departamentos/new.html.erb b/app/views/departamentos/new.html.erb new file mode 100644 index 0000000000..76eefa1cfb --- /dev/null +++ b/app/views/departamentos/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New departamento" %> + +

New departamento

+ +<%= render "form", departamento: @departamento %> + +
+ +
+ <%= link_to "Back to departamentos", departamentos_path %> +
diff --git a/app/views/departamentos/show.html.erb b/app/views/departamentos/show.html.erb new file mode 100644 index 0000000000..2957799d46 --- /dev/null +++ b/app/views/departamentos/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @departamento %> + +
+ <%= link_to "Edit this departamento", edit_departamento_path(@departamento) %> | + <%= link_to "Back to departamentos", departamentos_path %> + + <%= button_to "Destroy this departamento", @departamento, method: :delete %> +
diff --git a/app/views/departamentos/show.json.jbuilder b/app/views/departamentos/show.json.jbuilder new file mode 100644 index 0000000000..13c4a70c0c --- /dev/null +++ b/app/views/departamentos/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "departamentos/departamento", departamento: @departamento diff --git a/app/views/discentes/_discente.html.erb b/app/views/discentes/_discente.html.erb new file mode 100644 index 0000000000..6d800585cc --- /dev/null +++ b/app/views/discentes/_discente.html.erb @@ -0,0 +1,27 @@ +
+
+ Matricula: + <%= discente.matricula %> +
+ +
+ Email: + <%= discente.email %> +
+ +
+ Nome: + <%= discente.nome %> +
+ +
+ Formacao: + <%= discente.formacao %> +
+ +
+ Curso: + <%= discente.curso_id %> +
+ +
diff --git a/app/views/discentes/_discente.json.jbuilder b/app/views/discentes/_discente.json.jbuilder new file mode 100644 index 0000000000..1451775555 --- /dev/null +++ b/app/views/discentes/_discente.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! discente, :id, :matricula, :email, :nome, :formacao, :curso_id, :created_at, :updated_at +json.url discente_url(discente, format: :json) diff --git a/app/views/discentes/_form.html.erb b/app/views/discentes/_form.html.erb new file mode 100644 index 0000000000..1508351bb7 --- /dev/null +++ b/app/views/discentes/_form.html.erb @@ -0,0 +1,42 @@ +<%= form_with(model: discente) do |form| %> + <% if discente.errors.any? %> +
+

<%= pluralize(discente.errors.count, "error") %> prohibited this discente from being saved:

+ +
    + <% discente.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :matricula, style: "display: block" %> + <%= form.text_field :matricula %> +
+ +
+ <%= form.label :email, style: "display: block" %> + <%= form.text_field :email %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :formacao, style: "display: block" %> + <%= form.text_field :formacao %> +
+ +
+ <%= form.label :curso_id, style: "display: block" %> + <%= form.text_field :curso_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/discentes/edit.html.erb b/app/views/discentes/edit.html.erb new file mode 100644 index 0000000000..b406df6523 --- /dev/null +++ b/app/views/discentes/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing discente" %> + +

Editing discente

+ +<%= render "form", discente: @discente %> + +
+ +
+ <%= link_to "Show this discente", @discente %> | + <%= link_to "Back to discentes", discentes_path %> +
diff --git a/app/views/discentes/index.html.erb b/app/views/discentes/index.html.erb new file mode 100644 index 0000000000..55626169e5 --- /dev/null +++ b/app/views/discentes/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Discentes" %> + +

Discentes

+ +
+ <% @discentes.each do |discente| %> + <%= render discente %> +

+ <%= link_to "Show this discente", discente %> +

+ <% end %> +
+ +<%= link_to "New discente", new_discente_path %> diff --git a/app/views/discentes/index.json.jbuilder b/app/views/discentes/index.json.jbuilder new file mode 100644 index 0000000000..80c25ce894 --- /dev/null +++ b/app/views/discentes/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @discentes, partial: "discentes/discente", as: :discente diff --git a/app/views/discentes/new.html.erb b/app/views/discentes/new.html.erb new file mode 100644 index 0000000000..964c1192ba --- /dev/null +++ b/app/views/discentes/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New discente" %> + +

New discente

+ +<%= render "form", discente: @discente %> + +
+ +
+ <%= link_to "Back to discentes", discentes_path %> +
diff --git a/app/views/discentes/show.html.erb b/app/views/discentes/show.html.erb new file mode 100644 index 0000000000..253165e73e --- /dev/null +++ b/app/views/discentes/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @discente %> + +
+ <%= link_to "Edit this discente", edit_discente_path(@discente) %> | + <%= link_to "Back to discentes", discentes_path %> + + <%= button_to "Destroy this discente", @discente, method: :delete %> +
diff --git a/app/views/discentes/show.json.jbuilder b/app/views/discentes/show.json.jbuilder new file mode 100644 index 0000000000..0d3ad84a23 --- /dev/null +++ b/app/views/discentes/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "discentes/discente", discente: @discente diff --git a/app/views/disciplinas/_disciplina.html.erb b/app/views/disciplinas/_disciplina.html.erb new file mode 100644 index 0000000000..eece272568 --- /dev/null +++ b/app/views/disciplinas/_disciplina.html.erb @@ -0,0 +1,17 @@ +
+
+ Codigo: + <%= disciplina.codigo %> +
+ +
+ Nome: + <%= disciplina.nome %> +
+ +
+ Departamento: + <%= disciplina.departamento_id %> +
+ +
diff --git a/app/views/disciplinas/_disciplina.json.jbuilder b/app/views/disciplinas/_disciplina.json.jbuilder new file mode 100644 index 0000000000..c7fc54340e --- /dev/null +++ b/app/views/disciplinas/_disciplina.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! disciplina, :id, :codigo, :nome, :departamento_id, :created_at, :updated_at +json.url disciplina_url(disciplina, format: :json) diff --git a/app/views/disciplinas/_form.html.erb b/app/views/disciplinas/_form.html.erb new file mode 100644 index 0000000000..373da8e92a --- /dev/null +++ b/app/views/disciplinas/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: disciplina) do |form| %> + <% if disciplina.errors.any? %> +
+

<%= pluralize(disciplina.errors.count, "error") %> prohibited this disciplina from being saved:

+ +
    + <% disciplina.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :codigo, style: "display: block" %> + <%= form.text_field :codigo %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :departamento_id, style: "display: block" %> + <%= form.text_field :departamento_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/disciplinas/edit.html.erb b/app/views/disciplinas/edit.html.erb new file mode 100644 index 0000000000..d43c76ac3f --- /dev/null +++ b/app/views/disciplinas/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing disciplina" %> + +

Editing disciplina

+ +<%= render "form", disciplina: @disciplina %> + +
+ +
+ <%= link_to "Show this disciplina", @disciplina %> | + <%= link_to "Back to disciplinas", disciplinas_path %> +
diff --git a/app/views/disciplinas/index.html.erb b/app/views/disciplinas/index.html.erb new file mode 100644 index 0000000000..f2806e550c --- /dev/null +++ b/app/views/disciplinas/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Disciplinas" %> + +

Disciplinas

+ +
+ <% @disciplinas.each do |disciplina| %> + <%= render disciplina %> +

+ <%= link_to "Show this disciplina", disciplina %> +

+ <% end %> +
+ +<%= link_to "New disciplina", new_disciplina_path %> diff --git a/app/views/disciplinas/index.json.jbuilder b/app/views/disciplinas/index.json.jbuilder new file mode 100644 index 0000000000..f7dfbb1351 --- /dev/null +++ b/app/views/disciplinas/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @disciplinas, partial: "disciplinas/disciplina", as: :disciplina diff --git a/app/views/disciplinas/new.html.erb b/app/views/disciplinas/new.html.erb new file mode 100644 index 0000000000..749a8f81d4 --- /dev/null +++ b/app/views/disciplinas/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New disciplina" %> + +

New disciplina

+ +<%= render "form", disciplina: @disciplina %> + +
+ +
+ <%= link_to "Back to disciplinas", disciplinas_path %> +
diff --git a/app/views/disciplinas/show.html.erb b/app/views/disciplinas/show.html.erb new file mode 100644 index 0000000000..53498063d9 --- /dev/null +++ b/app/views/disciplinas/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @disciplina %> + +
+ <%= link_to "Edit this disciplina", edit_disciplina_path(@disciplina) %> | + <%= link_to "Back to disciplinas", disciplinas_path %> + + <%= button_to "Destroy this disciplina", @disciplina, method: :delete %> +
diff --git a/app/views/disciplinas/show.json.jbuilder b/app/views/disciplinas/show.json.jbuilder new file mode 100644 index 0000000000..81900042ae --- /dev/null +++ b/app/views/disciplinas/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "disciplinas/disciplina", disciplina: @disciplina diff --git a/app/views/docentes/_docente.html.erb b/app/views/docentes/_docente.html.erb new file mode 100644 index 0000000000..1aebfe62bf --- /dev/null +++ b/app/views/docentes/_docente.html.erb @@ -0,0 +1,22 @@ +
+
+ Matricula: + <%= docente.matricula %> +
+ +
+ Email: + <%= docente.email %> +
+ +
+ Nome: + <%= docente.nome %> +
+ +
+ Formacao: + <%= docente.formacao %> +
+ +
diff --git a/app/views/docentes/_docente.json.jbuilder b/app/views/docentes/_docente.json.jbuilder new file mode 100644 index 0000000000..6d10e76c27 --- /dev/null +++ b/app/views/docentes/_docente.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! docente, :id, :matricula, :email, :nome, :formacao, :created_at, :updated_at +json.url docente_url(docente, format: :json) diff --git a/app/views/docentes/_form.html.erb b/app/views/docentes/_form.html.erb new file mode 100644 index 0000000000..59d2257579 --- /dev/null +++ b/app/views/docentes/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: docente) do |form| %> + <% if docente.errors.any? %> +
+

<%= pluralize(docente.errors.count, "error") %> prohibited this docente from being saved:

+ +
    + <% docente.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :matricula, style: "display: block" %> + <%= form.text_field :matricula %> +
+ +
+ <%= form.label :email, style: "display: block" %> + <%= form.text_field :email %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :formacao, style: "display: block" %> + <%= form.text_field :formacao %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/docentes/edit.html.erb b/app/views/docentes/edit.html.erb new file mode 100644 index 0000000000..f943000a91 --- /dev/null +++ b/app/views/docentes/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing docente" %> + +

Editing docente

+ +<%= render "form", docente: @docente %> + +
+ +
+ <%= link_to "Show this docente", @docente %> | + <%= link_to "Back to docentes", docentes_path %> +
diff --git a/app/views/docentes/index.html.erb b/app/views/docentes/index.html.erb new file mode 100644 index 0000000000..87242c4310 --- /dev/null +++ b/app/views/docentes/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Docentes" %> + +

Docentes

+ +
+ <% @docentes.each do |docente| %> + <%= render docente %> +

+ <%= link_to "Show this docente", docente %> +

+ <% end %> +
+ +<%= link_to "New docente", new_docente_path %> diff --git a/app/views/docentes/index.json.jbuilder b/app/views/docentes/index.json.jbuilder new file mode 100644 index 0000000000..9fa1138d65 --- /dev/null +++ b/app/views/docentes/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @docentes, partial: "docentes/docente", as: :docente diff --git a/app/views/docentes/new.html.erb b/app/views/docentes/new.html.erb new file mode 100644 index 0000000000..963e827ea2 --- /dev/null +++ b/app/views/docentes/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New docente" %> + +

New docente

+ +<%= render "form", docente: @docente %> + +
+ +
+ <%= link_to "Back to docentes", docentes_path %> +
diff --git a/app/views/docentes/show.html.erb b/app/views/docentes/show.html.erb new file mode 100644 index 0000000000..2cae716ac2 --- /dev/null +++ b/app/views/docentes/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @docente %> + +
+ <%= link_to "Edit this docente", edit_docente_path(@docente) %> | + <%= link_to "Back to docentes", docentes_path %> + + <%= button_to "Destroy this docente", @docente, method: :delete %> +
diff --git a/app/views/docentes/show.json.jbuilder b/app/views/docentes/show.json.jbuilder new file mode 100644 index 0000000000..52216e7d59 --- /dev/null +++ b/app/views/docentes/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "docentes/docente", docente: @docente diff --git a/app/views/elemento_forms/_elemento_form.html.erb b/app/views/elemento_forms/_elemento_form.html.erb new file mode 100644 index 0000000000..c9c8ff75dd --- /dev/null +++ b/app/views/elemento_forms/_elemento_form.html.erb @@ -0,0 +1,17 @@ +
+
+ Ordem: + <%= elemento_form.ordem %> +
+ +
+ Enunciado: + <%= elemento_form.enunciado %> +
+ +
+ Formulario: + <%= elemento_form.formulario_id %> +
+ +
diff --git a/app/views/elemento_forms/_elemento_form.json.jbuilder b/app/views/elemento_forms/_elemento_form.json.jbuilder new file mode 100644 index 0000000000..c8c9c3c1dd --- /dev/null +++ b/app/views/elemento_forms/_elemento_form.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! elemento_form, :id, :ordem, :enunciado, :formulario_id, :created_at, :updated_at +json.url elemento_form_url(elemento_form, format: :json) diff --git a/app/views/elemento_forms/_form.html.erb b/app/views/elemento_forms/_form.html.erb new file mode 100644 index 0000000000..e82793e837 --- /dev/null +++ b/app/views/elemento_forms/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: elemento_form) do |form| %> + <% if elemento_form.errors.any? %> +
+

<%= pluralize(elemento_form.errors.count, "error") %> prohibited this elemento_form from being saved:

+ +
    + <% elemento_form.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :ordem, style: "display: block" %> + <%= form.number_field :ordem %> +
+ +
+ <%= form.label :enunciado, style: "display: block" %> + <%= form.text_field :enunciado %> +
+ +
+ <%= form.label :formulario_id, style: "display: block" %> + <%= form.text_field :formulario_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/elemento_forms/edit.html.erb b/app/views/elemento_forms/edit.html.erb new file mode 100644 index 0000000000..a40b53f636 --- /dev/null +++ b/app/views/elemento_forms/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing elemento form" %> + +

Editing elemento form

+ +<%= render "form", elemento_form: @elemento_form %> + +
+ +
+ <%= link_to "Show this elemento form", @elemento_form %> | + <%= link_to "Back to elemento forms", elemento_forms_path %> +
diff --git a/app/views/elemento_forms/index.html.erb b/app/views/elemento_forms/index.html.erb new file mode 100644 index 0000000000..ee86c1863e --- /dev/null +++ b/app/views/elemento_forms/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Elemento forms" %> + +

Elemento forms

+ +
+ <% @elemento_forms.each do |elemento_form| %> + <%= render elemento_form %> +

+ <%= link_to "Show this elemento form", elemento_form %> +

+ <% end %> +
+ +<%= link_to "New elemento form", new_elemento_form_path %> diff --git a/app/views/elemento_forms/index.json.jbuilder b/app/views/elemento_forms/index.json.jbuilder new file mode 100644 index 0000000000..d92ed08923 --- /dev/null +++ b/app/views/elemento_forms/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @elemento_forms, partial: "elemento_forms/elemento_form", as: :elemento_form diff --git a/app/views/elemento_forms/new.html.erb b/app/views/elemento_forms/new.html.erb new file mode 100644 index 0000000000..1802adb7fc --- /dev/null +++ b/app/views/elemento_forms/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New elemento form" %> + +

New elemento form

+ +<%= render "form", elemento_form: @elemento_form %> + +
+ +
+ <%= link_to "Back to elemento forms", elemento_forms_path %> +
diff --git a/app/views/elemento_forms/show.html.erb b/app/views/elemento_forms/show.html.erb new file mode 100644 index 0000000000..216c0abdbf --- /dev/null +++ b/app/views/elemento_forms/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @elemento_form %> + +
+ <%= link_to "Edit this elemento form", edit_elemento_form_path(@elemento_form) %> | + <%= link_to "Back to elemento forms", elemento_forms_path %> + + <%= button_to "Destroy this elemento form", @elemento_form, method: :delete %> +
diff --git a/app/views/elemento_forms/show.json.jbuilder b/app/views/elemento_forms/show.json.jbuilder new file mode 100644 index 0000000000..f73a125a23 --- /dev/null +++ b/app/views/elemento_forms/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "elemento_forms/elemento_form", elemento_form: @elemento_form diff --git a/app/views/elementos/_elemento.html.erb b/app/views/elementos/_elemento.html.erb new file mode 100644 index 0000000000..2fba356080 --- /dev/null +++ b/app/views/elementos/_elemento.html.erb @@ -0,0 +1,17 @@ +
+
+ Ordem: + <%= elemento.ordem %> +
+ +
+ Enunciado: + <%= elemento.enunciado %> +
+ +
+ Template: + <%= elemento.template_id %> +
+ +
diff --git a/app/views/elementos/_elemento.json.jbuilder b/app/views/elementos/_elemento.json.jbuilder new file mode 100644 index 0000000000..ab132a3548 --- /dev/null +++ b/app/views/elementos/_elemento.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! elemento, :id, :ordem, :enunciado, :template_id, :created_at, :updated_at +json.url elemento_url(elemento, format: :json) diff --git a/app/views/elementos/_form.html.erb b/app/views/elementos/_form.html.erb new file mode 100644 index 0000000000..e7f9b64d4c --- /dev/null +++ b/app/views/elementos/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: elemento) do |form| %> + <% if elemento.errors.any? %> +
+

<%= pluralize(elemento.errors.count, "error") %> prohibited this elemento from being saved:

+ +
    + <% elemento.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :ordem, style: "display: block" %> + <%= form.number_field :ordem %> +
+ +
+ <%= form.label :enunciado, style: "display: block" %> + <%= form.text_field :enunciado %> +
+ +
+ <%= form.label :template_id, style: "display: block" %> + <%= form.text_field :template_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/elementos/edit.html.erb b/app/views/elementos/edit.html.erb new file mode 100644 index 0000000000..e8021663c8 --- /dev/null +++ b/app/views/elementos/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing elemento" %> + +

Editing elemento

+ +<%= render "form", elemento: @elemento %> + +
+ +
+ <%= link_to "Show this elemento", @elemento %> | + <%= link_to "Back to elementos", elementos_path %> +
diff --git a/app/views/elementos/index.html.erb b/app/views/elementos/index.html.erb new file mode 100644 index 0000000000..e3edba25e0 --- /dev/null +++ b/app/views/elementos/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Elementos" %> + +

Elementos

+ +
+ <% @elementos.each do |elemento| %> + <%= render elemento %> +

+ <%= link_to "Show this elemento", elemento %> +

+ <% end %> +
+ +<%= link_to "New elemento", new_elemento_path %> diff --git a/app/views/elementos/index.json.jbuilder b/app/views/elementos/index.json.jbuilder new file mode 100644 index 0000000000..bbf28cc646 --- /dev/null +++ b/app/views/elementos/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @elementos, partial: "elementos/elemento", as: :elemento diff --git a/app/views/elementos/new.html.erb b/app/views/elementos/new.html.erb new file mode 100644 index 0000000000..dc3997b102 --- /dev/null +++ b/app/views/elementos/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New elemento" %> + +

New elemento

+ +<%= render "form", elemento: @elemento %> + +
+ +
+ <%= link_to "Back to elementos", elementos_path %> +
diff --git a/app/views/elementos/show.html.erb b/app/views/elementos/show.html.erb new file mode 100644 index 0000000000..e8d76a29af --- /dev/null +++ b/app/views/elementos/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @elemento %> + +
+ <%= link_to "Edit this elemento", edit_elemento_path(@elemento) %> | + <%= link_to "Back to elementos", elementos_path %> + + <%= button_to "Destroy this elemento", @elemento, method: :delete %> +
diff --git a/app/views/elementos/show.json.jbuilder b/app/views/elementos/show.json.jbuilder new file mode 100644 index 0000000000..a39f969950 --- /dev/null +++ b/app/views/elementos/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "elementos/elemento", elemento: @elemento diff --git a/app/views/formularios/_form.html.erb b/app/views/formularios/_form.html.erb new file mode 100644 index 0000000000..ddbf9658b6 --- /dev/null +++ b/app/views/formularios/_form.html.erb @@ -0,0 +1,22 @@ +<%= form_with(model: formulario) do |form| %> + <% if formulario.errors.any? %> +
+

<%= pluralize(formulario.errors.count, "error") %> prohibited this formulario from being saved:

+ +
    + <% formulario.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :turma_id, style: "display: block" %> + <%= form.text_field :turma_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/formularios/_formulario.html.erb b/app/views/formularios/_formulario.html.erb new file mode 100644 index 0000000000..18470d4252 --- /dev/null +++ b/app/views/formularios/_formulario.html.erb @@ -0,0 +1,7 @@ +
+
+ Turma: + <%= formulario.turma_id %> +
+ +
diff --git a/app/views/formularios/_formulario.json.jbuilder b/app/views/formularios/_formulario.json.jbuilder new file mode 100644 index 0000000000..70529ec0c5 --- /dev/null +++ b/app/views/formularios/_formulario.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! formulario, :id, :turma_id, :created_at, :updated_at +json.url formulario_url(formulario, format: :json) diff --git a/app/views/formularios/edit.html.erb b/app/views/formularios/edit.html.erb new file mode 100644 index 0000000000..2fb833aa29 --- /dev/null +++ b/app/views/formularios/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing formulario" %> + +

Editing formulario

+ +<%= render "form", formulario: @formulario %> + +
+ +
+ <%= link_to "Show this formulario", @formulario %> | + <%= link_to "Back to formularios", formularios_path %> +
diff --git a/app/views/formularios/index.html.erb b/app/views/formularios/index.html.erb new file mode 100644 index 0000000000..99df9d53e3 --- /dev/null +++ b/app/views/formularios/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Formularios" %> + +

Formularios

+ +
+ <% @formularios.each do |formulario| %> + <%= render formulario %> +

+ <%= link_to "Show this formulario", formulario %> +

+ <% end %> +
+ +<%= link_to "New formulario", new_formulario_path %> diff --git a/app/views/formularios/index.json.jbuilder b/app/views/formularios/index.json.jbuilder new file mode 100644 index 0000000000..70770973a8 --- /dev/null +++ b/app/views/formularios/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @formularios, partial: "formularios/formulario", as: :formulario diff --git a/app/views/formularios/new.html.erb b/app/views/formularios/new.html.erb new file mode 100644 index 0000000000..0dbdfdbd5c --- /dev/null +++ b/app/views/formularios/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New formulario" %> + +

New formulario

+ +<%= render "form", formulario: @formulario %> + +
+ +
+ <%= link_to "Back to formularios", formularios_path %> +
diff --git a/app/views/formularios/show.html.erb b/app/views/formularios/show.html.erb new file mode 100644 index 0000000000..24709ac66b --- /dev/null +++ b/app/views/formularios/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @formulario %> + +
+ <%= link_to "Edit this formulario", edit_formulario_path(@formulario) %> | + <%= link_to "Back to formularios", formularios_path %> + + <%= button_to "Destroy this formulario", @formulario, method: :delete %> +
diff --git a/app/views/formularios/show.json.jbuilder b/app/views/formularios/show.json.jbuilder new file mode 100644 index 0000000000..476f64d624 --- /dev/null +++ b/app/views/formularios/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "formularios/formulario", formulario: @formulario diff --git a/app/views/resposta_elems/_form.html.erb b/app/views/resposta_elems/_form.html.erb new file mode 100644 index 0000000000..3e09b2d5ee --- /dev/null +++ b/app/views/resposta_elems/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: resposta_elem) do |form| %> + <% if resposta_elem.errors.any? %> +
+

<%= pluralize(resposta_elem.errors.count, "error") %> prohibited this resposta_elem from being saved:

+ +
    + <% resposta_elem.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :texto_resposta, style: "display: block" %> + <%= form.textarea :texto_resposta %> +
+ +
+ <%= form.label :resposta_form_id, style: "display: block" %> + <%= form.text_field :resposta_form_id %> +
+ +
+ <%= form.label :elemento_form_id, style: "display: block" %> + <%= form.text_field :elemento_form_id %> +
+ +
+ <%= form.label :campo_form_id, style: "display: block" %> + <%= form.text_field :campo_form_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/resposta_elems/_resposta_elem.html.erb b/app/views/resposta_elems/_resposta_elem.html.erb new file mode 100644 index 0000000000..8c745b02ac --- /dev/null +++ b/app/views/resposta_elems/_resposta_elem.html.erb @@ -0,0 +1,22 @@ +
+
+ Texto resposta: + <%= resposta_elem.texto_resposta %> +
+ +
+ Resposta form: + <%= resposta_elem.resposta_form_id %> +
+ +
+ Elemento form: + <%= resposta_elem.elemento_form_id %> +
+ +
+ Campo form: + <%= resposta_elem.campo_form_id %> +
+ +
diff --git a/app/views/resposta_elems/_resposta_elem.json.jbuilder b/app/views/resposta_elems/_resposta_elem.json.jbuilder new file mode 100644 index 0000000000..ee21ede9bb --- /dev/null +++ b/app/views/resposta_elems/_resposta_elem.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! resposta_elem, :id, :texto_resposta, :resposta_form_id, :elemento_form_id, :campo_form_id, :created_at, :updated_at +json.url resposta_elem_url(resposta_elem, format: :json) diff --git a/app/views/resposta_elems/edit.html.erb b/app/views/resposta_elems/edit.html.erb new file mode 100644 index 0000000000..dc00e9f6b3 --- /dev/null +++ b/app/views/resposta_elems/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing resposta elem" %> + +

Editing resposta elem

+ +<%= render "form", resposta_elem: @resposta_elem %> + +
+ +
+ <%= link_to "Show this resposta elem", @resposta_elem %> | + <%= link_to "Back to resposta elems", resposta_elems_path %> +
diff --git a/app/views/resposta_elems/index.html.erb b/app/views/resposta_elems/index.html.erb new file mode 100644 index 0000000000..ab277400f0 --- /dev/null +++ b/app/views/resposta_elems/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Resposta elems" %> + +

Resposta elems

+ +
+ <% @resposta_elems.each do |resposta_elem| %> + <%= render resposta_elem %> +

+ <%= link_to "Show this resposta elem", resposta_elem %> +

+ <% end %> +
+ +<%= link_to "New resposta elem", new_resposta_elem_path %> diff --git a/app/views/resposta_elems/index.json.jbuilder b/app/views/resposta_elems/index.json.jbuilder new file mode 100644 index 0000000000..9bedba8ca4 --- /dev/null +++ b/app/views/resposta_elems/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @resposta_elems, partial: "resposta_elems/resposta_elem", as: :resposta_elem diff --git a/app/views/resposta_elems/new.html.erb b/app/views/resposta_elems/new.html.erb new file mode 100644 index 0000000000..b00f55c4cb --- /dev/null +++ b/app/views/resposta_elems/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New resposta elem" %> + +

New resposta elem

+ +<%= render "form", resposta_elem: @resposta_elem %> + +
+ +
+ <%= link_to "Back to resposta elems", resposta_elems_path %> +
diff --git a/app/views/resposta_elems/show.html.erb b/app/views/resposta_elems/show.html.erb new file mode 100644 index 0000000000..4662d00331 --- /dev/null +++ b/app/views/resposta_elems/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @resposta_elem %> + +
+ <%= link_to "Edit this resposta elem", edit_resposta_elem_path(@resposta_elem) %> | + <%= link_to "Back to resposta elems", resposta_elems_path %> + + <%= button_to "Destroy this resposta elem", @resposta_elem, method: :delete %> +
diff --git a/app/views/resposta_elems/show.json.jbuilder b/app/views/resposta_elems/show.json.jbuilder new file mode 100644 index 0000000000..33fcf947e4 --- /dev/null +++ b/app/views/resposta_elems/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "resposta_elems/resposta_elem", resposta_elem: @resposta_elem diff --git a/app/views/resposta_forms/_form.html.erb b/app/views/resposta_forms/_form.html.erb new file mode 100644 index 0000000000..8a1345f86c --- /dev/null +++ b/app/views/resposta_forms/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: resposta_form) do |form| %> + <% if resposta_form.errors.any? %> +
+

<%= pluralize(resposta_form.errors.count, "error") %> prohibited this resposta_form from being saved:

+ +
    + <% resposta_form.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :data_submissao, style: "display: block" %> + <%= form.date_field :data_submissao %> +
+ +
+ <%= form.label :formulario_id, style: "display: block" %> + <%= form.text_field :formulario_id %> +
+ +
+ <%= form.label :usuario_id, style: "display: block" %> + <%= form.text_field :usuario_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/resposta_forms/_resposta_form.html.erb b/app/views/resposta_forms/_resposta_form.html.erb new file mode 100644 index 0000000000..ca137130db --- /dev/null +++ b/app/views/resposta_forms/_resposta_form.html.erb @@ -0,0 +1,17 @@ +
+
+ Data submissao: + <%= resposta_form.data_submissao %> +
+ +
+ Formulario: + <%= resposta_form.formulario_id %> +
+ +
+ Usuario: + <%= resposta_form.usuario_id %> +
+ +
diff --git a/app/views/resposta_forms/_resposta_form.json.jbuilder b/app/views/resposta_forms/_resposta_form.json.jbuilder new file mode 100644 index 0000000000..72ef55e3d3 --- /dev/null +++ b/app/views/resposta_forms/_resposta_form.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! resposta_form, :id, :data_submissao, :formulario_id, :usuario_id, :created_at, :updated_at +json.url resposta_form_url(resposta_form, format: :json) diff --git a/app/views/resposta_forms/edit.html.erb b/app/views/resposta_forms/edit.html.erb new file mode 100644 index 0000000000..787853e439 --- /dev/null +++ b/app/views/resposta_forms/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing resposta form" %> + +

Editing resposta form

+ +<%= render "form", resposta_form: @resposta_form %> + +
+ +
+ <%= link_to "Show this resposta form", @resposta_form %> | + <%= link_to "Back to resposta forms", resposta_forms_path %> +
diff --git a/app/views/resposta_forms/index.html.erb b/app/views/resposta_forms/index.html.erb new file mode 100644 index 0000000000..1680e608d8 --- /dev/null +++ b/app/views/resposta_forms/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Resposta forms" %> + +

Resposta forms

+ +
+ <% @resposta_forms.each do |resposta_form| %> + <%= render resposta_form %> +

+ <%= link_to "Show this resposta form", resposta_form %> +

+ <% end %> +
+ +<%= link_to "New resposta form", new_resposta_form_path %> diff --git a/app/views/resposta_forms/index.json.jbuilder b/app/views/resposta_forms/index.json.jbuilder new file mode 100644 index 0000000000..a4ad662804 --- /dev/null +++ b/app/views/resposta_forms/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @resposta_forms, partial: "resposta_forms/resposta_form", as: :resposta_form diff --git a/app/views/resposta_forms/new.html.erb b/app/views/resposta_forms/new.html.erb new file mode 100644 index 0000000000..82472ef192 --- /dev/null +++ b/app/views/resposta_forms/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New resposta form" %> + +

New resposta form

+ +<%= render "form", resposta_form: @resposta_form %> + +
+ +
+ <%= link_to "Back to resposta forms", resposta_forms_path %> +
diff --git a/app/views/resposta_forms/show.html.erb b/app/views/resposta_forms/show.html.erb new file mode 100644 index 0000000000..e57e7b663c --- /dev/null +++ b/app/views/resposta_forms/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @resposta_form %> + +
+ <%= link_to "Edit this resposta form", edit_resposta_form_path(@resposta_form) %> | + <%= link_to "Back to resposta forms", resposta_forms_path %> + + <%= button_to "Destroy this resposta form", @resposta_form, method: :delete %> +
diff --git a/app/views/resposta_forms/show.json.jbuilder b/app/views/resposta_forms/show.json.jbuilder new file mode 100644 index 0000000000..cf7c6cab1f --- /dev/null +++ b/app/views/resposta_forms/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "resposta_forms/resposta_form", resposta_form: @resposta_form diff --git a/app/views/templates/_form.html.erb b/app/views/templates/_form.html.erb new file mode 100644 index 0000000000..556b3bf170 --- /dev/null +++ b/app/views/templates/_form.html.erb @@ -0,0 +1,22 @@ +<%= form_with(model: template) do |form| %> + <% if template.errors.any? %> +
+

<%= pluralize(template.errors.count, "error") %> prohibited this template from being saved:

+ +
    + <% template.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/templates/_template.html.erb b/app/views/templates/_template.html.erb new file mode 100644 index 0000000000..e9fdcd5bdd --- /dev/null +++ b/app/views/templates/_template.html.erb @@ -0,0 +1,7 @@ +
+
+ Nome: + <%= template.nome %> +
+ +
diff --git a/app/views/templates/_template.json.jbuilder b/app/views/templates/_template.json.jbuilder new file mode 100644 index 0000000000..4cffa98a79 --- /dev/null +++ b/app/views/templates/_template.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! template, :id, :nome, :created_at, :updated_at +json.url template_url(template, format: :json) diff --git a/app/views/templates/edit.html.erb b/app/views/templates/edit.html.erb new file mode 100644 index 0000000000..2fe355a9c7 --- /dev/null +++ b/app/views/templates/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing template" %> + +

Editing template

+ +<%= render "form", template: @template %> + +
+ +
+ <%= link_to "Show this template", @template %> | + <%= link_to "Back to templates", templates_path %> +
diff --git a/app/views/templates/index.html.erb b/app/views/templates/index.html.erb new file mode 100644 index 0000000000..93d4cd21c2 --- /dev/null +++ b/app/views/templates/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Templates" %> + +

Templates

+ +
+ <% @templates.each do |template| %> + <%= render template %> +

+ <%= link_to "Show this template", template %> +

+ <% end %> +
+ +<%= link_to "New template", new_template_path %> diff --git a/app/views/templates/index.json.jbuilder b/app/views/templates/index.json.jbuilder new file mode 100644 index 0000000000..5163fa0e1e --- /dev/null +++ b/app/views/templates/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @templates, partial: "templates/template", as: :template diff --git a/app/views/templates/new.html.erb b/app/views/templates/new.html.erb new file mode 100644 index 0000000000..bd2d47148d --- /dev/null +++ b/app/views/templates/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New template" %> + +

New template

+ +<%= render "form", template: @template %> + +
+ +
+ <%= link_to "Back to templates", templates_path %> +
diff --git a/app/views/templates/show.html.erb b/app/views/templates/show.html.erb new file mode 100644 index 0000000000..e610456e09 --- /dev/null +++ b/app/views/templates/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @template %> + +
+ <%= link_to "Edit this template", edit_template_path(@template) %> | + <%= link_to "Back to templates", templates_path %> + + <%= button_to "Destroy this template", @template, method: :delete %> +
diff --git a/app/views/templates/show.json.jbuilder b/app/views/templates/show.json.jbuilder new file mode 100644 index 0000000000..33110ec93b --- /dev/null +++ b/app/views/templates/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "templates/template", template: @template diff --git a/app/views/turmas/_form.html.erb b/app/views/turmas/_form.html.erb new file mode 100644 index 0000000000..fd4628cb48 --- /dev/null +++ b/app/views/turmas/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: turma) do |form| %> + <% if turma.errors.any? %> +
+

<%= pluralize(turma.errors.count, "error") %> prohibited this turma from being saved:

+ +
    + <% turma.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :numero_da_turma, style: "display: block" %> + <%= form.text_field :numero_da_turma %> +
+ +
+ <%= form.label :semestre, style: "display: block" %> + <%= form.text_field :semestre %> +
+ +
+ <%= form.label :horario, style: "display: block" %> + <%= form.text_field :horario %> +
+ +
+ <%= form.label :disciplina_id, style: "display: block" %> + <%= form.text_field :disciplina_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/turmas/_turma.html.erb b/app/views/turmas/_turma.html.erb new file mode 100644 index 0000000000..59428ae588 --- /dev/null +++ b/app/views/turmas/_turma.html.erb @@ -0,0 +1,22 @@ +
+
+ Numero da turma: + <%= turma.numero_da_turma %> +
+ +
+ Semestre: + <%= turma.semestre %> +
+ +
+ Horario: + <%= turma.horario %> +
+ +
+ Disciplina: + <%= turma.disciplina_id %> +
+ +
diff --git a/app/views/turmas/_turma.json.jbuilder b/app/views/turmas/_turma.json.jbuilder new file mode 100644 index 0000000000..f5e91fcfa8 --- /dev/null +++ b/app/views/turmas/_turma.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! turma, :id, :numero_da_turma, :semestre, :horario, :disciplina_id, :created_at, :updated_at +json.url turma_url(turma, format: :json) diff --git a/app/views/turmas/edit.html.erb b/app/views/turmas/edit.html.erb new file mode 100644 index 0000000000..108b99a6c2 --- /dev/null +++ b/app/views/turmas/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing turma" %> + +

Editing turma

+ +<%= render "form", turma: @turma %> + +
+ +
+ <%= link_to "Show this turma", @turma %> | + <%= link_to "Back to turmas", turmas_path %> +
diff --git a/app/views/turmas/index.html.erb b/app/views/turmas/index.html.erb new file mode 100644 index 0000000000..72ec97a969 --- /dev/null +++ b/app/views/turmas/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Turmas" %> + +

Turmas

+ +
+ <% @turmas.each do |turma| %> + <%= render turma %> +

+ <%= link_to "Show this turma", turma %> +

+ <% end %> +
+ +<%= link_to "New turma", new_turma_path %> diff --git a/app/views/turmas/index.json.jbuilder b/app/views/turmas/index.json.jbuilder new file mode 100644 index 0000000000..e70b9255db --- /dev/null +++ b/app/views/turmas/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @turmas, partial: "turmas/turma", as: :turma diff --git a/app/views/turmas/new.html.erb b/app/views/turmas/new.html.erb new file mode 100644 index 0000000000..477e3282ff --- /dev/null +++ b/app/views/turmas/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New turma" %> + +

New turma

+ +<%= render "form", turma: @turma %> + +
+ +
+ <%= link_to "Back to turmas", turmas_path %> +
diff --git a/app/views/turmas/show.html.erb b/app/views/turmas/show.html.erb new file mode 100644 index 0000000000..72fb58239d --- /dev/null +++ b/app/views/turmas/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @turma %> + +
+ <%= link_to "Edit this turma", edit_turma_path(@turma) %> | + <%= link_to "Back to turmas", turmas_path %> + + <%= button_to "Destroy this turma", @turma, method: :delete %> +
diff --git a/app/views/turmas/show.json.jbuilder b/app/views/turmas/show.json.jbuilder new file mode 100644 index 0000000000..1d164186aa --- /dev/null +++ b/app/views/turmas/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "turmas/turma", turma: @turma diff --git a/app/views/usuarios/_form.html.erb b/app/views/usuarios/_form.html.erb new file mode 100644 index 0000000000..6a0bcb7c33 --- /dev/null +++ b/app/views/usuarios/_form.html.erb @@ -0,0 +1,42 @@ +<%= form_with(model: usuario) do |form| %> + <% if usuario.errors.any? %> +
+

<%= pluralize(usuario.errors.count, "error") %> prohibited this usuario from being saved:

+ +
    + <% usuario.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :matricula, style: "display: block" %> + <%= form.text_field :matricula %> +
+ +
+ <%= form.label :email, style: "display: block" %> + <%= form.text_field :email %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :formacao, style: "display: block" %> + <%= form.text_field :formacao %> +
+ +
+ <%= form.label :type, style: "display: block" %> + <%= form.text_field :type %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/usuarios/_usuario.html.erb b/app/views/usuarios/_usuario.html.erb new file mode 100644 index 0000000000..6defd9c276 --- /dev/null +++ b/app/views/usuarios/_usuario.html.erb @@ -0,0 +1,27 @@ +
+
+ Matricula: + <%= usuario.matricula %> +
+ +
+ Email: + <%= usuario.email %> +
+ +
+ Nome: + <%= usuario.nome %> +
+ +
+ Formacao: + <%= usuario.formacao %> +
+ +
+ Type: + <%= usuario.type %> +
+ +
diff --git a/app/views/usuarios/_usuario.json.jbuilder b/app/views/usuarios/_usuario.json.jbuilder new file mode 100644 index 0000000000..4f0dd1450d --- /dev/null +++ b/app/views/usuarios/_usuario.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! usuario, :id, :matricula, :email, :nome, :formacao, :type, :created_at, :updated_at +json.url usuario_url(usuario, format: :json) diff --git a/app/views/usuarios/edit.html.erb b/app/views/usuarios/edit.html.erb new file mode 100644 index 0000000000..670af5b784 --- /dev/null +++ b/app/views/usuarios/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing usuario" %> + +

Editing usuario

+ +<%= render "form", usuario: @usuario %> + +
+ +
+ <%= link_to "Show this usuario", @usuario %> | + <%= link_to "Back to usuarios", usuarios_path %> +
diff --git a/app/views/usuarios/index.html.erb b/app/views/usuarios/index.html.erb new file mode 100644 index 0000000000..53b9428ddc --- /dev/null +++ b/app/views/usuarios/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Usuarios" %> + +

Usuarios

+ +
+ <% @usuarios.each do |usuario| %> + <%= render usuario %> +

+ <%= link_to "Show this usuario", usuario %> +

+ <% end %> +
+ +<%= link_to "New usuario", new_usuario_path %> diff --git a/app/views/usuarios/index.json.jbuilder b/app/views/usuarios/index.json.jbuilder new file mode 100644 index 0000000000..b7fdb3ce8f --- /dev/null +++ b/app/views/usuarios/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @usuarios, partial: "usuarios/usuario", as: :usuario diff --git a/app/views/usuarios/new.html.erb b/app/views/usuarios/new.html.erb new file mode 100644 index 0000000000..8a2c9f08cc --- /dev/null +++ b/app/views/usuarios/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New usuario" %> + +

New usuario

+ +<%= render "form", usuario: @usuario %> + +
+ +
+ <%= link_to "Back to usuarios", usuarios_path %> +
diff --git a/app/views/usuarios/show.html.erb b/app/views/usuarios/show.html.erb new file mode 100644 index 0000000000..ae4030189d --- /dev/null +++ b/app/views/usuarios/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @usuario %> + +
+ <%= link_to "Edit this usuario", edit_usuario_path(@usuario) %> | + <%= link_to "Back to usuarios", usuarios_path %> + + <%= button_to "Destroy this usuario", @usuario, method: :delete %> +
diff --git a/app/views/usuarios/show.json.jbuilder b/app/views/usuarios/show.json.jbuilder new file mode 100644 index 0000000000..ad071a9501 --- /dev/null +++ b/app/views/usuarios/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "usuarios/usuario", usuario: @usuario diff --git a/config/database.yml b/config/database.yml index 26477427b2..a857bdc858 100644 --- a/config/database.yml +++ b/config/database.yml @@ -12,10 +12,10 @@ default: &default adapter: mysql2 encoding: utf8mb4 - max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root - password: - socket: /tmp/mysql.sock + password: root + socket: /var/run/mysqld/mysqld.sock development: <<: *default diff --git a/config/routes.rb b/config/routes.rb index 48254e88ed..20f16c622c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,19 @@ Rails.application.routes.draw do + resources :resposta_elems + resources :resposta_forms + resources :campo_forms + resources :elemento_forms + resources :formularios + resources :campos + resources :elementos + resources :templates + resources :docentes + resources :discentes + resources :usuarios + resources :turmas + resources :disciplinas + resources :cursos + resources :departamentos # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. diff --git a/db/migrate/20260527234832_create_departamentos.rb b/db/migrate/20260527234832_create_departamentos.rb new file mode 100644 index 0000000000..d68e988470 --- /dev/null +++ b/db/migrate/20260527234832_create_departamentos.rb @@ -0,0 +1,11 @@ +class CreateDepartamentos < ActiveRecord::Migration[8.1] + def change + create_table :departamentos do |t| + t.string :codigo + t.string :nome + + t.timestamps + end + add_index :departamentos, :codigo, unique: true + end +end diff --git a/db/migrate/20260527234834_create_cursos.rb b/db/migrate/20260527234834_create_cursos.rb new file mode 100644 index 0000000000..df00ece751 --- /dev/null +++ b/db/migrate/20260527234834_create_cursos.rb @@ -0,0 +1,12 @@ +class CreateCursos < ActiveRecord::Migration[8.1] + def change + create_table :cursos do |t| + t.string :codigo + t.string :nome + t.references :departamento, null: false, foreign_key: true + + t.timestamps + end + add_index :cursos, :codigo, unique: true + end +end diff --git a/db/migrate/20260527234836_create_disciplinas.rb b/db/migrate/20260527234836_create_disciplinas.rb new file mode 100644 index 0000000000..3792bd4359 --- /dev/null +++ b/db/migrate/20260527234836_create_disciplinas.rb @@ -0,0 +1,12 @@ +class CreateDisciplinas < ActiveRecord::Migration[8.1] + def change + create_table :disciplinas do |t| + t.string :codigo + t.string :nome + t.references :departamento, null: false, foreign_key: true + + t.timestamps + end + add_index :disciplinas, :codigo, unique: true + end +end diff --git a/db/migrate/20260527234838_create_turmas.rb b/db/migrate/20260527234838_create_turmas.rb new file mode 100644 index 0000000000..6cebbbbf67 --- /dev/null +++ b/db/migrate/20260527234838_create_turmas.rb @@ -0,0 +1,12 @@ +class CreateTurmas < ActiveRecord::Migration[8.1] + def change + create_table :turmas do |t| + t.string :numero_da_turma + t.string :semestre + t.string :horario + t.references :disciplina, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235010_create_usuarios.rb b/db/migrate/20260527235010_create_usuarios.rb new file mode 100644 index 0000000000..0810d70635 --- /dev/null +++ b/db/migrate/20260527235010_create_usuarios.rb @@ -0,0 +1,17 @@ +class CreateUsuarios < ActiveRecord::Migration[8.1] + def change + create_table :usuarios do |t| + t.string :matricula + t.string :senha_hash + t.string :email + t.string :nome + t.string :formacao + t.string :type + t.references :curso, null: false, foreign_key: true + t.references :departamento, null: false, foreign_key: true + + t.timestamps + end + add_index :usuarios, :matricula, unique: true + end +end diff --git a/db/migrate/20260527235026_create_templates.rb b/db/migrate/20260527235026_create_templates.rb new file mode 100644 index 0000000000..0170a38e2c --- /dev/null +++ b/db/migrate/20260527235026_create_templates.rb @@ -0,0 +1,9 @@ +class CreateTemplates < ActiveRecord::Migration[8.1] + def change + create_table :templates do |t| + t.string :nome + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235028_create_elementos.rb b/db/migrate/20260527235028_create_elementos.rb new file mode 100644 index 0000000000..0f606f6609 --- /dev/null +++ b/db/migrate/20260527235028_create_elementos.rb @@ -0,0 +1,11 @@ +class CreateElementos < ActiveRecord::Migration[8.1] + def change + create_table :elementos do |t| + t.integer :ordem + t.string :enunciado + t.references :template, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235031_create_campos.rb b/db/migrate/20260527235031_create_campos.rb new file mode 100644 index 0000000000..2eed8b9a65 --- /dev/null +++ b/db/migrate/20260527235031_create_campos.rb @@ -0,0 +1,12 @@ +class CreateCampos < ActiveRecord::Migration[8.1] + def change + create_table :campos do |t| + t.integer :ordem + t.string :enunciado + t.string :tipo_elemento + t.references :elemento, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235053_create_formularios.rb b/db/migrate/20260527235053_create_formularios.rb new file mode 100644 index 0000000000..a0db30072f --- /dev/null +++ b/db/migrate/20260527235053_create_formularios.rb @@ -0,0 +1,9 @@ +class CreateFormularios < ActiveRecord::Migration[8.1] + def change + create_table :formularios do |t| + t.references :turma, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235055_create_elemento_forms.rb b/db/migrate/20260527235055_create_elemento_forms.rb new file mode 100644 index 0000000000..af930be937 --- /dev/null +++ b/db/migrate/20260527235055_create_elemento_forms.rb @@ -0,0 +1,11 @@ +class CreateElementoForms < ActiveRecord::Migration[8.1] + def change + create_table :elemento_forms do |t| + t.integer :ordem + t.string :enunciado + t.references :formulario, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235057_create_campo_forms.rb b/db/migrate/20260527235057_create_campo_forms.rb new file mode 100644 index 0000000000..383ec9749f --- /dev/null +++ b/db/migrate/20260527235057_create_campo_forms.rb @@ -0,0 +1,11 @@ +class CreateCampoForms < ActiveRecord::Migration[8.1] + def change + create_table :campo_forms do |t| + t.integer :ordem + t.string :enunciado + t.references :elemento_form, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235101_create_resposta_forms.rb b/db/migrate/20260527235101_create_resposta_forms.rb new file mode 100644 index 0000000000..6e8b112723 --- /dev/null +++ b/db/migrate/20260527235101_create_resposta_forms.rb @@ -0,0 +1,11 @@ +class CreateRespostaForms < ActiveRecord::Migration[8.1] + def change + create_table :resposta_forms do |t| + t.date :data_submissao + t.references :formulario, null: false, foreign_key: true + t.references :usuario, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235104_create_resposta_elems.rb b/db/migrate/20260527235104_create_resposta_elems.rb new file mode 100644 index 0000000000..8c9aa6fba9 --- /dev/null +++ b/db/migrate/20260527235104_create_resposta_elems.rb @@ -0,0 +1,12 @@ +class CreateRespostaElems < ActiveRecord::Migration[8.1] + def change + create_table :resposta_elems do |t| + t.text :texto_resposta + t.references :resposta_form, null: false, foreign_key: true + t.references :elemento_form, null: false, foreign_key: true + t.references :campo_form, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260528000107_create_join_table_discente_turma.rb b/db/migrate/20260528000107_create_join_table_discente_turma.rb new file mode 100644 index 0000000000..caf907c424 --- /dev/null +++ b/db/migrate/20260528000107_create_join_table_discente_turma.rb @@ -0,0 +1,8 @@ +class CreateJoinTableDiscenteTurma < ActiveRecord::Migration[8.1] + def change + create_join_table :discentes, :turmas do |t| + # t.index [:discente_id, :turma_id] + # t.index [:turma_id, :discente_id] + end + end +end diff --git a/db/migrate/20260528000109_create_join_table_docente_turma.rb b/db/migrate/20260528000109_create_join_table_docente_turma.rb new file mode 100644 index 0000000000..962b882b0c --- /dev/null +++ b/db/migrate/20260528000109_create_join_table_docente_turma.rb @@ -0,0 +1,8 @@ +class CreateJoinTableDocenteTurma < ActiveRecord::Migration[8.1] + def change + create_join_table :docentes, :turmas do |t| + # t.index [:docente_id, :turma_id] + # t.index [:turma_id, :docente_id] + end + end +end diff --git a/db/migrate/20260528002258_ajusta_nulos_para_sti.rb b/db/migrate/20260528002258_ajusta_nulos_para_sti.rb new file mode 100644 index 0000000000..dda7db719a --- /dev/null +++ b/db/migrate/20260528002258_ajusta_nulos_para_sti.rb @@ -0,0 +1,7 @@ +class AjustaNulosParaSti < ActiveRecord::Migration[8.1] + def change + change_column_null :usuarios, :curso_id, true + change_column_null :usuarios, :departamento_id, true + change_column_null :resposta_elems, :campo_form_id, true + end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000000..79f6d96e13 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,165 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[8.1].define(version: 2026_05_28_002258) do + create_table "campo_forms", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "elemento_form_id", null: false + t.string "enunciado" + t.integer "ordem" + t.datetime "updated_at", null: false + t.index ["elemento_form_id"], name: "index_campo_forms_on_elemento_form_id" + end + + create_table "campos", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "elemento_id", null: false + t.string "enunciado" + t.integer "ordem" + t.string "tipo_elemento" + t.datetime "updated_at", null: false + t.index ["elemento_id"], name: "index_campos_on_elemento_id" + end + + create_table "cursos", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "codigo" + t.datetime "created_at", null: false + t.bigint "departamento_id", null: false + t.string "nome" + t.datetime "updated_at", null: false + t.index ["codigo"], name: "index_cursos_on_codigo", unique: true + t.index ["departamento_id"], name: "index_cursos_on_departamento_id" + end + + create_table "departamentos", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "codigo" + t.datetime "created_at", null: false + t.string "nome" + t.datetime "updated_at", null: false + t.index ["codigo"], name: "index_departamentos_on_codigo", unique: true + end + + create_table "discentes_turmas", id: false, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "discente_id", null: false + t.bigint "turma_id", null: false + end + + create_table "disciplinas", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "codigo" + t.datetime "created_at", null: false + t.bigint "departamento_id", null: false + t.string "nome" + t.datetime "updated_at", null: false + t.index ["codigo"], name: "index_disciplinas_on_codigo", unique: true + t.index ["departamento_id"], name: "index_disciplinas_on_departamento_id" + end + + create_table "docentes_turmas", id: false, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "docente_id", null: false + t.bigint "turma_id", null: false + end + + create_table "elemento_forms", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "enunciado" + t.bigint "formulario_id", null: false + t.integer "ordem" + t.datetime "updated_at", null: false + t.index ["formulario_id"], name: "index_elemento_forms_on_formulario_id" + end + + create_table "elementos", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "enunciado" + t.integer "ordem" + t.bigint "template_id", null: false + t.datetime "updated_at", null: false + t.index ["template_id"], name: "index_elementos_on_template_id" + end + + create_table "formularios", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "turma_id", null: false + t.datetime "updated_at", null: false + t.index ["turma_id"], name: "index_formularios_on_turma_id" + end + + create_table "resposta_elems", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "campo_form_id" + t.datetime "created_at", null: false + t.bigint "elemento_form_id", null: false + t.bigint "resposta_form_id", null: false + t.text "texto_resposta" + t.datetime "updated_at", null: false + t.index ["campo_form_id"], name: "index_resposta_elems_on_campo_form_id" + t.index ["elemento_form_id"], name: "index_resposta_elems_on_elemento_form_id" + t.index ["resposta_form_id"], name: "index_resposta_elems_on_resposta_form_id" + end + + create_table "resposta_forms", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.date "data_submissao" + t.bigint "formulario_id", null: false + t.datetime "updated_at", null: false + t.bigint "usuario_id", null: false + t.index ["formulario_id"], name: "index_resposta_forms_on_formulario_id" + t.index ["usuario_id"], name: "index_resposta_forms_on_usuario_id" + end + + create_table "templates", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "nome" + t.datetime "updated_at", null: false + end + + create_table "turmas", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "disciplina_id", null: false + t.string "horario" + t.string "numero_da_turma" + t.string "semestre" + t.datetime "updated_at", null: false + t.index ["disciplina_id"], name: "index_turmas_on_disciplina_id" + end + + create_table "usuarios", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "curso_id" + t.bigint "departamento_id" + t.string "email" + t.string "formacao" + t.string "matricula" + t.string "nome" + t.string "senha_hash" + t.string "type" + t.datetime "updated_at", null: false + t.index ["curso_id"], name: "index_usuarios_on_curso_id" + t.index ["departamento_id"], name: "index_usuarios_on_departamento_id" + t.index ["matricula"], name: "index_usuarios_on_matricula", unique: true + end + + add_foreign_key "campo_forms", "elemento_forms" + add_foreign_key "campos", "elementos" + add_foreign_key "cursos", "departamentos" + add_foreign_key "disciplinas", "departamentos" + add_foreign_key "elemento_forms", "formularios" + add_foreign_key "elementos", "templates" + add_foreign_key "formularios", "turmas" + add_foreign_key "resposta_elems", "campo_forms" + add_foreign_key "resposta_elems", "elemento_forms" + add_foreign_key "resposta_elems", "resposta_forms" + add_foreign_key "resposta_forms", "formularios" + add_foreign_key "resposta_forms", "usuarios" + add_foreign_key "turmas", "disciplinas" + add_foreign_key "usuarios", "cursos" + add_foreign_key "usuarios", "departamentos" +end diff --git a/spec/helpers/campo_forms_helper_spec.rb b/spec/helpers/campo_forms_helper_spec.rb new file mode 100644 index 0000000000..03f4e78d98 --- /dev/null +++ b/spec/helpers/campo_forms_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the CampoFormsHelper. For example: +# +# describe CampoFormsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe CampoFormsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/campos_helper_spec.rb b/spec/helpers/campos_helper_spec.rb new file mode 100644 index 0000000000..6b7b8f6a57 --- /dev/null +++ b/spec/helpers/campos_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the CamposHelper. For example: +# +# describe CamposHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe CamposHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/cursos_helper_spec.rb b/spec/helpers/cursos_helper_spec.rb new file mode 100644 index 0000000000..48e2f77109 --- /dev/null +++ b/spec/helpers/cursos_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the CursosHelper. For example: +# +# describe CursosHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe CursosHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/departamentos_helper_spec.rb b/spec/helpers/departamentos_helper_spec.rb new file mode 100644 index 0000000000..07c9be8f3c --- /dev/null +++ b/spec/helpers/departamentos_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the DepartamentosHelper. For example: +# +# describe DepartamentosHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe DepartamentosHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/discentes_helper_spec.rb b/spec/helpers/discentes_helper_spec.rb new file mode 100644 index 0000000000..988b0ccdcf --- /dev/null +++ b/spec/helpers/discentes_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the DiscentesHelper. For example: +# +# describe DiscentesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe DiscentesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/disciplinas_helper_spec.rb b/spec/helpers/disciplinas_helper_spec.rb new file mode 100644 index 0000000000..43afb7d2c3 --- /dev/null +++ b/spec/helpers/disciplinas_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the DisciplinasHelper. For example: +# +# describe DisciplinasHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe DisciplinasHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/docentes_helper_spec.rb b/spec/helpers/docentes_helper_spec.rb new file mode 100644 index 0000000000..f39a1e5870 --- /dev/null +++ b/spec/helpers/docentes_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the DocentesHelper. For example: +# +# describe DocentesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe DocentesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/elemento_forms_helper_spec.rb b/spec/helpers/elemento_forms_helper_spec.rb new file mode 100644 index 0000000000..51c345f796 --- /dev/null +++ b/spec/helpers/elemento_forms_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ElementoFormsHelper. For example: +# +# describe ElementoFormsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ElementoFormsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/elementos_helper_spec.rb b/spec/helpers/elementos_helper_spec.rb new file mode 100644 index 0000000000..908f8b4903 --- /dev/null +++ b/spec/helpers/elementos_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ElementosHelper. For example: +# +# describe ElementosHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ElementosHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/formularios_helper_spec.rb b/spec/helpers/formularios_helper_spec.rb new file mode 100644 index 0000000000..b5045f4f06 --- /dev/null +++ b/spec/helpers/formularios_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the FormulariosHelper. For example: +# +# describe FormulariosHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe FormulariosHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/resposta_elems_helper_spec.rb b/spec/helpers/resposta_elems_helper_spec.rb new file mode 100644 index 0000000000..67dc42c971 --- /dev/null +++ b/spec/helpers/resposta_elems_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the RespostaElemsHelper. For example: +# +# describe RespostaElemsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe RespostaElemsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/resposta_forms_helper_spec.rb b/spec/helpers/resposta_forms_helper_spec.rb new file mode 100644 index 0000000000..506dedc8a3 --- /dev/null +++ b/spec/helpers/resposta_forms_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the RespostaFormsHelper. For example: +# +# describe RespostaFormsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe RespostaFormsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/templates_helper_spec.rb b/spec/helpers/templates_helper_spec.rb new file mode 100644 index 0000000000..5abfcb5dc5 --- /dev/null +++ b/spec/helpers/templates_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the TemplatesHelper. For example: +# +# describe TemplatesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe TemplatesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/turmas_helper_spec.rb b/spec/helpers/turmas_helper_spec.rb new file mode 100644 index 0000000000..dcae56f9ef --- /dev/null +++ b/spec/helpers/turmas_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the TurmasHelper. For example: +# +# describe TurmasHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe TurmasHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/usuarios_helper_spec.rb b/spec/helpers/usuarios_helper_spec.rb new file mode 100644 index 0000000000..f92d1f5608 --- /dev/null +++ b/spec/helpers/usuarios_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the UsuariosHelper. For example: +# +# describe UsuariosHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe UsuariosHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/campo_form_spec.rb b/spec/models/campo_form_spec.rb new file mode 100644 index 0000000000..05d3574c3d --- /dev/null +++ b/spec/models/campo_form_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CampoForm, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/campo_spec.rb b/spec/models/campo_spec.rb new file mode 100644 index 0000000000..6618006be8 --- /dev/null +++ b/spec/models/campo_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Campo, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/curso_spec.rb b/spec/models/curso_spec.rb new file mode 100644 index 0000000000..4e29152a4a --- /dev/null +++ b/spec/models/curso_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Curso, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/departamento_spec.rb b/spec/models/departamento_spec.rb new file mode 100644 index 0000000000..0a0d313f9c --- /dev/null +++ b/spec/models/departamento_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Departamento, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/disciplina_spec.rb b/spec/models/disciplina_spec.rb new file mode 100644 index 0000000000..17de7443da --- /dev/null +++ b/spec/models/disciplina_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Disciplina, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/elemento_form_spec.rb b/spec/models/elemento_form_spec.rb new file mode 100644 index 0000000000..2a8ad23d78 --- /dev/null +++ b/spec/models/elemento_form_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ElementoForm, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/elemento_spec.rb b/spec/models/elemento_spec.rb new file mode 100644 index 0000000000..fd36adff7a --- /dev/null +++ b/spec/models/elemento_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Elemento, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/formulario_spec.rb b/spec/models/formulario_spec.rb new file mode 100644 index 0000000000..2318f88769 --- /dev/null +++ b/spec/models/formulario_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Formulario, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/resposta_elem_spec.rb b/spec/models/resposta_elem_spec.rb new file mode 100644 index 0000000000..f466723e9d --- /dev/null +++ b/spec/models/resposta_elem_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe RespostaElem, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/resposta_form_spec.rb b/spec/models/resposta_form_spec.rb new file mode 100644 index 0000000000..16bb6683d4 --- /dev/null +++ b/spec/models/resposta_form_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe RespostaForm, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/template_spec.rb b/spec/models/template_spec.rb new file mode 100644 index 0000000000..068ef0ee3c --- /dev/null +++ b/spec/models/template_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Template, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/turma_spec.rb b/spec/models/turma_spec.rb new file mode 100644 index 0000000000..b7629b1e16 --- /dev/null +++ b/spec/models/turma_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Turma, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/usuario_spec.rb b/spec/models/usuario_spec.rb new file mode 100644 index 0000000000..12591f4841 --- /dev/null +++ b/spec/models/usuario_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Usuario, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/campo_forms_spec.rb b/spec/requests/campo_forms_spec.rb new file mode 100644 index 0000000000..a778ebc107 --- /dev/null +++ b/spec/requests/campo_forms_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/campo_forms", type: :request do + + # This should return the minimal set of attributes required to create a valid + # CampoForm. As you add validations to CampoForm, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + CampoForm.create! valid_attributes + get campo_forms_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + campo_form = CampoForm.create! valid_attributes + get campo_form_url(campo_form) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_campo_form_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + campo_form = CampoForm.create! valid_attributes + get edit_campo_form_url(campo_form) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new CampoForm" do + expect { + post campo_forms_url, params: { campo_form: valid_attributes } + }.to change(CampoForm, :count).by(1) + end + + it "redirects to the created campo_form" do + post campo_forms_url, params: { campo_form: valid_attributes } + expect(response).to redirect_to(campo_form_url(CampoForm.last)) + end + end + + context "with invalid parameters" do + it "does not create a new CampoForm" do + expect { + post campo_forms_url, params: { campo_form: invalid_attributes } + }.to change(CampoForm, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post campo_forms_url, params: { campo_form: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested campo_form" do + campo_form = CampoForm.create! valid_attributes + patch campo_form_url(campo_form), params: { campo_form: new_attributes } + campo_form.reload + skip("Add assertions for updated state") + end + + it "redirects to the campo_form" do + campo_form = CampoForm.create! valid_attributes + patch campo_form_url(campo_form), params: { campo_form: new_attributes } + campo_form.reload + expect(response).to redirect_to(campo_form_url(campo_form)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + campo_form = CampoForm.create! valid_attributes + patch campo_form_url(campo_form), params: { campo_form: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested campo_form" do + campo_form = CampoForm.create! valid_attributes + expect { + delete campo_form_url(campo_form) + }.to change(CampoForm, :count).by(-1) + end + + it "redirects to the campo_forms list" do + campo_form = CampoForm.create! valid_attributes + delete campo_form_url(campo_form) + expect(response).to redirect_to(campo_forms_url) + end + end +end diff --git a/spec/requests/campos_spec.rb b/spec/requests/campos_spec.rb new file mode 100644 index 0000000000..2710f29740 --- /dev/null +++ b/spec/requests/campos_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/campos", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Campo. As you add validations to Campo, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Campo.create! valid_attributes + get campos_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + campo = Campo.create! valid_attributes + get campo_url(campo) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_campo_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + campo = Campo.create! valid_attributes + get edit_campo_url(campo) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Campo" do + expect { + post campos_url, params: { campo: valid_attributes } + }.to change(Campo, :count).by(1) + end + + it "redirects to the created campo" do + post campos_url, params: { campo: valid_attributes } + expect(response).to redirect_to(campo_url(Campo.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Campo" do + expect { + post campos_url, params: { campo: invalid_attributes } + }.to change(Campo, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post campos_url, params: { campo: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested campo" do + campo = Campo.create! valid_attributes + patch campo_url(campo), params: { campo: new_attributes } + campo.reload + skip("Add assertions for updated state") + end + + it "redirects to the campo" do + campo = Campo.create! valid_attributes + patch campo_url(campo), params: { campo: new_attributes } + campo.reload + expect(response).to redirect_to(campo_url(campo)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + campo = Campo.create! valid_attributes + patch campo_url(campo), params: { campo: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested campo" do + campo = Campo.create! valid_attributes + expect { + delete campo_url(campo) + }.to change(Campo, :count).by(-1) + end + + it "redirects to the campos list" do + campo = Campo.create! valid_attributes + delete campo_url(campo) + expect(response).to redirect_to(campos_url) + end + end +end diff --git a/spec/requests/cursos_spec.rb b/spec/requests/cursos_spec.rb new file mode 100644 index 0000000000..ee0aef9826 --- /dev/null +++ b/spec/requests/cursos_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/cursos", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Curso. As you add validations to Curso, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Curso.create! valid_attributes + get cursos_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + curso = Curso.create! valid_attributes + get curso_url(curso) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_curso_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + curso = Curso.create! valid_attributes + get edit_curso_url(curso) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Curso" do + expect { + post cursos_url, params: { curso: valid_attributes } + }.to change(Curso, :count).by(1) + end + + it "redirects to the created curso" do + post cursos_url, params: { curso: valid_attributes } + expect(response).to redirect_to(curso_url(Curso.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Curso" do + expect { + post cursos_url, params: { curso: invalid_attributes } + }.to change(Curso, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post cursos_url, params: { curso: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested curso" do + curso = Curso.create! valid_attributes + patch curso_url(curso), params: { curso: new_attributes } + curso.reload + skip("Add assertions for updated state") + end + + it "redirects to the curso" do + curso = Curso.create! valid_attributes + patch curso_url(curso), params: { curso: new_attributes } + curso.reload + expect(response).to redirect_to(curso_url(curso)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + curso = Curso.create! valid_attributes + patch curso_url(curso), params: { curso: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested curso" do + curso = Curso.create! valid_attributes + expect { + delete curso_url(curso) + }.to change(Curso, :count).by(-1) + end + + it "redirects to the cursos list" do + curso = Curso.create! valid_attributes + delete curso_url(curso) + expect(response).to redirect_to(cursos_url) + end + end +end diff --git a/spec/requests/departamentos_spec.rb b/spec/requests/departamentos_spec.rb new file mode 100644 index 0000000000..ca13d8c22e --- /dev/null +++ b/spec/requests/departamentos_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/departamentos", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Departamento. As you add validations to Departamento, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Departamento.create! valid_attributes + get departamentos_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + departamento = Departamento.create! valid_attributes + get departamento_url(departamento) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_departamento_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + departamento = Departamento.create! valid_attributes + get edit_departamento_url(departamento) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Departamento" do + expect { + post departamentos_url, params: { departamento: valid_attributes } + }.to change(Departamento, :count).by(1) + end + + it "redirects to the created departamento" do + post departamentos_url, params: { departamento: valid_attributes } + expect(response).to redirect_to(departamento_url(Departamento.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Departamento" do + expect { + post departamentos_url, params: { departamento: invalid_attributes } + }.to change(Departamento, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post departamentos_url, params: { departamento: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested departamento" do + departamento = Departamento.create! valid_attributes + patch departamento_url(departamento), params: { departamento: new_attributes } + departamento.reload + skip("Add assertions for updated state") + end + + it "redirects to the departamento" do + departamento = Departamento.create! valid_attributes + patch departamento_url(departamento), params: { departamento: new_attributes } + departamento.reload + expect(response).to redirect_to(departamento_url(departamento)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + departamento = Departamento.create! valid_attributes + patch departamento_url(departamento), params: { departamento: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested departamento" do + departamento = Departamento.create! valid_attributes + expect { + delete departamento_url(departamento) + }.to change(Departamento, :count).by(-1) + end + + it "redirects to the departamentos list" do + departamento = Departamento.create! valid_attributes + delete departamento_url(departamento) + expect(response).to redirect_to(departamentos_url) + end + end +end diff --git a/spec/requests/discentes_spec.rb b/spec/requests/discentes_spec.rb new file mode 100644 index 0000000000..f7ab13b634 --- /dev/null +++ b/spec/requests/discentes_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/discentes", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Discente. As you add validations to Discente, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Discente.create! valid_attributes + get discentes_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + discente = Discente.create! valid_attributes + get discente_url(discente) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_discente_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + discente = Discente.create! valid_attributes + get edit_discente_url(discente) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Discente" do + expect { + post discentes_url, params: { discente: valid_attributes } + }.to change(Discente, :count).by(1) + end + + it "redirects to the created discente" do + post discentes_url, params: { discente: valid_attributes } + expect(response).to redirect_to(discente_url(Discente.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Discente" do + expect { + post discentes_url, params: { discente: invalid_attributes } + }.to change(Discente, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post discentes_url, params: { discente: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested discente" do + discente = Discente.create! valid_attributes + patch discente_url(discente), params: { discente: new_attributes } + discente.reload + skip("Add assertions for updated state") + end + + it "redirects to the discente" do + discente = Discente.create! valid_attributes + patch discente_url(discente), params: { discente: new_attributes } + discente.reload + expect(response).to redirect_to(discente_url(discente)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + discente = Discente.create! valid_attributes + patch discente_url(discente), params: { discente: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested discente" do + discente = Discente.create! valid_attributes + expect { + delete discente_url(discente) + }.to change(Discente, :count).by(-1) + end + + it "redirects to the discentes list" do + discente = Discente.create! valid_attributes + delete discente_url(discente) + expect(response).to redirect_to(discentes_url) + end + end +end diff --git a/spec/requests/disciplinas_spec.rb b/spec/requests/disciplinas_spec.rb new file mode 100644 index 0000000000..a962a5c82f --- /dev/null +++ b/spec/requests/disciplinas_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/disciplinas", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Disciplina. As you add validations to Disciplina, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Disciplina.create! valid_attributes + get disciplinas_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + disciplina = Disciplina.create! valid_attributes + get disciplina_url(disciplina) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_disciplina_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + disciplina = Disciplina.create! valid_attributes + get edit_disciplina_url(disciplina) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Disciplina" do + expect { + post disciplinas_url, params: { disciplina: valid_attributes } + }.to change(Disciplina, :count).by(1) + end + + it "redirects to the created disciplina" do + post disciplinas_url, params: { disciplina: valid_attributes } + expect(response).to redirect_to(disciplina_url(Disciplina.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Disciplina" do + expect { + post disciplinas_url, params: { disciplina: invalid_attributes } + }.to change(Disciplina, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post disciplinas_url, params: { disciplina: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested disciplina" do + disciplina = Disciplina.create! valid_attributes + patch disciplina_url(disciplina), params: { disciplina: new_attributes } + disciplina.reload + skip("Add assertions for updated state") + end + + it "redirects to the disciplina" do + disciplina = Disciplina.create! valid_attributes + patch disciplina_url(disciplina), params: { disciplina: new_attributes } + disciplina.reload + expect(response).to redirect_to(disciplina_url(disciplina)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + disciplina = Disciplina.create! valid_attributes + patch disciplina_url(disciplina), params: { disciplina: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested disciplina" do + disciplina = Disciplina.create! valid_attributes + expect { + delete disciplina_url(disciplina) + }.to change(Disciplina, :count).by(-1) + end + + it "redirects to the disciplinas list" do + disciplina = Disciplina.create! valid_attributes + delete disciplina_url(disciplina) + expect(response).to redirect_to(disciplinas_url) + end + end +end diff --git a/spec/requests/docentes_spec.rb b/spec/requests/docentes_spec.rb new file mode 100644 index 0000000000..568fa565f6 --- /dev/null +++ b/spec/requests/docentes_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/docentes", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Docente. As you add validations to Docente, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Docente.create! valid_attributes + get docentes_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + docente = Docente.create! valid_attributes + get docente_url(docente) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_docente_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + docente = Docente.create! valid_attributes + get edit_docente_url(docente) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Docente" do + expect { + post docentes_url, params: { docente: valid_attributes } + }.to change(Docente, :count).by(1) + end + + it "redirects to the created docente" do + post docentes_url, params: { docente: valid_attributes } + expect(response).to redirect_to(docente_url(Docente.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Docente" do + expect { + post docentes_url, params: { docente: invalid_attributes } + }.to change(Docente, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post docentes_url, params: { docente: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested docente" do + docente = Docente.create! valid_attributes + patch docente_url(docente), params: { docente: new_attributes } + docente.reload + skip("Add assertions for updated state") + end + + it "redirects to the docente" do + docente = Docente.create! valid_attributes + patch docente_url(docente), params: { docente: new_attributes } + docente.reload + expect(response).to redirect_to(docente_url(docente)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + docente = Docente.create! valid_attributes + patch docente_url(docente), params: { docente: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested docente" do + docente = Docente.create! valid_attributes + expect { + delete docente_url(docente) + }.to change(Docente, :count).by(-1) + end + + it "redirects to the docentes list" do + docente = Docente.create! valid_attributes + delete docente_url(docente) + expect(response).to redirect_to(docentes_url) + end + end +end diff --git a/spec/requests/elemento_forms_spec.rb b/spec/requests/elemento_forms_spec.rb new file mode 100644 index 0000000000..f8d3541e4a --- /dev/null +++ b/spec/requests/elemento_forms_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/elemento_forms", type: :request do + + # This should return the minimal set of attributes required to create a valid + # ElementoForm. As you add validations to ElementoForm, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + ElementoForm.create! valid_attributes + get elemento_forms_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + elemento_form = ElementoForm.create! valid_attributes + get elemento_form_url(elemento_form) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_elemento_form_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + elemento_form = ElementoForm.create! valid_attributes + get edit_elemento_form_url(elemento_form) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new ElementoForm" do + expect { + post elemento_forms_url, params: { elemento_form: valid_attributes } + }.to change(ElementoForm, :count).by(1) + end + + it "redirects to the created elemento_form" do + post elemento_forms_url, params: { elemento_form: valid_attributes } + expect(response).to redirect_to(elemento_form_url(ElementoForm.last)) + end + end + + context "with invalid parameters" do + it "does not create a new ElementoForm" do + expect { + post elemento_forms_url, params: { elemento_form: invalid_attributes } + }.to change(ElementoForm, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post elemento_forms_url, params: { elemento_form: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested elemento_form" do + elemento_form = ElementoForm.create! valid_attributes + patch elemento_form_url(elemento_form), params: { elemento_form: new_attributes } + elemento_form.reload + skip("Add assertions for updated state") + end + + it "redirects to the elemento_form" do + elemento_form = ElementoForm.create! valid_attributes + patch elemento_form_url(elemento_form), params: { elemento_form: new_attributes } + elemento_form.reload + expect(response).to redirect_to(elemento_form_url(elemento_form)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + elemento_form = ElementoForm.create! valid_attributes + patch elemento_form_url(elemento_form), params: { elemento_form: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested elemento_form" do + elemento_form = ElementoForm.create! valid_attributes + expect { + delete elemento_form_url(elemento_form) + }.to change(ElementoForm, :count).by(-1) + end + + it "redirects to the elemento_forms list" do + elemento_form = ElementoForm.create! valid_attributes + delete elemento_form_url(elemento_form) + expect(response).to redirect_to(elemento_forms_url) + end + end +end diff --git a/spec/requests/elementos_spec.rb b/spec/requests/elementos_spec.rb new file mode 100644 index 0000000000..ee5a0a13dc --- /dev/null +++ b/spec/requests/elementos_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/elementos", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Elemento. As you add validations to Elemento, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Elemento.create! valid_attributes + get elementos_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + elemento = Elemento.create! valid_attributes + get elemento_url(elemento) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_elemento_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + elemento = Elemento.create! valid_attributes + get edit_elemento_url(elemento) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Elemento" do + expect { + post elementos_url, params: { elemento: valid_attributes } + }.to change(Elemento, :count).by(1) + end + + it "redirects to the created elemento" do + post elementos_url, params: { elemento: valid_attributes } + expect(response).to redirect_to(elemento_url(Elemento.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Elemento" do + expect { + post elementos_url, params: { elemento: invalid_attributes } + }.to change(Elemento, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post elementos_url, params: { elemento: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested elemento" do + elemento = Elemento.create! valid_attributes + patch elemento_url(elemento), params: { elemento: new_attributes } + elemento.reload + skip("Add assertions for updated state") + end + + it "redirects to the elemento" do + elemento = Elemento.create! valid_attributes + patch elemento_url(elemento), params: { elemento: new_attributes } + elemento.reload + expect(response).to redirect_to(elemento_url(elemento)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + elemento = Elemento.create! valid_attributes + patch elemento_url(elemento), params: { elemento: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested elemento" do + elemento = Elemento.create! valid_attributes + expect { + delete elemento_url(elemento) + }.to change(Elemento, :count).by(-1) + end + + it "redirects to the elementos list" do + elemento = Elemento.create! valid_attributes + delete elemento_url(elemento) + expect(response).to redirect_to(elementos_url) + end + end +end diff --git a/spec/requests/formularios_spec.rb b/spec/requests/formularios_spec.rb new file mode 100644 index 0000000000..7c7db4ab28 --- /dev/null +++ b/spec/requests/formularios_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/formularios", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Formulario. As you add validations to Formulario, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Formulario.create! valid_attributes + get formularios_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + formulario = Formulario.create! valid_attributes + get formulario_url(formulario) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_formulario_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + formulario = Formulario.create! valid_attributes + get edit_formulario_url(formulario) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Formulario" do + expect { + post formularios_url, params: { formulario: valid_attributes } + }.to change(Formulario, :count).by(1) + end + + it "redirects to the created formulario" do + post formularios_url, params: { formulario: valid_attributes } + expect(response).to redirect_to(formulario_url(Formulario.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Formulario" do + expect { + post formularios_url, params: { formulario: invalid_attributes } + }.to change(Formulario, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post formularios_url, params: { formulario: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested formulario" do + formulario = Formulario.create! valid_attributes + patch formulario_url(formulario), params: { formulario: new_attributes } + formulario.reload + skip("Add assertions for updated state") + end + + it "redirects to the formulario" do + formulario = Formulario.create! valid_attributes + patch formulario_url(formulario), params: { formulario: new_attributes } + formulario.reload + expect(response).to redirect_to(formulario_url(formulario)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + formulario = Formulario.create! valid_attributes + patch formulario_url(formulario), params: { formulario: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested formulario" do + formulario = Formulario.create! valid_attributes + expect { + delete formulario_url(formulario) + }.to change(Formulario, :count).by(-1) + end + + it "redirects to the formularios list" do + formulario = Formulario.create! valid_attributes + delete formulario_url(formulario) + expect(response).to redirect_to(formularios_url) + end + end +end diff --git a/spec/requests/resposta_elems_spec.rb b/spec/requests/resposta_elems_spec.rb new file mode 100644 index 0000000000..839d8680ce --- /dev/null +++ b/spec/requests/resposta_elems_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/resposta_elems", type: :request do + + # This should return the minimal set of attributes required to create a valid + # RespostaElem. As you add validations to RespostaElem, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + RespostaElem.create! valid_attributes + get resposta_elems_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + resposta_elem = RespostaElem.create! valid_attributes + get resposta_elem_url(resposta_elem) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_resposta_elem_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + resposta_elem = RespostaElem.create! valid_attributes + get edit_resposta_elem_url(resposta_elem) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new RespostaElem" do + expect { + post resposta_elems_url, params: { resposta_elem: valid_attributes } + }.to change(RespostaElem, :count).by(1) + end + + it "redirects to the created resposta_elem" do + post resposta_elems_url, params: { resposta_elem: valid_attributes } + expect(response).to redirect_to(resposta_elem_url(RespostaElem.last)) + end + end + + context "with invalid parameters" do + it "does not create a new RespostaElem" do + expect { + post resposta_elems_url, params: { resposta_elem: invalid_attributes } + }.to change(RespostaElem, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post resposta_elems_url, params: { resposta_elem: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested resposta_elem" do + resposta_elem = RespostaElem.create! valid_attributes + patch resposta_elem_url(resposta_elem), params: { resposta_elem: new_attributes } + resposta_elem.reload + skip("Add assertions for updated state") + end + + it "redirects to the resposta_elem" do + resposta_elem = RespostaElem.create! valid_attributes + patch resposta_elem_url(resposta_elem), params: { resposta_elem: new_attributes } + resposta_elem.reload + expect(response).to redirect_to(resposta_elem_url(resposta_elem)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + resposta_elem = RespostaElem.create! valid_attributes + patch resposta_elem_url(resposta_elem), params: { resposta_elem: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested resposta_elem" do + resposta_elem = RespostaElem.create! valid_attributes + expect { + delete resposta_elem_url(resposta_elem) + }.to change(RespostaElem, :count).by(-1) + end + + it "redirects to the resposta_elems list" do + resposta_elem = RespostaElem.create! valid_attributes + delete resposta_elem_url(resposta_elem) + expect(response).to redirect_to(resposta_elems_url) + end + end +end diff --git a/spec/requests/resposta_forms_spec.rb b/spec/requests/resposta_forms_spec.rb new file mode 100644 index 0000000000..9f35a868f2 --- /dev/null +++ b/spec/requests/resposta_forms_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/resposta_forms", type: :request do + + # This should return the minimal set of attributes required to create a valid + # RespostaForm. As you add validations to RespostaForm, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + RespostaForm.create! valid_attributes + get resposta_forms_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + resposta_form = RespostaForm.create! valid_attributes + get resposta_form_url(resposta_form) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_resposta_form_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + resposta_form = RespostaForm.create! valid_attributes + get edit_resposta_form_url(resposta_form) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new RespostaForm" do + expect { + post resposta_forms_url, params: { resposta_form: valid_attributes } + }.to change(RespostaForm, :count).by(1) + end + + it "redirects to the created resposta_form" do + post resposta_forms_url, params: { resposta_form: valid_attributes } + expect(response).to redirect_to(resposta_form_url(RespostaForm.last)) + end + end + + context "with invalid parameters" do + it "does not create a new RespostaForm" do + expect { + post resposta_forms_url, params: { resposta_form: invalid_attributes } + }.to change(RespostaForm, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post resposta_forms_url, params: { resposta_form: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested resposta_form" do + resposta_form = RespostaForm.create! valid_attributes + patch resposta_form_url(resposta_form), params: { resposta_form: new_attributes } + resposta_form.reload + skip("Add assertions for updated state") + end + + it "redirects to the resposta_form" do + resposta_form = RespostaForm.create! valid_attributes + patch resposta_form_url(resposta_form), params: { resposta_form: new_attributes } + resposta_form.reload + expect(response).to redirect_to(resposta_form_url(resposta_form)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + resposta_form = RespostaForm.create! valid_attributes + patch resposta_form_url(resposta_form), params: { resposta_form: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested resposta_form" do + resposta_form = RespostaForm.create! valid_attributes + expect { + delete resposta_form_url(resposta_form) + }.to change(RespostaForm, :count).by(-1) + end + + it "redirects to the resposta_forms list" do + resposta_form = RespostaForm.create! valid_attributes + delete resposta_form_url(resposta_form) + expect(response).to redirect_to(resposta_forms_url) + end + end +end diff --git a/spec/requests/templates_spec.rb b/spec/requests/templates_spec.rb new file mode 100644 index 0000000000..f5401cd1fd --- /dev/null +++ b/spec/requests/templates_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/templates", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Template. As you add validations to Template, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Template.create! valid_attributes + get templates_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + template = Template.create! valid_attributes + get template_url(template) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_template_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + template = Template.create! valid_attributes + get edit_template_url(template) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Template" do + expect { + post templates_url, params: { template: valid_attributes } + }.to change(Template, :count).by(1) + end + + it "redirects to the created template" do + post templates_url, params: { template: valid_attributes } + expect(response).to redirect_to(template_url(Template.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Template" do + expect { + post templates_url, params: { template: invalid_attributes } + }.to change(Template, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post templates_url, params: { template: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested template" do + template = Template.create! valid_attributes + patch template_url(template), params: { template: new_attributes } + template.reload + skip("Add assertions for updated state") + end + + it "redirects to the template" do + template = Template.create! valid_attributes + patch template_url(template), params: { template: new_attributes } + template.reload + expect(response).to redirect_to(template_url(template)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + template = Template.create! valid_attributes + patch template_url(template), params: { template: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested template" do + template = Template.create! valid_attributes + expect { + delete template_url(template) + }.to change(Template, :count).by(-1) + end + + it "redirects to the templates list" do + template = Template.create! valid_attributes + delete template_url(template) + expect(response).to redirect_to(templates_url) + end + end +end diff --git a/spec/requests/turmas_spec.rb b/spec/requests/turmas_spec.rb new file mode 100644 index 0000000000..c86cc681fc --- /dev/null +++ b/spec/requests/turmas_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/turmas", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Turma. As you add validations to Turma, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Turma.create! valid_attributes + get turmas_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + turma = Turma.create! valid_attributes + get turma_url(turma) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_turma_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + turma = Turma.create! valid_attributes + get edit_turma_url(turma) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Turma" do + expect { + post turmas_url, params: { turma: valid_attributes } + }.to change(Turma, :count).by(1) + end + + it "redirects to the created turma" do + post turmas_url, params: { turma: valid_attributes } + expect(response).to redirect_to(turma_url(Turma.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Turma" do + expect { + post turmas_url, params: { turma: invalid_attributes } + }.to change(Turma, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post turmas_url, params: { turma: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested turma" do + turma = Turma.create! valid_attributes + patch turma_url(turma), params: { turma: new_attributes } + turma.reload + skip("Add assertions for updated state") + end + + it "redirects to the turma" do + turma = Turma.create! valid_attributes + patch turma_url(turma), params: { turma: new_attributes } + turma.reload + expect(response).to redirect_to(turma_url(turma)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + turma = Turma.create! valid_attributes + patch turma_url(turma), params: { turma: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested turma" do + turma = Turma.create! valid_attributes + expect { + delete turma_url(turma) + }.to change(Turma, :count).by(-1) + end + + it "redirects to the turmas list" do + turma = Turma.create! valid_attributes + delete turma_url(turma) + expect(response).to redirect_to(turmas_url) + end + end +end diff --git a/spec/requests/usuarios_spec.rb b/spec/requests/usuarios_spec.rb new file mode 100644 index 0000000000..4f9aabef93 --- /dev/null +++ b/spec/requests/usuarios_spec.rb @@ -0,0 +1,131 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to test the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. + +RSpec.describe "/usuarios", type: :request do + + # This should return the minimal set of attributes required to create a valid + # Usuario. As you add validations to Usuario, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + skip("Add a hash of attributes valid for your model") + } + + let(:invalid_attributes) { + skip("Add a hash of attributes invalid for your model") + } + + describe "GET /index" do + it "renders a successful response" do + Usuario.create! valid_attributes + get usuarios_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + usuario = Usuario.create! valid_attributes + get usuario_url(usuario) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_usuario_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "renders a successful response" do + usuario = Usuario.create! valid_attributes + get edit_usuario_url(usuario) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Usuario" do + expect { + post usuarios_url, params: { usuario: valid_attributes } + }.to change(Usuario, :count).by(1) + end + + it "redirects to the created usuario" do + post usuarios_url, params: { usuario: valid_attributes } + expect(response).to redirect_to(usuario_url(Usuario.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Usuario" do + expect { + post usuarios_url, params: { usuario: invalid_attributes } + }.to change(Usuario, :count).by(0) + end + + it "renders a response with 422 status (i.e. to display the 'new' template)" do + post usuarios_url, params: { usuario: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "PATCH /update" do + context "with valid parameters" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested usuario" do + usuario = Usuario.create! valid_attributes + patch usuario_url(usuario), params: { usuario: new_attributes } + usuario.reload + skip("Add assertions for updated state") + end + + it "redirects to the usuario" do + usuario = Usuario.create! valid_attributes + patch usuario_url(usuario), params: { usuario: new_attributes } + usuario.reload + expect(response).to redirect_to(usuario_url(usuario)) + end + end + + context "with invalid parameters" do + it "renders a response with 422 status (i.e. to display the 'edit' template)" do + usuario = Usuario.create! valid_attributes + patch usuario_url(usuario), params: { usuario: invalid_attributes } + expect(response).to have_http_status(:unprocessable_content) + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested usuario" do + usuario = Usuario.create! valid_attributes + expect { + delete usuario_url(usuario) + }.to change(Usuario, :count).by(-1) + end + + it "redirects to the usuarios list" do + usuario = Usuario.create! valid_attributes + delete usuario_url(usuario) + expect(response).to redirect_to(usuarios_url) + end + end +end diff --git a/spec/routing/campo_forms_routing_spec.rb b/spec/routing/campo_forms_routing_spec.rb new file mode 100644 index 0000000000..d9ba61251e --- /dev/null +++ b/spec/routing/campo_forms_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe CampoFormsController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/campo_forms").to route_to("campo_forms#index") + end + + it "routes to #new" do + expect(get: "/campo_forms/new").to route_to("campo_forms#new") + end + + it "routes to #show" do + expect(get: "/campo_forms/1").to route_to("campo_forms#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/campo_forms/1/edit").to route_to("campo_forms#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/campo_forms").to route_to("campo_forms#create") + end + + it "routes to #update via PUT" do + expect(put: "/campo_forms/1").to route_to("campo_forms#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/campo_forms/1").to route_to("campo_forms#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/campo_forms/1").to route_to("campo_forms#destroy", id: "1") + end + end +end diff --git a/spec/routing/campos_routing_spec.rb b/spec/routing/campos_routing_spec.rb new file mode 100644 index 0000000000..810f809b63 --- /dev/null +++ b/spec/routing/campos_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe CamposController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/campos").to route_to("campos#index") + end + + it "routes to #new" do + expect(get: "/campos/new").to route_to("campos#new") + end + + it "routes to #show" do + expect(get: "/campos/1").to route_to("campos#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/campos/1/edit").to route_to("campos#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/campos").to route_to("campos#create") + end + + it "routes to #update via PUT" do + expect(put: "/campos/1").to route_to("campos#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/campos/1").to route_to("campos#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/campos/1").to route_to("campos#destroy", id: "1") + end + end +end diff --git a/spec/routing/cursos_routing_spec.rb b/spec/routing/cursos_routing_spec.rb new file mode 100644 index 0000000000..dfebdeafe5 --- /dev/null +++ b/spec/routing/cursos_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe CursosController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/cursos").to route_to("cursos#index") + end + + it "routes to #new" do + expect(get: "/cursos/new").to route_to("cursos#new") + end + + it "routes to #show" do + expect(get: "/cursos/1").to route_to("cursos#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/cursos/1/edit").to route_to("cursos#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/cursos").to route_to("cursos#create") + end + + it "routes to #update via PUT" do + expect(put: "/cursos/1").to route_to("cursos#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/cursos/1").to route_to("cursos#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/cursos/1").to route_to("cursos#destroy", id: "1") + end + end +end diff --git a/spec/routing/departamentos_routing_spec.rb b/spec/routing/departamentos_routing_spec.rb new file mode 100644 index 0000000000..2535d28303 --- /dev/null +++ b/spec/routing/departamentos_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe DepartamentosController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/departamentos").to route_to("departamentos#index") + end + + it "routes to #new" do + expect(get: "/departamentos/new").to route_to("departamentos#new") + end + + it "routes to #show" do + expect(get: "/departamentos/1").to route_to("departamentos#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/departamentos/1/edit").to route_to("departamentos#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/departamentos").to route_to("departamentos#create") + end + + it "routes to #update via PUT" do + expect(put: "/departamentos/1").to route_to("departamentos#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/departamentos/1").to route_to("departamentos#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/departamentos/1").to route_to("departamentos#destroy", id: "1") + end + end +end diff --git a/spec/routing/discentes_routing_spec.rb b/spec/routing/discentes_routing_spec.rb new file mode 100644 index 0000000000..4c39bdec04 --- /dev/null +++ b/spec/routing/discentes_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe DiscentesController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/discentes").to route_to("discentes#index") + end + + it "routes to #new" do + expect(get: "/discentes/new").to route_to("discentes#new") + end + + it "routes to #show" do + expect(get: "/discentes/1").to route_to("discentes#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/discentes/1/edit").to route_to("discentes#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/discentes").to route_to("discentes#create") + end + + it "routes to #update via PUT" do + expect(put: "/discentes/1").to route_to("discentes#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/discentes/1").to route_to("discentes#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/discentes/1").to route_to("discentes#destroy", id: "1") + end + end +end diff --git a/spec/routing/disciplinas_routing_spec.rb b/spec/routing/disciplinas_routing_spec.rb new file mode 100644 index 0000000000..83819acd29 --- /dev/null +++ b/spec/routing/disciplinas_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe DisciplinasController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/disciplinas").to route_to("disciplinas#index") + end + + it "routes to #new" do + expect(get: "/disciplinas/new").to route_to("disciplinas#new") + end + + it "routes to #show" do + expect(get: "/disciplinas/1").to route_to("disciplinas#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/disciplinas/1/edit").to route_to("disciplinas#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/disciplinas").to route_to("disciplinas#create") + end + + it "routes to #update via PUT" do + expect(put: "/disciplinas/1").to route_to("disciplinas#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/disciplinas/1").to route_to("disciplinas#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/disciplinas/1").to route_to("disciplinas#destroy", id: "1") + end + end +end diff --git a/spec/routing/docentes_routing_spec.rb b/spec/routing/docentes_routing_spec.rb new file mode 100644 index 0000000000..552d560638 --- /dev/null +++ b/spec/routing/docentes_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe DocentesController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/docentes").to route_to("docentes#index") + end + + it "routes to #new" do + expect(get: "/docentes/new").to route_to("docentes#new") + end + + it "routes to #show" do + expect(get: "/docentes/1").to route_to("docentes#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/docentes/1/edit").to route_to("docentes#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/docentes").to route_to("docentes#create") + end + + it "routes to #update via PUT" do + expect(put: "/docentes/1").to route_to("docentes#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/docentes/1").to route_to("docentes#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/docentes/1").to route_to("docentes#destroy", id: "1") + end + end +end diff --git a/spec/routing/elemento_forms_routing_spec.rb b/spec/routing/elemento_forms_routing_spec.rb new file mode 100644 index 0000000000..3884645ada --- /dev/null +++ b/spec/routing/elemento_forms_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe ElementoFormsController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/elemento_forms").to route_to("elemento_forms#index") + end + + it "routes to #new" do + expect(get: "/elemento_forms/new").to route_to("elemento_forms#new") + end + + it "routes to #show" do + expect(get: "/elemento_forms/1").to route_to("elemento_forms#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/elemento_forms/1/edit").to route_to("elemento_forms#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/elemento_forms").to route_to("elemento_forms#create") + end + + it "routes to #update via PUT" do + expect(put: "/elemento_forms/1").to route_to("elemento_forms#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/elemento_forms/1").to route_to("elemento_forms#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/elemento_forms/1").to route_to("elemento_forms#destroy", id: "1") + end + end +end diff --git a/spec/routing/elementos_routing_spec.rb b/spec/routing/elementos_routing_spec.rb new file mode 100644 index 0000000000..18736f399b --- /dev/null +++ b/spec/routing/elementos_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe ElementosController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/elementos").to route_to("elementos#index") + end + + it "routes to #new" do + expect(get: "/elementos/new").to route_to("elementos#new") + end + + it "routes to #show" do + expect(get: "/elementos/1").to route_to("elementos#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/elementos/1/edit").to route_to("elementos#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/elementos").to route_to("elementos#create") + end + + it "routes to #update via PUT" do + expect(put: "/elementos/1").to route_to("elementos#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/elementos/1").to route_to("elementos#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/elementos/1").to route_to("elementos#destroy", id: "1") + end + end +end diff --git a/spec/routing/formularios_routing_spec.rb b/spec/routing/formularios_routing_spec.rb new file mode 100644 index 0000000000..e097ff7208 --- /dev/null +++ b/spec/routing/formularios_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe FormulariosController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/formularios").to route_to("formularios#index") + end + + it "routes to #new" do + expect(get: "/formularios/new").to route_to("formularios#new") + end + + it "routes to #show" do + expect(get: "/formularios/1").to route_to("formularios#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/formularios/1/edit").to route_to("formularios#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/formularios").to route_to("formularios#create") + end + + it "routes to #update via PUT" do + expect(put: "/formularios/1").to route_to("formularios#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/formularios/1").to route_to("formularios#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/formularios/1").to route_to("formularios#destroy", id: "1") + end + end +end diff --git a/spec/routing/resposta_elems_routing_spec.rb b/spec/routing/resposta_elems_routing_spec.rb new file mode 100644 index 0000000000..484e0f9c5c --- /dev/null +++ b/spec/routing/resposta_elems_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe RespostaElemsController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/resposta_elems").to route_to("resposta_elems#index") + end + + it "routes to #new" do + expect(get: "/resposta_elems/new").to route_to("resposta_elems#new") + end + + it "routes to #show" do + expect(get: "/resposta_elems/1").to route_to("resposta_elems#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/resposta_elems/1/edit").to route_to("resposta_elems#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/resposta_elems").to route_to("resposta_elems#create") + end + + it "routes to #update via PUT" do + expect(put: "/resposta_elems/1").to route_to("resposta_elems#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/resposta_elems/1").to route_to("resposta_elems#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/resposta_elems/1").to route_to("resposta_elems#destroy", id: "1") + end + end +end diff --git a/spec/routing/resposta_forms_routing_spec.rb b/spec/routing/resposta_forms_routing_spec.rb new file mode 100644 index 0000000000..e9631021d7 --- /dev/null +++ b/spec/routing/resposta_forms_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe RespostaFormsController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/resposta_forms").to route_to("resposta_forms#index") + end + + it "routes to #new" do + expect(get: "/resposta_forms/new").to route_to("resposta_forms#new") + end + + it "routes to #show" do + expect(get: "/resposta_forms/1").to route_to("resposta_forms#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/resposta_forms/1/edit").to route_to("resposta_forms#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/resposta_forms").to route_to("resposta_forms#create") + end + + it "routes to #update via PUT" do + expect(put: "/resposta_forms/1").to route_to("resposta_forms#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/resposta_forms/1").to route_to("resposta_forms#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/resposta_forms/1").to route_to("resposta_forms#destroy", id: "1") + end + end +end diff --git a/spec/routing/templates_routing_spec.rb b/spec/routing/templates_routing_spec.rb new file mode 100644 index 0000000000..b4097ab2ec --- /dev/null +++ b/spec/routing/templates_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe TemplatesController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/templates").to route_to("templates#index") + end + + it "routes to #new" do + expect(get: "/templates/new").to route_to("templates#new") + end + + it "routes to #show" do + expect(get: "/templates/1").to route_to("templates#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/templates/1/edit").to route_to("templates#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/templates").to route_to("templates#create") + end + + it "routes to #update via PUT" do + expect(put: "/templates/1").to route_to("templates#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/templates/1").to route_to("templates#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/templates/1").to route_to("templates#destroy", id: "1") + end + end +end diff --git a/spec/routing/turmas_routing_spec.rb b/spec/routing/turmas_routing_spec.rb new file mode 100644 index 0000000000..02948b90ab --- /dev/null +++ b/spec/routing/turmas_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe TurmasController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/turmas").to route_to("turmas#index") + end + + it "routes to #new" do + expect(get: "/turmas/new").to route_to("turmas#new") + end + + it "routes to #show" do + expect(get: "/turmas/1").to route_to("turmas#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/turmas/1/edit").to route_to("turmas#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/turmas").to route_to("turmas#create") + end + + it "routes to #update via PUT" do + expect(put: "/turmas/1").to route_to("turmas#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/turmas/1").to route_to("turmas#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/turmas/1").to route_to("turmas#destroy", id: "1") + end + end +end diff --git a/spec/routing/usuarios_routing_spec.rb b/spec/routing/usuarios_routing_spec.rb new file mode 100644 index 0000000000..93560e3542 --- /dev/null +++ b/spec/routing/usuarios_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe UsuariosController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/usuarios").to route_to("usuarios#index") + end + + it "routes to #new" do + expect(get: "/usuarios/new").to route_to("usuarios#new") + end + + it "routes to #show" do + expect(get: "/usuarios/1").to route_to("usuarios#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/usuarios/1/edit").to route_to("usuarios#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/usuarios").to route_to("usuarios#create") + end + + it "routes to #update via PUT" do + expect(put: "/usuarios/1").to route_to("usuarios#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/usuarios/1").to route_to("usuarios#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/usuarios/1").to route_to("usuarios#destroy", id: "1") + end + end +end diff --git a/spec/views/campo_forms/edit.html.erb_spec.rb b/spec/views/campo_forms/edit.html.erb_spec.rb new file mode 100644 index 0000000000..f5eb4f1a89 --- /dev/null +++ b/spec/views/campo_forms/edit.html.erb_spec.rb @@ -0,0 +1,28 @@ +require 'rails_helper' + +RSpec.describe "campo_forms/edit", type: :view do + let(:campo_form) { + CampoForm.create!( + ordem: 1, + enunciado: "MyString", + elemento_form: nil + ) + } + + before(:each) do + assign(:campo_form, campo_form) + end + + it "renders the edit campo_form form" do + render + + assert_select "form[action=?][method=?]", campo_form_path(campo_form), "post" do + + assert_select "input[name=?]", "campo_form[ordem]" + + assert_select "input[name=?]", "campo_form[enunciado]" + + assert_select "input[name=?]", "campo_form[elemento_form_id]" + end + end +end diff --git a/spec/views/campo_forms/index.html.erb_spec.rb b/spec/views/campo_forms/index.html.erb_spec.rb new file mode 100644 index 0000000000..15106f323f --- /dev/null +++ b/spec/views/campo_forms/index.html.erb_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +RSpec.describe "campo_forms/index", type: :view do + before(:each) do + assign(:campo_forms, [ + CampoForm.create!( + ordem: 2, + enunciado: "Enunciado", + elemento_form: nil + ), + CampoForm.create!( + ordem: 2, + enunciado: "Enunciado", + elemento_form: nil + ) + ]) + end + + it "renders a list of campo_forms" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new(2.to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Enunciado".to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/campo_forms/new.html.erb_spec.rb b/spec/views/campo_forms/new.html.erb_spec.rb new file mode 100644 index 0000000000..ce55db9ba5 --- /dev/null +++ b/spec/views/campo_forms/new.html.erb_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe "campo_forms/new", type: :view do + before(:each) do + assign(:campo_form, CampoForm.new( + ordem: 1, + enunciado: "MyString", + elemento_form: nil + )) + end + + it "renders new campo_form form" do + render + + assert_select "form[action=?][method=?]", campo_forms_path, "post" do + + assert_select "input[name=?]", "campo_form[ordem]" + + assert_select "input[name=?]", "campo_form[enunciado]" + + assert_select "input[name=?]", "campo_form[elemento_form_id]" + end + end +end diff --git a/spec/views/campo_forms/show.html.erb_spec.rb b/spec/views/campo_forms/show.html.erb_spec.rb new file mode 100644 index 0000000000..fa8c4b8bbc --- /dev/null +++ b/spec/views/campo_forms/show.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "campo_forms/show", type: :view do + before(:each) do + assign(:campo_form, CampoForm.create!( + ordem: 2, + enunciado: "Enunciado", + elemento_form: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/2/) + expect(rendered).to match(/Enunciado/) + expect(rendered).to match(//) + end +end diff --git a/spec/views/campos/edit.html.erb_spec.rb b/spec/views/campos/edit.html.erb_spec.rb new file mode 100644 index 0000000000..4d41e61ea8 --- /dev/null +++ b/spec/views/campos/edit.html.erb_spec.rb @@ -0,0 +1,31 @@ +require 'rails_helper' + +RSpec.describe "campos/edit", type: :view do + let(:campo) { + Campo.create!( + ordem: 1, + enunciado: "MyString", + tipo_elemento: "MyString", + elemento: nil + ) + } + + before(:each) do + assign(:campo, campo) + end + + it "renders the edit campo form" do + render + + assert_select "form[action=?][method=?]", campo_path(campo), "post" do + + assert_select "input[name=?]", "campo[ordem]" + + assert_select "input[name=?]", "campo[enunciado]" + + assert_select "input[name=?]", "campo[tipo_elemento]" + + assert_select "input[name=?]", "campo[elemento_id]" + end + end +end diff --git a/spec/views/campos/index.html.erb_spec.rb b/spec/views/campos/index.html.erb_spec.rb new file mode 100644 index 0000000000..049bf5f10a --- /dev/null +++ b/spec/views/campos/index.html.erb_spec.rb @@ -0,0 +1,29 @@ +require 'rails_helper' + +RSpec.describe "campos/index", type: :view do + before(:each) do + assign(:campos, [ + Campo.create!( + ordem: 2, + enunciado: "Enunciado", + tipo_elemento: "Tipo Elemento", + elemento: nil + ), + Campo.create!( + ordem: 2, + enunciado: "Enunciado", + tipo_elemento: "Tipo Elemento", + elemento: nil + ) + ]) + end + + it "renders a list of campos" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new(2.to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Enunciado".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Tipo Elemento".to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/campos/new.html.erb_spec.rb b/spec/views/campos/new.html.erb_spec.rb new file mode 100644 index 0000000000..ed753d8787 --- /dev/null +++ b/spec/views/campos/new.html.erb_spec.rb @@ -0,0 +1,27 @@ +require 'rails_helper' + +RSpec.describe "campos/new", type: :view do + before(:each) do + assign(:campo, Campo.new( + ordem: 1, + enunciado: "MyString", + tipo_elemento: "MyString", + elemento: nil + )) + end + + it "renders new campo form" do + render + + assert_select "form[action=?][method=?]", campos_path, "post" do + + assert_select "input[name=?]", "campo[ordem]" + + assert_select "input[name=?]", "campo[enunciado]" + + assert_select "input[name=?]", "campo[tipo_elemento]" + + assert_select "input[name=?]", "campo[elemento_id]" + end + end +end diff --git a/spec/views/campos/show.html.erb_spec.rb b/spec/views/campos/show.html.erb_spec.rb new file mode 100644 index 0000000000..13b5a5a9a9 --- /dev/null +++ b/spec/views/campos/show.html.erb_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe "campos/show", type: :view do + before(:each) do + assign(:campo, Campo.create!( + ordem: 2, + enunciado: "Enunciado", + tipo_elemento: "Tipo Elemento", + elemento: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/2/) + expect(rendered).to match(/Enunciado/) + expect(rendered).to match(/Tipo Elemento/) + expect(rendered).to match(//) + end +end diff --git a/spec/views/cursos/edit.html.erb_spec.rb b/spec/views/cursos/edit.html.erb_spec.rb new file mode 100644 index 0000000000..b20d018e98 --- /dev/null +++ b/spec/views/cursos/edit.html.erb_spec.rb @@ -0,0 +1,28 @@ +require 'rails_helper' + +RSpec.describe "cursos/edit", type: :view do + let(:curso) { + Curso.create!( + codigo: "MyString", + nome: "MyString", + departamento: nil + ) + } + + before(:each) do + assign(:curso, curso) + end + + it "renders the edit curso form" do + render + + assert_select "form[action=?][method=?]", curso_path(curso), "post" do + + assert_select "input[name=?]", "curso[codigo]" + + assert_select "input[name=?]", "curso[nome]" + + assert_select "input[name=?]", "curso[departamento_id]" + end + end +end diff --git a/spec/views/cursos/index.html.erb_spec.rb b/spec/views/cursos/index.html.erb_spec.rb new file mode 100644 index 0000000000..c61ac472ee --- /dev/null +++ b/spec/views/cursos/index.html.erb_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +RSpec.describe "cursos/index", type: :view do + before(:each) do + assign(:cursos, [ + Curso.create!( + codigo: "Codigo", + nome: "Nome", + departamento: nil + ), + Curso.create!( + codigo: "Codigo", + nome: "Nome", + departamento: nil + ) + ]) + end + + it "renders a list of cursos" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new("Codigo".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/cursos/new.html.erb_spec.rb b/spec/views/cursos/new.html.erb_spec.rb new file mode 100644 index 0000000000..61507c55a0 --- /dev/null +++ b/spec/views/cursos/new.html.erb_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe "cursos/new", type: :view do + before(:each) do + assign(:curso, Curso.new( + codigo: "MyString", + nome: "MyString", + departamento: nil + )) + end + + it "renders new curso form" do + render + + assert_select "form[action=?][method=?]", cursos_path, "post" do + + assert_select "input[name=?]", "curso[codigo]" + + assert_select "input[name=?]", "curso[nome]" + + assert_select "input[name=?]", "curso[departamento_id]" + end + end +end diff --git a/spec/views/cursos/show.html.erb_spec.rb b/spec/views/cursos/show.html.erb_spec.rb new file mode 100644 index 0000000000..a96f7138e1 --- /dev/null +++ b/spec/views/cursos/show.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "cursos/show", type: :view do + before(:each) do + assign(:curso, Curso.create!( + codigo: "Codigo", + nome: "Nome", + departamento: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Codigo/) + expect(rendered).to match(/Nome/) + expect(rendered).to match(//) + end +end diff --git a/spec/views/departamentos/edit.html.erb_spec.rb b/spec/views/departamentos/edit.html.erb_spec.rb new file mode 100644 index 0000000000..c043a47855 --- /dev/null +++ b/spec/views/departamentos/edit.html.erb_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +RSpec.describe "departamentos/edit", type: :view do + let(:departamento) { + Departamento.create!( + codigo: "MyString", + nome: "MyString" + ) + } + + before(:each) do + assign(:departamento, departamento) + end + + it "renders the edit departamento form" do + render + + assert_select "form[action=?][method=?]", departamento_path(departamento), "post" do + + assert_select "input[name=?]", "departamento[codigo]" + + assert_select "input[name=?]", "departamento[nome]" + end + end +end diff --git a/spec/views/departamentos/index.html.erb_spec.rb b/spec/views/departamentos/index.html.erb_spec.rb new file mode 100644 index 0000000000..d7dae7c4b6 --- /dev/null +++ b/spec/views/departamentos/index.html.erb_spec.rb @@ -0,0 +1,23 @@ +require 'rails_helper' + +RSpec.describe "departamentos/index", type: :view do + before(:each) do + assign(:departamentos, [ + Departamento.create!( + codigo: "Codigo", + nome: "Nome" + ), + Departamento.create!( + codigo: "Codigo", + nome: "Nome" + ) + ]) + end + + it "renders a list of departamentos" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new("Codigo".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 + end +end diff --git a/spec/views/departamentos/new.html.erb_spec.rb b/spec/views/departamentos/new.html.erb_spec.rb new file mode 100644 index 0000000000..72750b9386 --- /dev/null +++ b/spec/views/departamentos/new.html.erb_spec.rb @@ -0,0 +1,21 @@ +require 'rails_helper' + +RSpec.describe "departamentos/new", type: :view do + before(:each) do + assign(:departamento, Departamento.new( + codigo: "MyString", + nome: "MyString" + )) + end + + it "renders new departamento form" do + render + + assert_select "form[action=?][method=?]", departamentos_path, "post" do + + assert_select "input[name=?]", "departamento[codigo]" + + assert_select "input[name=?]", "departamento[nome]" + end + end +end diff --git a/spec/views/departamentos/show.html.erb_spec.rb b/spec/views/departamentos/show.html.erb_spec.rb new file mode 100644 index 0000000000..b861f35e57 --- /dev/null +++ b/spec/views/departamentos/show.html.erb_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +RSpec.describe "departamentos/show", type: :view do + before(:each) do + assign(:departamento, Departamento.create!( + codigo: "Codigo", + nome: "Nome" + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Codigo/) + expect(rendered).to match(/Nome/) + end +end diff --git a/spec/views/discentes/edit.html.erb_spec.rb b/spec/views/discentes/edit.html.erb_spec.rb new file mode 100644 index 0000000000..6036522f78 --- /dev/null +++ b/spec/views/discentes/edit.html.erb_spec.rb @@ -0,0 +1,34 @@ +require 'rails_helper' + +RSpec.describe "discentes/edit", type: :view do + let(:discente) { + Discente.create!( + matricula: "MyString", + email: "MyString", + nome: "MyString", + formacao: "MyString", + curso: nil + ) + } + + before(:each) do + assign(:discente, discente) + end + + it "renders the edit discente form" do + render + + assert_select "form[action=?][method=?]", discente_path(discente), "post" do + + assert_select "input[name=?]", "discente[matricula]" + + assert_select "input[name=?]", "discente[email]" + + assert_select "input[name=?]", "discente[nome]" + + assert_select "input[name=?]", "discente[formacao]" + + assert_select "input[name=?]", "discente[curso_id]" + end + end +end diff --git a/spec/views/discentes/index.html.erb_spec.rb b/spec/views/discentes/index.html.erb_spec.rb new file mode 100644 index 0000000000..d3e2f67e0b --- /dev/null +++ b/spec/views/discentes/index.html.erb_spec.rb @@ -0,0 +1,32 @@ +require 'rails_helper' + +RSpec.describe "discentes/index", type: :view do + before(:each) do + assign(:discentes, [ + Discente.create!( + matricula: "Matricula", + email: "Email", + nome: "Nome", + formacao: "Formacao", + curso: nil + ), + Discente.create!( + matricula: "Matricula", + email: "Email", + nome: "Nome", + formacao: "Formacao", + curso: nil + ) + ]) + end + + it "renders a list of discentes" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new("Matricula".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Email".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Formacao".to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/discentes/new.html.erb_spec.rb b/spec/views/discentes/new.html.erb_spec.rb new file mode 100644 index 0000000000..de51ff61bd --- /dev/null +++ b/spec/views/discentes/new.html.erb_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' + +RSpec.describe "discentes/new", type: :view do + before(:each) do + assign(:discente, Discente.new( + matricula: "MyString", + email: "MyString", + nome: "MyString", + formacao: "MyString", + curso: nil + )) + end + + it "renders new discente form" do + render + + assert_select "form[action=?][method=?]", discentes_path, "post" do + + assert_select "input[name=?]", "discente[matricula]" + + assert_select "input[name=?]", "discente[email]" + + assert_select "input[name=?]", "discente[nome]" + + assert_select "input[name=?]", "discente[formacao]" + + assert_select "input[name=?]", "discente[curso_id]" + end + end +end diff --git a/spec/views/discentes/show.html.erb_spec.rb b/spec/views/discentes/show.html.erb_spec.rb new file mode 100644 index 0000000000..112906e380 --- /dev/null +++ b/spec/views/discentes/show.html.erb_spec.rb @@ -0,0 +1,22 @@ +require 'rails_helper' + +RSpec.describe "discentes/show", type: :view do + before(:each) do + assign(:discente, Discente.create!( + matricula: "Matricula", + email: "Email", + nome: "Nome", + formacao: "Formacao", + curso: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Matricula/) + expect(rendered).to match(/Email/) + expect(rendered).to match(/Nome/) + expect(rendered).to match(/Formacao/) + expect(rendered).to match(//) + end +end diff --git a/spec/views/disciplinas/edit.html.erb_spec.rb b/spec/views/disciplinas/edit.html.erb_spec.rb new file mode 100644 index 0000000000..7e0c14497a --- /dev/null +++ b/spec/views/disciplinas/edit.html.erb_spec.rb @@ -0,0 +1,28 @@ +require 'rails_helper' + +RSpec.describe "disciplinas/edit", type: :view do + let(:disciplina) { + Disciplina.create!( + codigo: "MyString", + nome: "MyString", + departamento: nil + ) + } + + before(:each) do + assign(:disciplina, disciplina) + end + + it "renders the edit disciplina form" do + render + + assert_select "form[action=?][method=?]", disciplina_path(disciplina), "post" do + + assert_select "input[name=?]", "disciplina[codigo]" + + assert_select "input[name=?]", "disciplina[nome]" + + assert_select "input[name=?]", "disciplina[departamento_id]" + end + end +end diff --git a/spec/views/disciplinas/index.html.erb_spec.rb b/spec/views/disciplinas/index.html.erb_spec.rb new file mode 100644 index 0000000000..a0ce132015 --- /dev/null +++ b/spec/views/disciplinas/index.html.erb_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +RSpec.describe "disciplinas/index", type: :view do + before(:each) do + assign(:disciplinas, [ + Disciplina.create!( + codigo: "Codigo", + nome: "Nome", + departamento: nil + ), + Disciplina.create!( + codigo: "Codigo", + nome: "Nome", + departamento: nil + ) + ]) + end + + it "renders a list of disciplinas" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new("Codigo".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/disciplinas/new.html.erb_spec.rb b/spec/views/disciplinas/new.html.erb_spec.rb new file mode 100644 index 0000000000..399d554eb4 --- /dev/null +++ b/spec/views/disciplinas/new.html.erb_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe "disciplinas/new", type: :view do + before(:each) do + assign(:disciplina, Disciplina.new( + codigo: "MyString", + nome: "MyString", + departamento: nil + )) + end + + it "renders new disciplina form" do + render + + assert_select "form[action=?][method=?]", disciplinas_path, "post" do + + assert_select "input[name=?]", "disciplina[codigo]" + + assert_select "input[name=?]", "disciplina[nome]" + + assert_select "input[name=?]", "disciplina[departamento_id]" + end + end +end diff --git a/spec/views/disciplinas/show.html.erb_spec.rb b/spec/views/disciplinas/show.html.erb_spec.rb new file mode 100644 index 0000000000..c454aa05fe --- /dev/null +++ b/spec/views/disciplinas/show.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "disciplinas/show", type: :view do + before(:each) do + assign(:disciplina, Disciplina.create!( + codigo: "Codigo", + nome: "Nome", + departamento: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Codigo/) + expect(rendered).to match(/Nome/) + expect(rendered).to match(//) + end +end diff --git a/spec/views/docentes/edit.html.erb_spec.rb b/spec/views/docentes/edit.html.erb_spec.rb new file mode 100644 index 0000000000..4efd057927 --- /dev/null +++ b/spec/views/docentes/edit.html.erb_spec.rb @@ -0,0 +1,31 @@ +require 'rails_helper' + +RSpec.describe "docentes/edit", type: :view do + let(:docente) { + Docente.create!( + matricula: "MyString", + email: "MyString", + nome: "MyString", + formacao: "MyString" + ) + } + + before(:each) do + assign(:docente, docente) + end + + it "renders the edit docente form" do + render + + assert_select "form[action=?][method=?]", docente_path(docente), "post" do + + assert_select "input[name=?]", "docente[matricula]" + + assert_select "input[name=?]", "docente[email]" + + assert_select "input[name=?]", "docente[nome]" + + assert_select "input[name=?]", "docente[formacao]" + end + end +end diff --git a/spec/views/docentes/index.html.erb_spec.rb b/spec/views/docentes/index.html.erb_spec.rb new file mode 100644 index 0000000000..607f2ff85b --- /dev/null +++ b/spec/views/docentes/index.html.erb_spec.rb @@ -0,0 +1,29 @@ +require 'rails_helper' + +RSpec.describe "docentes/index", type: :view do + before(:each) do + assign(:docentes, [ + Docente.create!( + matricula: "Matricula", + email: "Email", + nome: "Nome", + formacao: "Formacao" + ), + Docente.create!( + matricula: "Matricula", + email: "Email", + nome: "Nome", + formacao: "Formacao" + ) + ]) + end + + it "renders a list of docentes" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new("Matricula".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Email".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Formacao".to_s), count: 2 + end +end diff --git a/spec/views/docentes/new.html.erb_spec.rb b/spec/views/docentes/new.html.erb_spec.rb new file mode 100644 index 0000000000..47b12f4329 --- /dev/null +++ b/spec/views/docentes/new.html.erb_spec.rb @@ -0,0 +1,27 @@ +require 'rails_helper' + +RSpec.describe "docentes/new", type: :view do + before(:each) do + assign(:docente, Docente.new( + matricula: "MyString", + email: "MyString", + nome: "MyString", + formacao: "MyString" + )) + end + + it "renders new docente form" do + render + + assert_select "form[action=?][method=?]", docentes_path, "post" do + + assert_select "input[name=?]", "docente[matricula]" + + assert_select "input[name=?]", "docente[email]" + + assert_select "input[name=?]", "docente[nome]" + + assert_select "input[name=?]", "docente[formacao]" + end + end +end diff --git a/spec/views/docentes/show.html.erb_spec.rb b/spec/views/docentes/show.html.erb_spec.rb new file mode 100644 index 0000000000..ae9b8987d0 --- /dev/null +++ b/spec/views/docentes/show.html.erb_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe "docentes/show", type: :view do + before(:each) do + assign(:docente, Docente.create!( + matricula: "Matricula", + email: "Email", + nome: "Nome", + formacao: "Formacao" + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Matricula/) + expect(rendered).to match(/Email/) + expect(rendered).to match(/Nome/) + expect(rendered).to match(/Formacao/) + end +end diff --git a/spec/views/elemento_forms/edit.html.erb_spec.rb b/spec/views/elemento_forms/edit.html.erb_spec.rb new file mode 100644 index 0000000000..a25c3a7389 --- /dev/null +++ b/spec/views/elemento_forms/edit.html.erb_spec.rb @@ -0,0 +1,28 @@ +require 'rails_helper' + +RSpec.describe "elemento_forms/edit", type: :view do + let(:elemento_form) { + ElementoForm.create!( + ordem: 1, + enunciado: "MyString", + formulario: nil + ) + } + + before(:each) do + assign(:elemento_form, elemento_form) + end + + it "renders the edit elemento_form form" do + render + + assert_select "form[action=?][method=?]", elemento_form_path(elemento_form), "post" do + + assert_select "input[name=?]", "elemento_form[ordem]" + + assert_select "input[name=?]", "elemento_form[enunciado]" + + assert_select "input[name=?]", "elemento_form[formulario_id]" + end + end +end diff --git a/spec/views/elemento_forms/index.html.erb_spec.rb b/spec/views/elemento_forms/index.html.erb_spec.rb new file mode 100644 index 0000000000..c86baf8d4a --- /dev/null +++ b/spec/views/elemento_forms/index.html.erb_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +RSpec.describe "elemento_forms/index", type: :view do + before(:each) do + assign(:elemento_forms, [ + ElementoForm.create!( + ordem: 2, + enunciado: "Enunciado", + formulario: nil + ), + ElementoForm.create!( + ordem: 2, + enunciado: "Enunciado", + formulario: nil + ) + ]) + end + + it "renders a list of elemento_forms" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new(2.to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Enunciado".to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/elemento_forms/new.html.erb_spec.rb b/spec/views/elemento_forms/new.html.erb_spec.rb new file mode 100644 index 0000000000..9fb02ca849 --- /dev/null +++ b/spec/views/elemento_forms/new.html.erb_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe "elemento_forms/new", type: :view do + before(:each) do + assign(:elemento_form, ElementoForm.new( + ordem: 1, + enunciado: "MyString", + formulario: nil + )) + end + + it "renders new elemento_form form" do + render + + assert_select "form[action=?][method=?]", elemento_forms_path, "post" do + + assert_select "input[name=?]", "elemento_form[ordem]" + + assert_select "input[name=?]", "elemento_form[enunciado]" + + assert_select "input[name=?]", "elemento_form[formulario_id]" + end + end +end diff --git a/spec/views/elemento_forms/show.html.erb_spec.rb b/spec/views/elemento_forms/show.html.erb_spec.rb new file mode 100644 index 0000000000..b117069837 --- /dev/null +++ b/spec/views/elemento_forms/show.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "elemento_forms/show", type: :view do + before(:each) do + assign(:elemento_form, ElementoForm.create!( + ordem: 2, + enunciado: "Enunciado", + formulario: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/2/) + expect(rendered).to match(/Enunciado/) + expect(rendered).to match(//) + end +end diff --git a/spec/views/elementos/edit.html.erb_spec.rb b/spec/views/elementos/edit.html.erb_spec.rb new file mode 100644 index 0000000000..7331812d36 --- /dev/null +++ b/spec/views/elementos/edit.html.erb_spec.rb @@ -0,0 +1,28 @@ +require 'rails_helper' + +RSpec.describe "elementos/edit", type: :view do + let(:elemento) { + Elemento.create!( + ordem: 1, + enunciado: "MyString", + template: nil + ) + } + + before(:each) do + assign(:elemento, elemento) + end + + it "renders the edit elemento form" do + render + + assert_select "form[action=?][method=?]", elemento_path(elemento), "post" do + + assert_select "input[name=?]", "elemento[ordem]" + + assert_select "input[name=?]", "elemento[enunciado]" + + assert_select "input[name=?]", "elemento[template_id]" + end + end +end diff --git a/spec/views/elementos/index.html.erb_spec.rb b/spec/views/elementos/index.html.erb_spec.rb new file mode 100644 index 0000000000..b71ab9bc50 --- /dev/null +++ b/spec/views/elementos/index.html.erb_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +RSpec.describe "elementos/index", type: :view do + before(:each) do + assign(:elementos, [ + Elemento.create!( + ordem: 2, + enunciado: "Enunciado", + template: nil + ), + Elemento.create!( + ordem: 2, + enunciado: "Enunciado", + template: nil + ) + ]) + end + + it "renders a list of elementos" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new(2.to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Enunciado".to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/elementos/new.html.erb_spec.rb b/spec/views/elementos/new.html.erb_spec.rb new file mode 100644 index 0000000000..a0e976d8f6 --- /dev/null +++ b/spec/views/elementos/new.html.erb_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe "elementos/new", type: :view do + before(:each) do + assign(:elemento, Elemento.new( + ordem: 1, + enunciado: "MyString", + template: nil + )) + end + + it "renders new elemento form" do + render + + assert_select "form[action=?][method=?]", elementos_path, "post" do + + assert_select "input[name=?]", "elemento[ordem]" + + assert_select "input[name=?]", "elemento[enunciado]" + + assert_select "input[name=?]", "elemento[template_id]" + end + end +end diff --git a/spec/views/elementos/show.html.erb_spec.rb b/spec/views/elementos/show.html.erb_spec.rb new file mode 100644 index 0000000000..08e9893960 --- /dev/null +++ b/spec/views/elementos/show.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "elementos/show", type: :view do + before(:each) do + assign(:elemento, Elemento.create!( + ordem: 2, + enunciado: "Enunciado", + template: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/2/) + expect(rendered).to match(/Enunciado/) + expect(rendered).to match(//) + end +end diff --git a/spec/views/formularios/edit.html.erb_spec.rb b/spec/views/formularios/edit.html.erb_spec.rb new file mode 100644 index 0000000000..118f90cb9f --- /dev/null +++ b/spec/views/formularios/edit.html.erb_spec.rb @@ -0,0 +1,22 @@ +require 'rails_helper' + +RSpec.describe "formularios/edit", type: :view do + let(:formulario) { + Formulario.create!( + turma: nil + ) + } + + before(:each) do + assign(:formulario, formulario) + end + + it "renders the edit formulario form" do + render + + assert_select "form[action=?][method=?]", formulario_path(formulario), "post" do + + assert_select "input[name=?]", "formulario[turma_id]" + end + end +end diff --git a/spec/views/formularios/index.html.erb_spec.rb b/spec/views/formularios/index.html.erb_spec.rb new file mode 100644 index 0000000000..e7eb943e54 --- /dev/null +++ b/spec/views/formularios/index.html.erb_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe "formularios/index", type: :view do + before(:each) do + assign(:formularios, [ + Formulario.create!( + turma: nil + ), + Formulario.create!( + turma: nil + ) + ]) + end + + it "renders a list of formularios" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/formularios/new.html.erb_spec.rb b/spec/views/formularios/new.html.erb_spec.rb new file mode 100644 index 0000000000..84fd52bf73 --- /dev/null +++ b/spec/views/formularios/new.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "formularios/new", type: :view do + before(:each) do + assign(:formulario, Formulario.new( + turma: nil + )) + end + + it "renders new formulario form" do + render + + assert_select "form[action=?][method=?]", formularios_path, "post" do + + assert_select "input[name=?]", "formulario[turma_id]" + end + end +end diff --git a/spec/views/formularios/show.html.erb_spec.rb b/spec/views/formularios/show.html.erb_spec.rb new file mode 100644 index 0000000000..e66b8bc106 --- /dev/null +++ b/spec/views/formularios/show.html.erb_spec.rb @@ -0,0 +1,14 @@ +require 'rails_helper' + +RSpec.describe "formularios/show", type: :view do + before(:each) do + assign(:formulario, Formulario.create!( + turma: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(//) + end +end diff --git a/spec/views/resposta_elems/edit.html.erb_spec.rb b/spec/views/resposta_elems/edit.html.erb_spec.rb new file mode 100644 index 0000000000..39fe881633 --- /dev/null +++ b/spec/views/resposta_elems/edit.html.erb_spec.rb @@ -0,0 +1,31 @@ +require 'rails_helper' + +RSpec.describe "resposta_elems/edit", type: :view do + let(:resposta_elem) { + RespostaElem.create!( + texto_resposta: "MyText", + resposta_form: nil, + elemento_form: nil, + campo_form: nil + ) + } + + before(:each) do + assign(:resposta_elem, resposta_elem) + end + + it "renders the edit resposta_elem form" do + render + + assert_select "form[action=?][method=?]", resposta_elem_path(resposta_elem), "post" do + + assert_select "textarea[name=?]", "resposta_elem[texto_resposta]" + + assert_select "input[name=?]", "resposta_elem[resposta_form_id]" + + assert_select "input[name=?]", "resposta_elem[elemento_form_id]" + + assert_select "input[name=?]", "resposta_elem[campo_form_id]" + end + end +end diff --git a/spec/views/resposta_elems/index.html.erb_spec.rb b/spec/views/resposta_elems/index.html.erb_spec.rb new file mode 100644 index 0000000000..0b4c0af7e9 --- /dev/null +++ b/spec/views/resposta_elems/index.html.erb_spec.rb @@ -0,0 +1,29 @@ +require 'rails_helper' + +RSpec.describe "resposta_elems/index", type: :view do + before(:each) do + assign(:resposta_elems, [ + RespostaElem.create!( + texto_resposta: "MyText", + resposta_form: nil, + elemento_form: nil, + campo_form: nil + ), + RespostaElem.create!( + texto_resposta: "MyText", + resposta_form: nil, + elemento_form: nil, + campo_form: nil + ) + ]) + end + + it "renders a list of resposta_elems" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new("MyText".to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/resposta_elems/new.html.erb_spec.rb b/spec/views/resposta_elems/new.html.erb_spec.rb new file mode 100644 index 0000000000..c8690f2b7c --- /dev/null +++ b/spec/views/resposta_elems/new.html.erb_spec.rb @@ -0,0 +1,27 @@ +require 'rails_helper' + +RSpec.describe "resposta_elems/new", type: :view do + before(:each) do + assign(:resposta_elem, RespostaElem.new( + texto_resposta: "MyText", + resposta_form: nil, + elemento_form: nil, + campo_form: nil + )) + end + + it "renders new resposta_elem form" do + render + + assert_select "form[action=?][method=?]", resposta_elems_path, "post" do + + assert_select "textarea[name=?]", "resposta_elem[texto_resposta]" + + assert_select "input[name=?]", "resposta_elem[resposta_form_id]" + + assert_select "input[name=?]", "resposta_elem[elemento_form_id]" + + assert_select "input[name=?]", "resposta_elem[campo_form_id]" + end + end +end diff --git a/spec/views/resposta_elems/show.html.erb_spec.rb b/spec/views/resposta_elems/show.html.erb_spec.rb new file mode 100644 index 0000000000..630a18fae4 --- /dev/null +++ b/spec/views/resposta_elems/show.html.erb_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe "resposta_elems/show", type: :view do + before(:each) do + assign(:resposta_elem, RespostaElem.create!( + texto_resposta: "MyText", + resposta_form: nil, + elemento_form: nil, + campo_form: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/MyText/) + expect(rendered).to match(//) + expect(rendered).to match(//) + expect(rendered).to match(//) + end +end diff --git a/spec/views/resposta_forms/edit.html.erb_spec.rb b/spec/views/resposta_forms/edit.html.erb_spec.rb new file mode 100644 index 0000000000..3428042fb5 --- /dev/null +++ b/spec/views/resposta_forms/edit.html.erb_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +RSpec.describe "resposta_forms/edit", type: :view do + let(:resposta_form) { + RespostaForm.create!( + formulario: nil, + usuario: nil + ) + } + + before(:each) do + assign(:resposta_form, resposta_form) + end + + it "renders the edit resposta_form form" do + render + + assert_select "form[action=?][method=?]", resposta_form_path(resposta_form), "post" do + + assert_select "input[name=?]", "resposta_form[formulario_id]" + + assert_select "input[name=?]", "resposta_form[usuario_id]" + end + end +end diff --git a/spec/views/resposta_forms/index.html.erb_spec.rb b/spec/views/resposta_forms/index.html.erb_spec.rb new file mode 100644 index 0000000000..01ac5cec14 --- /dev/null +++ b/spec/views/resposta_forms/index.html.erb_spec.rb @@ -0,0 +1,23 @@ +require 'rails_helper' + +RSpec.describe "resposta_forms/index", type: :view do + before(:each) do + assign(:resposta_forms, [ + RespostaForm.create!( + formulario: nil, + usuario: nil + ), + RespostaForm.create!( + formulario: nil, + usuario: nil + ) + ]) + end + + it "renders a list of resposta_forms" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/resposta_forms/new.html.erb_spec.rb b/spec/views/resposta_forms/new.html.erb_spec.rb new file mode 100644 index 0000000000..e531fe422b --- /dev/null +++ b/spec/views/resposta_forms/new.html.erb_spec.rb @@ -0,0 +1,21 @@ +require 'rails_helper' + +RSpec.describe "resposta_forms/new", type: :view do + before(:each) do + assign(:resposta_form, RespostaForm.new( + formulario: nil, + usuario: nil + )) + end + + it "renders new resposta_form form" do + render + + assert_select "form[action=?][method=?]", resposta_forms_path, "post" do + + assert_select "input[name=?]", "resposta_form[formulario_id]" + + assert_select "input[name=?]", "resposta_form[usuario_id]" + end + end +end diff --git a/spec/views/resposta_forms/show.html.erb_spec.rb b/spec/views/resposta_forms/show.html.erb_spec.rb new file mode 100644 index 0000000000..89e82f5b91 --- /dev/null +++ b/spec/views/resposta_forms/show.html.erb_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +RSpec.describe "resposta_forms/show", type: :view do + before(:each) do + assign(:resposta_form, RespostaForm.create!( + formulario: nil, + usuario: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(//) + expect(rendered).to match(//) + end +end diff --git a/spec/views/templates/edit.html.erb_spec.rb b/spec/views/templates/edit.html.erb_spec.rb new file mode 100644 index 0000000000..59b1ad2327 --- /dev/null +++ b/spec/views/templates/edit.html.erb_spec.rb @@ -0,0 +1,22 @@ +require 'rails_helper' + +RSpec.describe "templates/edit", type: :view do + let(:template) { + Template.create!( + nome: "MyString" + ) + } + + before(:each) do + assign(:template, template) + end + + it "renders the edit template form" do + render + + assert_select "form[action=?][method=?]", template_path(template), "post" do + + assert_select "input[name=?]", "template[nome]" + end + end +end diff --git a/spec/views/templates/index.html.erb_spec.rb b/spec/views/templates/index.html.erb_spec.rb new file mode 100644 index 0000000000..cd2287c874 --- /dev/null +++ b/spec/views/templates/index.html.erb_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe "templates/index", type: :view do + before(:each) do + assign(:templates, [ + Template.create!( + nome: "Nome" + ), + Template.create!( + nome: "Nome" + ) + ]) + end + + it "renders a list of templates" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 + end +end diff --git a/spec/views/templates/new.html.erb_spec.rb b/spec/views/templates/new.html.erb_spec.rb new file mode 100644 index 0000000000..17344a3896 --- /dev/null +++ b/spec/views/templates/new.html.erb_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +RSpec.describe "templates/new", type: :view do + before(:each) do + assign(:template, Template.new( + nome: "MyString" + )) + end + + it "renders new template form" do + render + + assert_select "form[action=?][method=?]", templates_path, "post" do + + assert_select "input[name=?]", "template[nome]" + end + end +end diff --git a/spec/views/templates/show.html.erb_spec.rb b/spec/views/templates/show.html.erb_spec.rb new file mode 100644 index 0000000000..760068a39e --- /dev/null +++ b/spec/views/templates/show.html.erb_spec.rb @@ -0,0 +1,14 @@ +require 'rails_helper' + +RSpec.describe "templates/show", type: :view do + before(:each) do + assign(:template, Template.create!( + nome: "Nome" + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Nome/) + end +end diff --git a/spec/views/turmas/edit.html.erb_spec.rb b/spec/views/turmas/edit.html.erb_spec.rb new file mode 100644 index 0000000000..367c9ec974 --- /dev/null +++ b/spec/views/turmas/edit.html.erb_spec.rb @@ -0,0 +1,31 @@ +require 'rails_helper' + +RSpec.describe "turmas/edit", type: :view do + let(:turma) { + Turma.create!( + numero_da_turma: "MyString", + semestre: "MyString", + horario: "MyString", + disciplina: nil + ) + } + + before(:each) do + assign(:turma, turma) + end + + it "renders the edit turma form" do + render + + assert_select "form[action=?][method=?]", turma_path(turma), "post" do + + assert_select "input[name=?]", "turma[numero_da_turma]" + + assert_select "input[name=?]", "turma[semestre]" + + assert_select "input[name=?]", "turma[horario]" + + assert_select "input[name=?]", "turma[disciplina_id]" + end + end +end diff --git a/spec/views/turmas/index.html.erb_spec.rb b/spec/views/turmas/index.html.erb_spec.rb new file mode 100644 index 0000000000..6a08b99105 --- /dev/null +++ b/spec/views/turmas/index.html.erb_spec.rb @@ -0,0 +1,29 @@ +require 'rails_helper' + +RSpec.describe "turmas/index", type: :view do + before(:each) do + assign(:turmas, [ + Turma.create!( + numero_da_turma: "Numero Da Turma", + semestre: "Semestre", + horario: "Horario", + disciplina: nil + ), + Turma.create!( + numero_da_turma: "Numero Da Turma", + semestre: "Semestre", + horario: "Horario", + disciplina: nil + ) + ]) + end + + it "renders a list of turmas" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new("Numero Da Turma".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Semestre".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Horario".to_s), count: 2 + assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 + end +end diff --git a/spec/views/turmas/new.html.erb_spec.rb b/spec/views/turmas/new.html.erb_spec.rb new file mode 100644 index 0000000000..ed22cbe1d3 --- /dev/null +++ b/spec/views/turmas/new.html.erb_spec.rb @@ -0,0 +1,27 @@ +require 'rails_helper' + +RSpec.describe "turmas/new", type: :view do + before(:each) do + assign(:turma, Turma.new( + numero_da_turma: "MyString", + semestre: "MyString", + horario: "MyString", + disciplina: nil + )) + end + + it "renders new turma form" do + render + + assert_select "form[action=?][method=?]", turmas_path, "post" do + + assert_select "input[name=?]", "turma[numero_da_turma]" + + assert_select "input[name=?]", "turma[semestre]" + + assert_select "input[name=?]", "turma[horario]" + + assert_select "input[name=?]", "turma[disciplina_id]" + end + end +end diff --git a/spec/views/turmas/show.html.erb_spec.rb b/spec/views/turmas/show.html.erb_spec.rb new file mode 100644 index 0000000000..0f6e190b67 --- /dev/null +++ b/spec/views/turmas/show.html.erb_spec.rb @@ -0,0 +1,20 @@ +require 'rails_helper' + +RSpec.describe "turmas/show", type: :view do + before(:each) do + assign(:turma, Turma.create!( + numero_da_turma: "Numero Da Turma", + semestre: "Semestre", + horario: "Horario", + disciplina: nil + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Numero Da Turma/) + expect(rendered).to match(/Semestre/) + expect(rendered).to match(/Horario/) + expect(rendered).to match(//) + end +end diff --git a/spec/views/usuarios/edit.html.erb_spec.rb b/spec/views/usuarios/edit.html.erb_spec.rb new file mode 100644 index 0000000000..03ac004182 --- /dev/null +++ b/spec/views/usuarios/edit.html.erb_spec.rb @@ -0,0 +1,34 @@ +require 'rails_helper' + +RSpec.describe "usuarios/edit", type: :view do + let(:usuario) { + Usuario.create!( + matricula: "MyString", + email: "MyString", + nome: "MyString", + formacao: "MyString", + type: "" + ) + } + + before(:each) do + assign(:usuario, usuario) + end + + it "renders the edit usuario form" do + render + + assert_select "form[action=?][method=?]", usuario_path(usuario), "post" do + + assert_select "input[name=?]", "usuario[matricula]" + + assert_select "input[name=?]", "usuario[email]" + + assert_select "input[name=?]", "usuario[nome]" + + assert_select "input[name=?]", "usuario[formacao]" + + assert_select "input[name=?]", "usuario[type]" + end + end +end diff --git a/spec/views/usuarios/index.html.erb_spec.rb b/spec/views/usuarios/index.html.erb_spec.rb new file mode 100644 index 0000000000..8c9c12b987 --- /dev/null +++ b/spec/views/usuarios/index.html.erb_spec.rb @@ -0,0 +1,32 @@ +require 'rails_helper' + +RSpec.describe "usuarios/index", type: :view do + before(:each) do + assign(:usuarios, [ + Usuario.create!( + matricula: "Matricula", + email: "Email", + nome: "Nome", + formacao: "Formacao", + type: "Type" + ), + Usuario.create!( + matricula: "Matricula", + email: "Email", + nome: "Nome", + formacao: "Formacao", + type: "Type" + ) + ]) + end + + it "renders a list of usuarios" do + render + cell_selector = 'div>p' + assert_select cell_selector, text: Regexp.new("Matricula".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Email".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Formacao".to_s), count: 2 + assert_select cell_selector, text: Regexp.new("Type".to_s), count: 2 + end +end diff --git a/spec/views/usuarios/new.html.erb_spec.rb b/spec/views/usuarios/new.html.erb_spec.rb new file mode 100644 index 0000000000..0db91f114e --- /dev/null +++ b/spec/views/usuarios/new.html.erb_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' + +RSpec.describe "usuarios/new", type: :view do + before(:each) do + assign(:usuario, Usuario.new( + matricula: "MyString", + email: "MyString", + nome: "MyString", + formacao: "MyString", + type: "" + )) + end + + it "renders new usuario form" do + render + + assert_select "form[action=?][method=?]", usuarios_path, "post" do + + assert_select "input[name=?]", "usuario[matricula]" + + assert_select "input[name=?]", "usuario[email]" + + assert_select "input[name=?]", "usuario[nome]" + + assert_select "input[name=?]", "usuario[formacao]" + + assert_select "input[name=?]", "usuario[type]" + end + end +end diff --git a/spec/views/usuarios/show.html.erb_spec.rb b/spec/views/usuarios/show.html.erb_spec.rb new file mode 100644 index 0000000000..871de0d504 --- /dev/null +++ b/spec/views/usuarios/show.html.erb_spec.rb @@ -0,0 +1,22 @@ +require 'rails_helper' + +RSpec.describe "usuarios/show", type: :view do + before(:each) do + assign(:usuario, Usuario.create!( + matricula: "Matricula", + email: "Email", + nome: "Nome", + formacao: "Formacao", + type: "Type" + )) + end + + it "renders attributes in

" do + render + expect(rendered).to match(/Matricula/) + expect(rendered).to match(/Email/) + expect(rendered).to match(/Nome/) + expect(rendered).to match(/Formacao/) + expect(rendered).to match(/Type/) + end +end From 1c99fd102d19a93fa89a213a6f405d560f1b528a Mon Sep 17 00:00:00 2001 From: neatzzy Date: Mon, 1 Jun 2026 16:56:52 -0300 Subject: [PATCH 12/55] :sparkles: feat: rotas do admin do sistema --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 20f16c622c..5faee283e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,6 +19,8 @@ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check + get 'admin', to 'admin#index', as :admin + post 'admin/importar_sigaa' to 'admin#importar_sigaa', as :importar_sigaa # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest From 6e9b38cd71e2c3657d1ced5c2439b6ecf8aea3ef Mon Sep 17 00:00:00 2001 From: neatzzy Date: Mon, 1 Jun 2026 17:55:07 -0300 Subject: [PATCH 13/55] :wrench: fix: consertado erro de sintaxe das rotas --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 5faee283e1..3f7eb9e566 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,8 +19,8 @@ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check - get 'admin', to 'admin#index', as :admin - post 'admin/importar_sigaa' to 'admin#importar_sigaa', as :importar_sigaa + get "admin", to: "admin#index", as: :admin + post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest From 046f258fd81f87e152c92087cc1f093e6af97810 Mon Sep 17 00:00:00 2001 From: neatzzy Date: Mon, 1 Jun 2026 18:30:01 -0300 Subject: [PATCH 14/55] =?UTF-8?q?:sparkles:=20feat:=20Importa=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20dados=20do=20sigaa=20e=20configura=C3=A7=C3=A3o=20do=20?= =?UTF-8?q?db=20de=20testes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 1 + Gemfile.lock | 15 ++ app/controllers/admin_controller.rb | 35 +++++ app/helpers/admin_helper.rb | 2 + app/services/sigaa_importer.rb | 138 ++++++++++++++++++ app/views/admin/index.html.erb | 7 + app/views/layouts/application.html.erb | 8 + config/database.yml | 13 +- .../importar_dados_sigaa_steps.rb | 45 ++++++ features/support/env.rb | 13 ++ spec/helpers/admin_helper_spec.rb | 15 ++ spec/requests/admin_spec.rb | 7 + 12 files changed, 294 insertions(+), 5 deletions(-) create mode 100644 app/controllers/admin_controller.rb create mode 100644 app/helpers/admin_helper.rb create mode 100644 app/services/sigaa_importer.rb create mode 100644 app/views/admin/index.html.erb create mode 100644 features/step_definitions/importar_dados_sigaa_steps.rb create mode 100644 spec/helpers/admin_helper_spec.rb create mode 100644 spec/requests/admin_spec.rb diff --git a/Gemfile b/Gemfile index c8d2dce83a..f0d7bf40b5 100644 --- a/Gemfile +++ b/Gemfile @@ -66,5 +66,6 @@ group :test do gem "selenium-webdriver" gem "cucumber-rails", require: false gem "database_cleaner" + gem "sqlite3", ">= 2.1" gem "rspec-rails" end diff --git a/Gemfile.lock b/Gemfile.lock index 56c83cb28b..84e9e94176 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -387,6 +387,13 @@ GEM fugit (~> 1.11) railties (>= 7.1) thor (>= 1.3.1) + sqlite3 (2.9.4-aarch64-linux-gnu) + sqlite3 (2.9.4-aarch64-linux-musl) + sqlite3 (2.9.4-arm-linux-gnu) + sqlite3 (2.9.4-arm-linux-musl) + sqlite3 (2.9.4-x64-mingw-ucrt) + sqlite3 (2.9.4-x86_64-linux-gnu) + sqlite3 (2.9.4-x86_64-linux-musl) sshkit (1.25.0) base64 logger @@ -469,6 +476,7 @@ DEPENDENCIES solid_cable solid_cache solid_queue + sqlite3 (>= 2.1) stimulus-rails thruster turbo-rails @@ -613,6 +621,13 @@ CHECKSUMS solid_cable (3.0.12) sha256=a168a54731a455d5627af48d8441ea3b554b8c1f6e6cd6074109de493e6b0460 solid_cache (1.0.10) sha256=bc05a2fb3ac78a6f43cbb5946679cf9db67dd30d22939ededc385cb93e120d41 solid_queue (1.4.0) sha256=e6a18d196f0b27cb6e3c77c5b31258b05fb634f8ed64fb1866ed164047216c2a + sqlite3 (2.9.4-aarch64-linux-gnu) sha256=ecabed721e6eaad54601d2685f09029d90025efc8d931040dc89cb3f8a2080ec + sqlite3 (2.9.4-aarch64-linux-musl) sha256=ffb4255947fb54c8c3eeca97460c9702b40de91ce390455ef7367ca6a3929a31 + sqlite3 (2.9.4-arm-linux-gnu) sha256=9ee2008b9fbec984c3c165b0d7eedd2bd2a415100b761bfa3a4c6fbec9208bf6 + sqlite3 (2.9.4-arm-linux-musl) sha256=8dc1fe4da6977992cd62decf4a93ccf6cc2e124a5e6a340160d52092f70e837a + sqlite3 (2.9.4-x64-mingw-ucrt) sha256=40997c549b19e2fdfcc5e271f6bdd4d502179742c0bfd678da23d0d09b929848 + sqlite3 (2.9.4-x86_64-linux-gnu) sha256=537a3eda71b1df1336d0055cbebe55a7317c34870c192c7b6b9d8d0be6871847 + sqlite3 (2.9.4-x86_64-linux-musl) sha256=3fc5e865b4be9a85d998203ef8d0c0fdcb92f20acf34a254346ff8a19088efec sshkit (1.25.0) sha256=c8c6543cdb60f91f1d277306d585dd11b6a064cb44eab0972827e4311ff96744 stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06 stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1 diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb new file mode 100644 index 0000000000..55fcf87194 --- /dev/null +++ b/app/controllers/admin_controller.rb @@ -0,0 +1,35 @@ +class AdminController < ApplicationController + def index + # Renderiza a página com os botões de Importar e Atualizar + end + + def importar_sigaa + resultado = SigaaImporter.import_from_files("classes.json", "members.json") + + case resultado + when /sucesso/i + redirect_to admin_path, notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." + when /alguns dados/i + redirect_to admin_path, notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" + when /já existem/i + redirect_to admin_path, alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" + else + redirect_to admin_path, alert: "erro informando que a importação falhou" + end + end + + def atualizar_sigaa + resultado = SigaaImporter.update_from_files("classes.json", "members.json") + + case resultado + when /atualiza/i + redirect_to admin_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." + when /alguns dados/i + redirect_to admin_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" + when /já estão atualizados/i + redirect_to admin_path, alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" + else + redirect_to admin_path, alert: "erro informando que a atualização falhou" + end + end +end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb new file mode 100644 index 0000000000..d5c6d3555d --- /dev/null +++ b/app/helpers/admin_helper.rb @@ -0,0 +1,2 @@ +module AdminHelper +end diff --git a/app/services/sigaa_importer.rb b/app/services/sigaa_importer.rb new file mode 100644 index 0000000000..461d42b0a2 --- /dev/null +++ b/app/services/sigaa_importer.rb @@ -0,0 +1,138 @@ +class SigaaImporter + def self.import_from_files(classes_path, members_path) + created = 0 + ignored = 0 + + ActiveRecord::Base.transaction do + # classes.json + classes = JSON.parse(File.read(classes_path)) + classes.each do |c| + disciplina = Disciplina.find_or_create_by(codigo: c["code"]) do |d| + d.nome = c["name"] + end + + class_info = c["class"] || {} + turma = Turma.find_or_create_by(disciplina: disciplina, numero_da_turma: class_info["classCode"], semestre: class_info["semester"]) do |t| + t.horario = class_info["time"] + end + + if turma.created_at == turma.updated_at + created += 1 + else + ignored += 1 + end + end + + # class_members.json + members = JSON.parse(File.read(members_path)) + members.each do |m| + code = m.dig("class", "code") || m["code"] + class_code = m.dig("class", "classCode") || m["classCode"] + semester = m.dig("class", "semester") || m["semester"] + + disciplina = Disciplina.find_by(codigo: code) + turma = Turma.find_by(disciplina: disciplina, numero_da_turma: class_code, semestre: semester) + next unless turma + + # docente + if m["docente"].is_a?(Hash) + dep = Departamento.find_or_create_by(nome: m["docente"]["departamento"]) if m["docente"]["departamento"] + usuario = Usuario.find_or_create_by(usuario: m["docente"]["usuario"]) do |u| + u.nome = m["docente"]["nome"] + u.email = m["docente"]["email"] + end + docente = Docente.find_or_create_by(usuario: usuario.usuario) do |dct| + dct.nome = usuario.nome + dct.email = usuario.email + dct.departamento = dep if dep + end + unless docente.turmas.exists?(turma.id) + docente.turmas << turma + created += 1 + else + ignored += 1 + end + end + + # discentes + Array(m["dicente"]).each do |aluno| + next unless aluno.is_a?(Hash) + curso = Curso.find_or_create_by(nome: aluno["curso"]) if aluno["curso"] + usuario = Usuario.find_or_create_by(matricula: aluno["matricula"]) do |u| + u.nome = aluno["nome"] + u.email = aluno["email"] + end + discente = Discente.find_or_create_by(matricula: aluno["matricula"]) do |d| + d.nome = usuario.nome + d.usuario = usuario.usuario if usuario.respond_to?(:usuario) + d.curso = curso if curso + end + unless discente.turmas.exists?(turma.id) + discente.turmas << turma + created += 1 + else + ignored += 1 + end + end + end + end + + if created > 0 && ignored > 0 + "alguns dados já foram importados e não serão importados novamente, mas os dados restantes foram importados com sucesso" + elsif created == 0 + "os dados já existem e não foram duplicados" + else + "importação realizada com sucesso" + end + rescue StandardError => _e + "a importação falhou" + end + + def self.update_from_files(classes_path, members_path) + ActiveRecord::Base.transaction do + classes = JSON.parse(File.read(classes_path)) + classes.each do |c| + disciplina = Disciplina.find_by(codigo: c["code"]) + disciplina.update(nome: c["name"]) if disciplina + + class_info = c["class"] || {} + turma = Turma.find_by(disciplina: disciplina, numero_da_turma: class_info["classCode"], semestre: class_info["semester"]) + turma.update(horario: class_info["time"]) if turma + end + + members = JSON.parse(File.read(members_path)) + members.each do |m| + code = m.dig("class", "code") || m["code"] + class_code = m.dig("class", "classCode") || m["classCode"] + semester = m.dig("class", "semester") || m["semester"] + + disciplina = Disciplina.find_by(codigo: code) + turma = Turma.find_by(disciplina: disciplina, numero_da_turma: class_code, semestre: semester) + next unless turma + + if m["docente"].is_a?(Hash) + dep = Departamento.find_or_create_by(nome: m["docente"]["departamento"]) if m["docente"]["departamento"] + usuario = Usuario.find_by(usuario: m["docente"]["usuario"]) + usuario.update(nome: m["docente"]["nome"], email: m["docente"]["email"]) if usuario + docente = Docente.find_by(usuario: m["docente"]["usuario"]) + docente.update(nome: m["docente"]["nome"], email: m["docente"]["email"], departamento: dep) if docente + docente.turmas << turma unless docente.turmas.exists?(turma.id) + end + + Array(m["dicente"]).each do |aluno| + next unless aluno.is_a?(Hash) + curso = Curso.find_or_create_by(nome: aluno["curso"]) if aluno["curso"] + usuario = Usuario.find_by(matricula: aluno["matricula"]) + usuario.update(nome: aluno["nome"], email: aluno["email"]) if usuario + discente = Discente.find_by(matricula: aluno["matricula"]) + discente.update(nome: aluno["nome"], curso: curso) if discente + discente.turmas << turma unless discente.turmas.exists?(turma.id) + end + end + end + + "atualização realizada com sucesso" + rescue StandardError => _e + "a atualização falhou" + end +end diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb new file mode 100644 index 0000000000..e5b841e377 --- /dev/null +++ b/app/views/admin/index.html.erb @@ -0,0 +1,7 @@ +

+

Ações de Importação SIGAA

+ +
+ <%= button_to "Importar SIGAA", importar_sigaa_path, method: :post, class: "btn btn-primary" %> +
+
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9e51e3817f..b8541bf863 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -24,6 +24,14 @@ + <% if flash.any? %> +
+ <% flash.each do |type, message| %> +
<%= message %>
+ <% end %> +
+ <% end %> + <%= yield %> diff --git a/config/database.yml b/config/database.yml index a857bdc858..2b363eb8c2 100644 --- a/config/database.yml +++ b/config/database.yml @@ -13,9 +13,9 @@ default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - username: root - password: root - socket: /var/run/mysqld/mysqld.sock + username: <%= ENV.fetch("CAMAAR_DATABASE_USERNAME", "root") %> + password: <%= ENV.fetch("CAMAAR_DATABASE_PASSWORD", "root") %> + socket: <%= ENV.fetch("MYSQL_SOCKET", "/var/run/mysqld/mysqld.sock") %> development: <<: *default @@ -25,8 +25,11 @@ development: # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: - <<: *default - database: camaar_test + adapter: sqlite3 + database: db/test.sqlite3 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + timeout: 5000 + encoding: utf8 # As with config/credentials.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is diff --git a/features/step_definitions/importar_dados_sigaa_steps.rb b/features/step_definitions/importar_dados_sigaa_steps.rb new file mode 100644 index 0000000000..3bf2146cd1 --- /dev/null +++ b/features/step_definitions/importar_dados_sigaa_steps.rb @@ -0,0 +1,45 @@ + + +Dado('que os dados do SIGAA estão disponíveis para importação') do + # By default, let the importer work normally; specific scenarios will stub its return. +end + +Dado('que os dados do SIGAA foram importados com sucesso') do + allow(SigaaImporter).to receive(:import_from_files).and_return("importação realizada com sucesso") + page.driver.post(importar_sigaa_path) + visit admin_path +end + +Dado('que eu tentei importar os dados do SIGAA mas ocorreu um erro') do + allow(SigaaImporter).to receive(:import_from_files).and_return("a importação falhou") + page.driver.post(importar_sigaa_path) + visit admin_path +end + +Dado('que os dados do SIGAA já existem na base de dados do sistema') do + allow(SigaaImporter).to receive(:import_from_files).and_return("os dados já existem e não foram duplicados") + page.driver.post(importar_sigaa_path) + visit admin_path +end + +Dado('que alguns dados do SIGAA já existem na base de dados do sistema') do + allow(SigaaImporter).to receive(:import_from_files).and_return("alguns dados já foram importados e não serão importados novamente") + page.driver.post(importar_sigaa_path) + visit admin_path +end + +Então('as turmas, matérias e participantes do SIGAA estão presentes no sistema') do + expect(page).to have_content('As turmas, matérias e participantes do SIGAA estão presentes no sistema') +end + +Então('uma mensagem de erro é exibida informando que a importação falhou') do + expect(page).to have_content('erro informando que a importação falhou') +end + +Então('uma mensagem é exibida informando que os dados já foram importados e não serão importados novamente') do + expect(page).to have_content('os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente') +end + +Então('uma mensagem é exibida informando que alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso') do + expect(page).to have_content('alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso') +end diff --git a/features/support/env.rb b/features/support/env.rb index 3b97d14087..b475ecd447 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -51,3 +51,16 @@ # The :transaction strategy is faster, but might give you threading problems. # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature Cucumber::Rails::Database.javascript_strategy = :truncation + +# Make RSpec mocks available in Cucumber steps (allow_any_instance_of, allow, etc.) +require 'rspec/mocks' +World(RSpec::Mocks::ExampleMethods) + +Before do + RSpec::Mocks.setup +end + +After do + RSpec::Mocks.verify + RSpec::Mocks.teardown +end diff --git a/spec/helpers/admin_helper_spec.rb b/spec/helpers/admin_helper_spec.rb new file mode 100644 index 0000000000..aec0cef762 --- /dev/null +++ b/spec/helpers/admin_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the AdminHelper. For example: +# +# describe AdminHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe AdminHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/admin_spec.rb b/spec/requests/admin_spec.rb new file mode 100644 index 0000000000..2ce29b5db8 --- /dev/null +++ b/spec/requests/admin_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe "Admins", type: :request do + describe "GET /index" do + pending "add some examples (or delete) #{__FILE__}" + end +end From b66685fa8324f5c6a173183293070a7178546d50 Mon Sep 17 00:00:00 2001 From: leitaonerd Date: Tue, 2 Jun 2026 16:50:28 -0300 Subject: [PATCH 15/55] =?UTF-8?q?defini=C3=A7=C3=A3o=20e=20redefini=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20senha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 +- Gemfile.lock | 3 + .../definicao_senhas_controller.rb | 45 +++++++++++ app/controllers/home_controller.rb | 4 + .../redefinicao_senhas_controller.rb | 67 ++++++++++++++++ app/controllers/sessions_controller.rb | 44 +++++++++++ app/mailers/usuario_mailer.rb | 15 ++++ app/models/usuario.rb | 70 +++++++++++++++++ app/views/definicao_senhas/edit.html.erb | 17 +++++ app/views/home/index.html.erb | 1 + app/views/layouts/application.html.erb | 4 + app/views/redefinicao_senhas/edit.html.erb | 17 +++++ app/views/redefinicao_senhas/new.html.erb | 12 +++ app/views/sessions/new.html.erb | 19 +++++ .../usuario_mailer/definicao_senha.html.erb | 5 ++ .../usuario_mailer/definicao_senha.text.erb | 5 ++ .../usuario_mailer/redefinicao_senha.html.erb | 5 ++ .../usuario_mailer/redefinicao_senha.text.erb | 5 ++ config/routes.rb | 14 ++++ ...1120000_add_definicao_senha_to_usuarios.rb | 8 ++ ...90000_add_redefinicao_senha_to_usuarios.rb | 8 ++ db/schema.rb | 8 +- features/step_definitions/cadastro_steps.rb | 13 ++-- .../criar_formulario_steps.rb | 1 + features/step_definitions/login_steps.rb | 28 +++++-- features/step_definitions/senha_steps.rb | 76 +++++++++++++++++++ 26 files changed, 484 insertions(+), 12 deletions(-) create mode 100644 app/controllers/definicao_senhas_controller.rb create mode 100644 app/controllers/home_controller.rb create mode 100644 app/controllers/redefinicao_senhas_controller.rb create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/mailers/usuario_mailer.rb create mode 100644 app/views/definicao_senhas/edit.html.erb create mode 100644 app/views/home/index.html.erb create mode 100644 app/views/redefinicao_senhas/edit.html.erb create mode 100644 app/views/redefinicao_senhas/new.html.erb create mode 100644 app/views/sessions/new.html.erb create mode 100644 app/views/usuario_mailer/definicao_senha.html.erb create mode 100644 app/views/usuario_mailer/definicao_senha.text.erb create mode 100644 app/views/usuario_mailer/redefinicao_senha.html.erb create mode 100644 app/views/usuario_mailer/redefinicao_senha.text.erb create mode 100644 db/migrate/20260601120000_add_definicao_senha_to_usuarios.rb create mode 100644 db/migrate/20260602090000_add_redefinicao_senha_to_usuarios.rb create mode 100644 features/step_definitions/senha_steps.rb diff --git a/Gemfile b/Gemfile index c8d2dce83a..892d972fbd 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,7 @@ gem "stimulus-rails" gem "jbuilder" # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" +gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem "tzinfo-data", platforms: %i[ windows jruby ] diff --git a/Gemfile.lock b/Gemfile.lock index 56c83cb28b..c6a237f391 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,6 +79,7 @@ GEM public_suffix (>= 2.0.2, < 8.0) ast (2.4.3) base64 (0.3.0) + bcrypt (3.1.22) bcrypt_pbkdf (1.1.2) bigdecimal (4.1.2) bindex (0.8.1) @@ -448,6 +449,7 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES + bcrypt (~> 3.1.7) bootsnap brakeman bundler-audit @@ -491,6 +493,7 @@ CHECKSUMS addressable (2.9.0) sha256=7fdf6ac3660f7f4e867a0838be3f6cf722ace541dd97767fa42bc6cfa980c7af ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383 base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b + bcrypt (3.1.22) sha256=1f0072e88c2d705d94aff7f2c5cb02eb3f1ec4b8368671e19112527489f29032 bcrypt_pbkdf (1.1.2) sha256=c2414c23ce66869b3eb9f643d6a3374d8322dfb5078125c82792304c10b94cf6 bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd bindex (0.8.1) sha256=7b1ecc9dc539ed8bccfc8cb4d2732046227b09d6f37582ff12e50a5047ceb17e diff --git a/app/controllers/definicao_senhas_controller.rb b/app/controllers/definicao_senhas_controller.rb new file mode 100644 index 0000000000..96cf9ae77e --- /dev/null +++ b/app/controllers/definicao_senhas_controller.rb @@ -0,0 +1,45 @@ +class DefinicaoSenhasController < ApplicationController + def edit + @usuario = Usuario.find_by(definicao_senha_token: params[:token]) + + return if @usuario.present? + + redirect_to root_path, alert: "Link de definição de senha inválido." + end + + def update + @usuario = Usuario.find_by(definicao_senha_token: params[:token]) + + if @usuario.blank? + redirect_to root_path, alert: "Link de definição de senha inválido." + return + end + + nova_senha = params[:senha].to_s + confirmacao = params[:senha_confirmation].to_s + + if nova_senha != confirmacao + flash.now[:alert] = "Falha na definição de senha: confirmação não confere" + render :edit, status: :unprocessable_content + return + end + + if nova_senha.length < 6 + flash.now[:alert] = "Falha na definição de senha: senha inválida" + render :edit, status: :unprocessable_content + return + end + + @usuario.senha = nova_senha + @usuario.senha_confirmation = confirmacao + @usuario.definicao_senha_token = nil + @usuario.definicao_senha_sent_at = nil + + if @usuario.save + redirect_to root_path, notice: "Senha definida com sucesso." + else + flash.now[:alert] = "Falha na definição de senha: senha inválida" + render :edit, status: :unprocessable_content + end + end +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000000..95f29929ca --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,4 @@ +class HomeController < ApplicationController + def index + end +end diff --git a/app/controllers/redefinicao_senhas_controller.rb b/app/controllers/redefinicao_senhas_controller.rb new file mode 100644 index 0000000000..29534249d5 --- /dev/null +++ b/app/controllers/redefinicao_senhas_controller.rb @@ -0,0 +1,67 @@ +class RedefinicaoSenhasController < ApplicationController + def new + end + + def create + email = params[:email].to_s.strip + + if email.blank? + redirect_to redefinir_senha_path, alert: "Falha na redefinição de senha: informe seu email" + return + end + + usuario = Usuario.find_by(email: email) + + if usuario.blank? + redirect_to redefinir_senha_path, alert: "Falha na redefinição de senha: usuário não encontrado" + return + end + + usuario.enviar_email_redefinicao_senha! + redirect_to root_path, notice: "Solicitação de redefinição de senha enviada." + end + + def edit + @usuario = Usuario.find_by(redefinicao_senha_token: params[:token]) + + return if @usuario.present? + + redirect_to root_path, alert: "Link de redefinição de senha inválido." + end + + def update + @usuario = Usuario.find_by(redefinicao_senha_token: params[:token]) + + if @usuario.blank? + redirect_to root_path, alert: "Link de redefinição de senha inválido." + return + end + + nova_senha = params[:senha].to_s + confirmacao = params[:senha_confirmation].to_s + + if nova_senha != confirmacao + flash.now[:alert] = "Falha na redefinição de senha: confirmação não confere" + render :edit, status: :unprocessable_content + return + end + + if nova_senha.length < 6 + flash.now[:alert] = "Falha na redefinição de senha: senha inválida" + render :edit, status: :unprocessable_content + return + end + + @usuario.senha = nova_senha + @usuario.senha_confirmation = confirmacao + @usuario.redefinicao_senha_token = nil + @usuario.redefinicao_senha_sent_at = nil + + if @usuario.save + redirect_to root_path, notice: "Senha redefinida com sucesso." + else + flash.now[:alert] = "Falha na redefinição de senha: senha inválida" + render :edit, status: :unprocessable_content + end + end +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000000..aafb6f4339 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,44 @@ +class SessionsController < ApplicationController + def new + end + + def create + login = params[:login].to_s.strip + senha = params[:senha].to_s + + if login.blank? + redirect_to root_path, alert: "Falha no login: informe seu email ou matrícula" + return + end + + if senha.blank? + redirect_to root_path, alert: "Falha no login: informe a sua senha" + return + end + + usuario = Usuario.find_by(email: login) || Usuario.find_by(matricula: login) + + if usuario.blank? + redirect_to root_path, alert: "Falha no login: usuário não encontrado" + return + end + + unless usuario.senha_definida? + redirect_to root_path, alert: "Falha no login: usuário existente deve efetivar o seu cadastro por email" + return + end + + unless usuario.autenticar_senha(senha) + redirect_to root_path, alert: "Falha no login: senha incorreta" + return + end + + session[:usuario_id] = usuario.id + redirect_to inicio_path, notice: "Login realizado com sucesso." + end + + def destroy + reset_session + redirect_to root_path + end +end diff --git a/app/mailers/usuario_mailer.rb b/app/mailers/usuario_mailer.rb new file mode 100644 index 0000000000..f9b99925c4 --- /dev/null +++ b/app/mailers/usuario_mailer.rb @@ -0,0 +1,15 @@ +class UsuarioMailer < ApplicationMailer + def definicao_senha(usuario) + @usuario = usuario + @url = edit_definicao_senha_url(token: usuario.definicao_senha_token) + + mail(to: usuario.email, subject: "Definição de senha") + end + + def redefinicao_senha(usuario) + @usuario = usuario + @url = edit_redefinicao_senha_url(token: usuario.redefinicao_senha_token) + + mail(to: usuario.email, subject: "Redefinição de senha") + end +end diff --git a/app/models/usuario.rb b/app/models/usuario.rb index 0cae5cc929..04f128aa0c 100644 --- a/app/models/usuario.rb +++ b/app/models/usuario.rb @@ -4,4 +4,74 @@ class Usuario < ApplicationRecord validates :matricula, presence: true, uniqueness: true validates :email, presence: true, uniqueness: true validates :nome, presence: true + + attr_reader :senha + attr_accessor :senha_confirmation + + before_save :atualizar_senha_hash, if: -> { senha.present? } + validate :validar_senha, if: -> { senha.present? } + + def senha=(nova_senha) + @senha = nova_senha + end + + def senha_definida? + senha_hash.present? + end + + def autenticar_senha(tentativa) + return false if senha_hash.blank? + + BCrypt::Password.new(senha_hash) == tentativa + rescue BCrypt::Errors::InvalidHash + false + end + + def gerar_definicao_senha_token! + update!( + definicao_senha_token: SecureRandom.urlsafe_base64(32), + definicao_senha_sent_at: Time.current + ) + end + + def enviar_email_definicao_senha! + gerar_definicao_senha_token! + UsuarioMailer.definicao_senha(self).deliver_now + end + + def gerar_redefinicao_senha_token! + update!( + redefinicao_senha_token: SecureRandom.urlsafe_base64(32), + redefinicao_senha_sent_at: Time.current + ) + end + + def enviar_email_redefinicao_senha! + gerar_redefinicao_senha_token! + UsuarioMailer.redefinicao_senha(self).deliver_now + end + + def limpar_redefinicao_senha_token! + update!(redefinicao_senha_token: nil, redefinicao_senha_sent_at: nil) + end + + def limpar_definicao_senha_token! + update!(definicao_senha_token: nil, definicao_senha_sent_at: nil) + end + + private + + def validar_senha + if senha_confirmation.present? && senha != senha_confirmation + errors.add(:senha, :confirmation, message: "confirmação não confere") + end + + if senha.length < 6 + errors.add(:senha, :invalid, message: "senha inválida") + end + end + + def atualizar_senha_hash + self.senha_hash = BCrypt::Password.create(senha) + end end \ No newline at end of file diff --git a/app/views/definicao_senhas/edit.html.erb b/app/views/definicao_senhas/edit.html.erb new file mode 100644 index 0000000000..db28bdd159 --- /dev/null +++ b/app/views/definicao_senhas/edit.html.erb @@ -0,0 +1,17 @@ +

Definição de senha

+ +<%= form_with url: definicao_senha_path(token: params[:token]), method: :patch do %> +
+ <%= label_tag :senha, "Nova senha" %> + <%= password_field_tag :senha %> +
+ +
+ <%= label_tag :senha_confirmation, "Confirmar senha" %> + <%= password_field_tag :senha_confirmation %> +
+ +
+ <%= submit_tag "Definir senha" %> +
+<% end %> diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000000..605d440da6 --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1 @@ +

Página inicial

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9e51e3817f..76b583b824 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -24,6 +24,10 @@ + <% flash.each do |type, message| %> +
<%= message %>
+ <% end %> + <%= yield %> diff --git a/app/views/redefinicao_senhas/edit.html.erb b/app/views/redefinicao_senhas/edit.html.erb new file mode 100644 index 0000000000..e79c4226bb --- /dev/null +++ b/app/views/redefinicao_senhas/edit.html.erb @@ -0,0 +1,17 @@ +

Redefinição de senha

+ +<%= form_with url: redefinicao_senha_path(token: params[:token]), method: :patch do %> +
+ <%= label_tag :senha, "Nova senha" %> + <%= password_field_tag :senha %> +
+ +
+ <%= label_tag :senha_confirmation, "Confirmar senha" %> + <%= password_field_tag :senha_confirmation %> +
+ +
+ <%= submit_tag "Redefinir senha" %> +
+<% end %> diff --git a/app/views/redefinicao_senhas/new.html.erb b/app/views/redefinicao_senhas/new.html.erb new file mode 100644 index 0000000000..88c31f2ef6 --- /dev/null +++ b/app/views/redefinicao_senhas/new.html.erb @@ -0,0 +1,12 @@ +

Redefinição de senha

+ +<%= form_with url: redefinir_senha_path do %> +
+ <%= label_tag :email, "Email" %> + <%= email_field_tag :email %> +
+ +
+ <%= submit_tag "Solicitar redefinição" %> +
+<% end %> diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 0000000000..a8cceae605 --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,19 @@ +

Login

+ +<%= form_with url: login_path do %> +
+ <%= label_tag :login, "Email ou matrícula" %> + <%= text_field_tag :login %> +
+ +
+ <%= label_tag :senha, "Senha" %> + <%= password_field_tag :senha %> +
+ +
+ <%= submit_tag "Entrar" %> +
+<% end %> + +<%= button_to "Esqueci minha senha", redefinir_senha_path, method: :get %> diff --git a/app/views/usuario_mailer/definicao_senha.html.erb b/app/views/usuario_mailer/definicao_senha.html.erb new file mode 100644 index 0000000000..627179a338 --- /dev/null +++ b/app/views/usuario_mailer/definicao_senha.html.erb @@ -0,0 +1,5 @@ +

Olá, <%= @usuario.nome %>.

+ +

Para definir sua senha e acessar o sistema, acesse o link abaixo:

+ +

<%= @url %>

diff --git a/app/views/usuario_mailer/definicao_senha.text.erb b/app/views/usuario_mailer/definicao_senha.text.erb new file mode 100644 index 0000000000..37e8a1dca3 --- /dev/null +++ b/app/views/usuario_mailer/definicao_senha.text.erb @@ -0,0 +1,5 @@ +Olá, <%= @usuario.nome %>. + +Para definir sua senha e acessar o sistema, acesse o link abaixo: + +<%= @url %> diff --git a/app/views/usuario_mailer/redefinicao_senha.html.erb b/app/views/usuario_mailer/redefinicao_senha.html.erb new file mode 100644 index 0000000000..389a9c5176 --- /dev/null +++ b/app/views/usuario_mailer/redefinicao_senha.html.erb @@ -0,0 +1,5 @@ +

Olá, <%= @usuario.nome %>.

+ +

Você solicitou a redefinição da sua senha. Acesse o link abaixo:

+ +

<%= @url %>

diff --git a/app/views/usuario_mailer/redefinicao_senha.text.erb b/app/views/usuario_mailer/redefinicao_senha.text.erb new file mode 100644 index 0000000000..f874bdf5cd --- /dev/null +++ b/app/views/usuario_mailer/redefinicao_senha.text.erb @@ -0,0 +1,5 @@ +Olá, <%= @usuario.nome %>. + +Você solicitou a redefinição da sua senha. Acesse o link abaixo: + +<%= @url %> diff --git a/config/routes.rb b/config/routes.rb index 20f16c622c..3b3d21a89c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,18 @@ Rails.application.routes.draw do + root "sessions#new" + + get "/inicio", to: "home#index", as: :inicio + post "/login", to: "sessions#create", as: :login + delete "/logout", to: "sessions#destroy", as: :logout + + get "/definir_senha/:token", to: "definicao_senhas#edit", as: :edit_definicao_senha + patch "/definir_senha/:token", to: "definicao_senhas#update", as: :definicao_senha + + get "/redefinir_senha", to: "redefinicao_senhas#new", as: :redefinir_senha + post "/redefinir_senha", to: "redefinicao_senhas#create" + get "/redefinir_senha/:token", to: "redefinicao_senhas#edit", as: :edit_redefinicao_senha + patch "/redefinir_senha/:token", to: "redefinicao_senhas#update", as: :redefinicao_senha + resources :resposta_elems resources :resposta_forms resources :campo_forms diff --git a/db/migrate/20260601120000_add_definicao_senha_to_usuarios.rb b/db/migrate/20260601120000_add_definicao_senha_to_usuarios.rb new file mode 100644 index 0000000000..8a8f0ed497 --- /dev/null +++ b/db/migrate/20260601120000_add_definicao_senha_to_usuarios.rb @@ -0,0 +1,8 @@ +class AddDefinicaoSenhaToUsuarios < ActiveRecord::Migration[8.1] + def change + add_column :usuarios, :definicao_senha_token, :string + add_column :usuarios, :definicao_senha_sent_at, :datetime + + add_index :usuarios, :definicao_senha_token, unique: true + end +end diff --git a/db/migrate/20260602090000_add_redefinicao_senha_to_usuarios.rb b/db/migrate/20260602090000_add_redefinicao_senha_to_usuarios.rb new file mode 100644 index 0000000000..11ab0be88e --- /dev/null +++ b/db/migrate/20260602090000_add_redefinicao_senha_to_usuarios.rb @@ -0,0 +1,8 @@ +class AddRedefinicaoSenhaToUsuarios < ActiveRecord::Migration[8.1] + def change + add_column :usuarios, :redefinicao_senha_token, :string + add_column :usuarios, :redefinicao_senha_sent_at, :datetime + + add_index :usuarios, :redefinicao_senha_token, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 79f6d96e13..d039b4be04 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_05_28_002258) do +ActiveRecord::Schema[8.1].define(version: 2026_06_02_090000) do create_table "campo_forms", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.datetime "created_at", null: false t.bigint "elemento_form_id", null: false @@ -134,17 +134,23 @@ create_table "usuarios", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.datetime "created_at", null: false t.bigint "curso_id" + t.datetime "definicao_senha_sent_at" + t.string "definicao_senha_token" t.bigint "departamento_id" t.string "email" t.string "formacao" t.string "matricula" t.string "nome" + t.datetime "redefinicao_senha_sent_at" + t.string "redefinicao_senha_token" t.string "senha_hash" t.string "type" t.datetime "updated_at", null: false t.index ["curso_id"], name: "index_usuarios_on_curso_id" + t.index ["definicao_senha_token"], name: "index_usuarios_on_definicao_senha_token", unique: true t.index ["departamento_id"], name: "index_usuarios_on_departamento_id" t.index ["matricula"], name: "index_usuarios_on_matricula", unique: true + t.index ["redefinicao_senha_token"], name: "index_usuarios_on_redefinicao_senha_token", unique: true end add_foreign_key "campo_forms", "elemento_forms" diff --git a/features/step_definitions/cadastro_steps.rb b/features/step_definitions/cadastro_steps.rb index de5fe32d6e..64f06b8b6f 100644 --- a/features/step_definitions/cadastro_steps.rb +++ b/features/step_definitions/cadastro_steps.rb @@ -7,10 +7,13 @@ # implementar a partir da feature de importar dados end -Então('o e-mail de usuário {string} está cadastrado no sistema com senha indefinida') do |email| - # implementar quando definir models -end - Então('um email de definição de senha é enviado para o email {string}') do |email| - # implementar quando definir models (vai ser um método do model) + usuario = Usuario.find_by!(email: email) + ActionMailer::Base.deliveries.clear + usuario.enviar_email_definicao_senha! + + @email_destino = email + + enviados = ActionMailer::Base.deliveries.select { |m| m.to == [email] } + expect(enviados).not_to be_empty end \ No newline at end of file diff --git a/features/step_definitions/criar_formulario_steps.rb b/features/step_definitions/criar_formulario_steps.rb index f30c817a7e..4df517218c 100644 --- a/features/step_definitions/criar_formulario_steps.rb +++ b/features/step_definitions/criar_formulario_steps.rb @@ -26,6 +26,7 @@ end Quando('eu clico em {string}') do |nome_botao| + visit root_path unless page.has_button?(nome_botao) click_button nome_botao end diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index 213109e6e0..db564f532e 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -1,41 +1,59 @@ Dado('que meu usuário está cadastrado com o email {string}') do |email| - # Implementar quando definir models + Usuario.find_or_create_by!(email: email) do |u| + u.matricula = "#{rand(100000..999999)}" + u.nome = "Usuário Teste" + end end Dado('que meu email {string} não está cadastrado no sistema') do |email| - # Implementar quando definir models + Usuario.where(email: email).delete_all end Dado('que meu usuário está cadastrado com o email {string} e senha {string}') do |email, senha| - # Implementar quando definir models + usuario = Usuario.find_or_initialize_by(email: email) + usuario.matricula ||= "#{rand(100000..999999)}" + usuario.nome ||= "Usuário Teste" + usuario.senha = senha + usuario.senha_confirmation = senha + usuario.save! end Dado('que minha matrícula {string} está cadastrada no sistema e senha {string}') do |matricula, senha| - # Implementar quando definir models + usuario = Usuario.find_or_initialize_by(matricula: matricula) + usuario.email ||= "#{matricula}@teste.com" + usuario.nome ||= "Usuário Teste" + usuario.senha = senha + usuario.senha_confirmation = senha + usuario.save! end Dado('que minha senha para {string} não está definida') do |email| - # Implementar quando definir models + usuario = Usuario.find_by!(email: email) + usuario.update!(senha_hash: nil) end Quando('eu tento realizar o login com o email {string} e a senha {string}') do |email_usuario, senha_usuario| + visit root_path fill_in "login", with: email_usuario fill_in "senha", with: senha_usuario click_button "Entrar" end Quando('eu tento realizar o login com matrícula {string} e a senha {string}') do |matricula_usuario, senha_usuario| + visit root_path fill_in "login", with: matricula_usuario fill_in "senha", with: senha_usuario click_button "Entrar" end Quando('eu tento realizar o login sem informar meu email ou matrícula e com senha {string}') do |senha_usuario| + visit root_path fill_in "senha", with: senha_usuario click_button "Entrar" end Quando('eu tento realizar o login com email {string} sem informar minha senha') do |email_usuario| + visit root_path fill_in "login", with: email_usuario click_button "Entrar" end diff --git a/features/step_definitions/senha_steps.rb b/features/step_definitions/senha_steps.rb new file mode 100644 index 0000000000..51cd2b2ee7 --- /dev/null +++ b/features/step_definitions/senha_steps.rb @@ -0,0 +1,76 @@ +Dado('que o e-mail de usuário {string} está cadastrado no sistema com senha indefinida') do |email| + usuario = Usuario.find_or_initialize_by(email: email) + usuario.matricula ||= "#{rand(100000..999999)}" + usuario.nome ||= "Usuário Teste" + usuario.senha_hash = nil + usuario.save! +end + +Quando('eu acesso o link de definição de senha recebido por e-mail') do + email_destino = @email_destino || raise("Email de destino não definido nos steps") + + mensagem = ActionMailer::Base.deliveries.reverse.find { |m| m.to == [email_destino] } + raise("Nenhum email enviado para #{email_destino}") if mensagem.nil? + + corpo = mensagem.text_part&.body&.decoded || mensagem.html_part&.body&.decoded || mensagem.body.decoded + url = corpo[%r{https?://\S+}] + raise("Não encontrei URL no email") if url.nil? + + visit url +end + +Quando('eu informo a nova senha {string} e confirmo a senha {string}') do |senha, confirmacao| + fill_in "senha", with: senha + fill_in "senha_confirmation", with: confirmacao +end + +Quando('eu confirmo a definição de senha') do + click_button "Definir senha" +end + +Quando('eu informo o email {string}') do |email| + fill_in "email", with: email +end + +Quando('eu solicito a redefinição de senha') do + click_button "Solicitar redefinição" +end + +Quando('eu solicito a redefinição de senha sem informar meu email') do + click_button "Solicitar redefinição" +end + +Então('um email de redefinição de senha é enviado para o email {string}') do |email| + usuario = Usuario.find_by!(email: email) + ActionMailer::Base.deliveries.clear + usuario.enviar_email_redefinicao_senha! + + @email_destino = email + + enviados = ActionMailer::Base.deliveries.select { |m| m.to == [email] } + expect(enviados).not_to be_empty +end + +Dado('que eu solicitei a redefinição de senha para o email {string}') do |email| + usuario = Usuario.find_by!(email: email) + ActionMailer::Base.deliveries.clear + usuario.enviar_email_redefinicao_senha! + @email_destino = email +end + +Quando('eu acesso o link de redefinição de senha recebido por e-mail') do + email_destino = @email_destino || raise("Email de destino não definido nos steps") + + mensagem = ActionMailer::Base.deliveries.reverse.find { |m| m.to == [email_destino] } + raise("Nenhum email enviado para #{email_destino}") if mensagem.nil? + + corpo = mensagem.text_part&.body&.decoded || mensagem.html_part&.body&.decoded || mensagem.body.decoded + url = corpo[%r{https?://\S+}] + raise("Não encontrei URL no email") if url.nil? + + visit url +end + +Quando('eu confirmo a redefinição de senha') do + click_button "Redefinir senha" +end From 60ef476793566c38594145596acaf9feb85eb4bc Mon Sep 17 00:00:00 2001 From: Liferoijrm Date: Sat, 6 Jun 2026 02:33:44 -0300 Subject: [PATCH 16/55] =?UTF-8?q?:sparkles:feat:=20estiliza=C3=A7=C3=A3o?= =?UTF-8?q?=20com=20CSS=20e=20Seeds=20para=20o=20banco?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/login.css | 94 ++++++++++++++++++ app/assets/stylesheets/redefinir_senha.css | 83 ++++++++++++++++ app/models/discente.rb | 2 +- app/models/docente.rb | 2 +- app/models/turma.rb | 4 +- app/views/redefinicao_senhas/new.html.erb | 25 +++-- app/views/sessions/new.html.erb | 39 +++++--- config/database.yml | 2 +- db/seeds.rb | 106 +++++++++++++++++++-- 9 files changed, 320 insertions(+), 37 deletions(-) create mode 100644 app/assets/stylesheets/login.css create mode 100644 app/assets/stylesheets/redefinir_senha.css diff --git a/app/assets/stylesheets/login.css b/app/assets/stylesheets/login.css new file mode 100644 index 0000000000..a22f4ec6bf --- /dev/null +++ b/app/assets/stylesheets/login.css @@ -0,0 +1,94 @@ +body { + background: #efefef; + margin: 0; + font-family: Arial, sans-serif; +} + +.login-container { + width: 90%; + max-width: 1100px; + height: 500px; + + margin: 40px auto; + + display: flex; + + background: white; + border-radius: 10px; + + overflow: hidden; +} + +.login-form { + flex: 1; + + display: flex; + flex-direction: column; + justify-content: center; + + padding: 50px; +} + +.login-form h1 { + text-align: center; + margin-bottom: 40px; +} + +.field { + margin-bottom: 20px; +} + +.field label { + display: block; + margin-bottom: 8px; +} + +.field input { + width: 100%; + box-sizing: border-box; + + padding: 12px; + + border: 1px solid #ccc; + border-radius: 6px; +} + +.btn-login { + width: 100%; + + padding: 12px; + + border: none; + border-radius: 6px; + + background: #2ecc71; + color: white; + + cursor: pointer; + + font-size: 16px; +} + +.btn-login:hover { + opacity: 0.9; +} + +.btn-forgot { + margin-top: 15px; +} + +.login-banner { + flex: 1; + + background: #6d1f6d; + + display: flex; + justify-content: center; + align-items: center; +} + +.login-banner h2 { + color: white; + text-align: center; + font-size: 4rem; +} \ No newline at end of file diff --git a/app/assets/stylesheets/redefinir_senha.css b/app/assets/stylesheets/redefinir_senha.css new file mode 100644 index 0000000000..893bc54580 --- /dev/null +++ b/app/assets/stylesheets/redefinir_senha.css @@ -0,0 +1,83 @@ +html, +body { + margin: 0; + padding: 0; + height: 100%; + font-family: Arial, Helvetica, sans-serif; + background-color: #f5f5f5; +} + +.password-reset-container { + height: 100vh; + + display: flex; + justify-content: center; + align-items: center; +} + +.password-reset-box { + width: 100%; + max-width: 450px; + + background: white; + + padding: 40px; + + border-radius: 10px; + + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); + + box-sizing: border-box; +} + +.password-reset-box h1 { + text-align: center; + + margin-top: 0; + margin-bottom: 30px; + + font-size: 2rem; + font-weight: normal; +} + +.field { + display: flex; + flex-direction: column; + + margin-bottom: 20px; +} + +.field label { + margin-bottom: 8px; +} + +.field input { + padding: 12px; + + border: 1px solid #d0d0d0; + border-radius: 6px; + + font-size: 1rem; + box-sizing: border-box; +} + +.btn-submit { + width: 100%; + + padding: 12px; + + border: none; + border-radius: 6px; + + background-color: #6e1f69; + color: white; + + font-size: 1rem; + font-weight: bold; + + cursor: pointer; +} + +.btn-submit:hover { + opacity: 0.9; +} \ No newline at end of file diff --git a/app/models/discente.rb b/app/models/discente.rb index d06b0b7772..d76084e48a 100644 --- a/app/models/discente.rb +++ b/app/models/discente.rb @@ -1,4 +1,4 @@ class Discente < Usuario validates :curso_id, presence: true - has_and_belongs_to_many :turmas + has_and_belongs_to_many :turmas, join_table: "discentes_turmas" end \ No newline at end of file diff --git a/app/models/docente.rb b/app/models/docente.rb index bd48475299..8c670c642b 100644 --- a/app/models/docente.rb +++ b/app/models/docente.rb @@ -1,4 +1,4 @@ class Docente < Usuario validates :formacao, presence: true - has_and_belongs_to_many :turmas + has_and_belongs_to_many :turmas, join_table: "docentes_turmas" end \ No newline at end of file diff --git a/app/models/turma.rb b/app/models/turma.rb index e189be5359..6015166c43 100644 --- a/app/models/turma.rb +++ b/app/models/turma.rb @@ -1,8 +1,8 @@ class Turma < ApplicationRecord belongs_to :disciplina has_many :formularios, dependent: :destroy - has_and_belongs_to_many :discentes - has_and_belongs_to_many :docentes + has_and_belongs_to_many :discentes, join_table: "discentes_turmas" + has_and_belongs_to_many :docentes, join_table: "docentes_turmas" validates :numero_da_turma, presence: true, uniqueness: { scope: [:semestre, :disciplina_id], diff --git a/app/views/redefinicao_senhas/new.html.erb b/app/views/redefinicao_senhas/new.html.erb index 88c31f2ef6..e7234e77f1 100644 --- a/app/views/redefinicao_senhas/new.html.erb +++ b/app/views/redefinicao_senhas/new.html.erb @@ -1,12 +1,19 @@ -

Redefinição de senha

+
+
-<%= form_with url: redefinir_senha_path do %> -
- <%= label_tag :email, "Email" %> - <%= email_field_tag :email %> -
+

Redefinição de senha

+ + <%= form_with url: redefinir_senha_path do %> + +
+ <%= label_tag :email, "Email" %> + <%= email_field_tag :email %> +
+ + <%= submit_tag "Solicitar redefinição", + class: "btn-submit" %> + + <% end %> -
- <%= submit_tag "Solicitar redefinição" %>
-<% end %> +
\ No newline at end of file diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index a8cceae605..8f93b2236a 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,19 +1,30 @@ -

Login

+ diff --git a/config/routes.rb b/config/routes.rb index 3f7eb9e566..b74480f44e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,6 +21,7 @@ get "up" => "rails/health#show", as: :rails_health_check get "admin", to: "admin#index", as: :admin post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa + post "admin/atualizar_sigaa", to: "admin#atualizar_sigaa", as: :atualizar_sigaa # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest From 8391c3c45d55d37cae5a4e944378542da01100b1 Mon Sep 17 00:00:00 2001 From: neatzzy Date: Sat, 6 Jun 2026 09:18:59 -0300 Subject: [PATCH 19/55] =?UTF-8?q?:test=5Ftube:=20test:=20BDD=20cucumber=20?= =?UTF-8?q?da=20funcionalidade=20de=20atualiza=C3=A7=C3=A3o=20com=20dados?= =?UTF-8?q?=20do=20SIGAA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 4 +- .../atualizar_dados_sigaa_steps.rb | 41 +++++++++++++++++++ .../importar_dados_sigaa_steps.rb | 2 +- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 features/step_definitions/atualizar_dados_sigaa_steps.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 55fcf87194..00fbc30f2c 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -22,12 +22,12 @@ def atualizar_sigaa resultado = SigaaImporter.update_from_files("classes.json", "members.json") case resultado - when /atualiza/i - redirect_to admin_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." when /alguns dados/i redirect_to admin_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" when /já estão atualizados/i redirect_to admin_path, alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" + when /atualiza/i + redirect_to admin_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." else redirect_to admin_path, alert: "erro informando que a atualização falhou" end diff --git a/features/step_definitions/atualizar_dados_sigaa_steps.rb b/features/step_definitions/atualizar_dados_sigaa_steps.rb new file mode 100644 index 0000000000..493818ef95 --- /dev/null +++ b/features/step_definitions/atualizar_dados_sigaa_steps.rb @@ -0,0 +1,41 @@ +# Reutilizar o gerenciamento de paginas dos outros steps + +Dado('que os dados do SIGAA foram atualizados com sucesso') do + allow(SigaaImporter).to receive(:update_from_files).and_return("atualização realizada com sucesso") + page.driver.post(atualizar_sigaa_path) + visit admin_path +end + +Dado('que eu tentei atualizar os dados do SIGAA mas ocorreu um erro') do + allow(SigaaImporter).to receive(:update_from_files).and_return("falha") + page.driver.post(atualizar_sigaa_path) + visit admin_path +end + +Dado('que os dados do SIGAA já estão atualizados na base de dados do sistema') do + allow(SigaaImporter).to receive(:update_from_files).and_return("os dados do SIGAA já estão atualizados e não serão atualizados novamente") + page.driver.post(atualizar_sigaa_path) + visit admin_path +end + +Dado('que alguns dados do SIGAA já estão atualizados na base de dados do sistema') do + allow(SigaaImporter).to receive(:update_from_files).and_return("alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso") + page.driver.post(atualizar_sigaa_path) + visit admin_path +end + +Então('as turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA') do + expect(page).to have_content('As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA.') +end + +Então('uma mensagem de erro é exibida informando que a atualização falhou') do + expect(page).to have_content('erro informando que a atualização falhou') +end + +Então('uma mensagem é exibida informando que os dados já estão atualizados e não serão atualizados novamente') do + expect(page).to have_content('os dados do SIGAA já estão atualizados e não serão atualizados novamente') +end + +Então('uma mensagem é exibida informando que alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso') do + expect(page).to have_content('alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso') +end diff --git a/features/step_definitions/importar_dados_sigaa_steps.rb b/features/step_definitions/importar_dados_sigaa_steps.rb index 3bf2146cd1..dde28c469f 100644 --- a/features/step_definitions/importar_dados_sigaa_steps.rb +++ b/features/step_definitions/importar_dados_sigaa_steps.rb @@ -1,7 +1,7 @@ Dado('que os dados do SIGAA estão disponíveis para importação') do - # By default, let the importer work normally; specific scenarios will stub its return. + # Por padrão, o SigaaImporter importará os dados dos arquivos "classes.json" e "members.json", então não é necessário configurar nada aqui para simular a disponibilidade dos dados do SIGAA. end Dado('que os dados do SIGAA foram importados com sucesso') do From df483079acb8ae92208eddec0307f09c0ec3d18c Mon Sep 17 00:00:00 2001 From: neatzzy Date: Sat, 6 Jun 2026 09:24:03 -0300 Subject: [PATCH 20/55] :recycle: refactor: removida a dependencia do sqlite --- Gemfile | 1 - Gemfile.lock | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/Gemfile b/Gemfile index f0d7bf40b5..c8d2dce83a 100644 --- a/Gemfile +++ b/Gemfile @@ -66,6 +66,5 @@ group :test do gem "selenium-webdriver" gem "cucumber-rails", require: false gem "database_cleaner" - gem "sqlite3", ">= 2.1" gem "rspec-rails" end diff --git a/Gemfile.lock b/Gemfile.lock index 84e9e94176..56c83cb28b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -387,13 +387,6 @@ GEM fugit (~> 1.11) railties (>= 7.1) thor (>= 1.3.1) - sqlite3 (2.9.4-aarch64-linux-gnu) - sqlite3 (2.9.4-aarch64-linux-musl) - sqlite3 (2.9.4-arm-linux-gnu) - sqlite3 (2.9.4-arm-linux-musl) - sqlite3 (2.9.4-x64-mingw-ucrt) - sqlite3 (2.9.4-x86_64-linux-gnu) - sqlite3 (2.9.4-x86_64-linux-musl) sshkit (1.25.0) base64 logger @@ -476,7 +469,6 @@ DEPENDENCIES solid_cable solid_cache solid_queue - sqlite3 (>= 2.1) stimulus-rails thruster turbo-rails @@ -621,13 +613,6 @@ CHECKSUMS solid_cable (3.0.12) sha256=a168a54731a455d5627af48d8441ea3b554b8c1f6e6cd6074109de493e6b0460 solid_cache (1.0.10) sha256=bc05a2fb3ac78a6f43cbb5946679cf9db67dd30d22939ededc385cb93e120d41 solid_queue (1.4.0) sha256=e6a18d196f0b27cb6e3c77c5b31258b05fb634f8ed64fb1866ed164047216c2a - sqlite3 (2.9.4-aarch64-linux-gnu) sha256=ecabed721e6eaad54601d2685f09029d90025efc8d931040dc89cb3f8a2080ec - sqlite3 (2.9.4-aarch64-linux-musl) sha256=ffb4255947fb54c8c3eeca97460c9702b40de91ce390455ef7367ca6a3929a31 - sqlite3 (2.9.4-arm-linux-gnu) sha256=9ee2008b9fbec984c3c165b0d7eedd2bd2a415100b761bfa3a4c6fbec9208bf6 - sqlite3 (2.9.4-arm-linux-musl) sha256=8dc1fe4da6977992cd62decf4a93ccf6cc2e124a5e6a340160d52092f70e837a - sqlite3 (2.9.4-x64-mingw-ucrt) sha256=40997c549b19e2fdfcc5e271f6bdd4d502179742c0bfd678da23d0d09b929848 - sqlite3 (2.9.4-x86_64-linux-gnu) sha256=537a3eda71b1df1336d0055cbebe55a7317c34870c192c7b6b9d8d0be6871847 - sqlite3 (2.9.4-x86_64-linux-musl) sha256=3fc5e865b4be9a85d998203ef8d0c0fdcb92f20acf34a254346ff8a19088efec sshkit (1.25.0) sha256=c8c6543cdb60f91f1d277306d585dd11b6a064cb44eab0972827e4311ff96744 stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06 stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1 From a4b84e9d88c56e3faa6ce3010382b5fa42583b04 Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Thu, 11 Jun 2026 09:19:56 -0300 Subject: [PATCH 21/55] config-database --- config/database.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/database.yml b/config/database.yml index 584ff3f93d..63ad6ca8d5 100644 --- a/config/database.yml +++ b/config/database.yml @@ -13,8 +13,8 @@ default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - username: root - password: <%= ENV["CAMAAR_DATABASE_PASSWORD"] %> + username: camaar + password: senha_do_camaar socket: /var/run/mysqld/mysqld.sock development: From 55b9e9c5e0f87f7a8622e211c9edcaa777558029 Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Thu, 11 Jun 2026 10:35:35 -0300 Subject: [PATCH 22/55] feat: admin page --- app/assets/stylesheets/gerenciamento.css | 165 +++++++++++++++++++++++ app/controllers/admin_controller.rb | 25 ++-- app/views/admin/avaliacoes.html.erb | 3 + app/views/admin/gerenciamento.html.erb | 18 +++ app/views/admin/index.html.erb | 8 -- app/views/layouts/gerenciamento.html.erb | 57 ++++++++ config/routes.rb | 8 +- 7 files changed, 264 insertions(+), 20 deletions(-) create mode 100644 app/assets/stylesheets/gerenciamento.css create mode 100644 app/views/admin/avaliacoes.html.erb create mode 100644 app/views/admin/gerenciamento.html.erb delete mode 100644 app/views/admin/index.html.erb create mode 100644 app/views/layouts/gerenciamento.html.erb diff --git a/app/assets/stylesheets/gerenciamento.css b/app/assets/stylesheets/gerenciamento.css new file mode 100644 index 0000000000..dcc3bff573 --- /dev/null +++ b/app/assets/stylesheets/gerenciamento.css @@ -0,0 +1,165 @@ + +body, html { + margin: 0; + padding: 0; + height: 100vh; + font-family: 'Roboto', 'Poppins', sans-serif; + background: #DBDBDB; +} + +.admin-container { + display: flex; + flex-direction: column; + height: 100vh; + overflow: hidden; +} + +.admin-header { + height: 60px; + min-height: 60px; + background: #FFFFFF; + box-shadow: 0px 11px 10.7px rgba(0, 0, 0, 0.05); + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 20px; + z-index: 10; +} + +.header-left, .header-right { + display: flex; + align-items: center; + gap: 24px; +} + +.tab-name { + font-size: 24px; + font-weight: 400; + color: #000000; + margin: 0; +} + +.search-container { + width: 271px; + height: 40px; + border: 1px solid #8E8E8E; + border-radius: 47px; + display: flex; + align-items: center; + padding: 0 15px; + box-sizing: border-box; +} + +.search-input { + border: none; + background: transparent; + outline: none; + width: 100%; + font-family: 'Roboto', sans-serif; + font-size: 14px; +} + +.user-avatar { + width: 44px; + height: 44px; + background: #6C2365; + border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; + color: #FFFFFF; + font-size: 24px; + font-weight: 500; +} + +.admin-body { + display: flex; + flex: 1; + overflow: hidden; +} + +.admin-sidebar { + width: 257px; + min-width: 257px; + background: #FFFFFF; + display: flex; + flex-direction: column; + border-right: 1px solid #D9D9D9; + padding-top: 10px; +} + +.menu-item { + height: 46px; + display: flex; + justify-content: center; + align-items: center; + border-bottom: 1px solid #D9D9D9; + text-decoration: none; + color: #000000; + font-size: 16px; +} + +.menu-item.active { + background: #6C2365; + color: #FFFFFF; +} + +.admin-content { + flex: 1; + background: #DBDBDB; + padding: 25px 43px; + display: flex; + flex-direction: column; + align-items: center; + gap: 50px; + overflow-y: auto; +} + +.figma-card { + width: 462px; + height: 655px; + background: #FFFFFF; + border-radius: 8px; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: center; + padding-top: 40px; + gap: 15px; +} + +.btn-figma { + width: 302px; + height: 43px; + display: flex; + justify-content: center; + align-items: center; + border-radius: 6px; + font-family: 'Poppins', sans-serif; + font-weight: 500; + font-size: 16px; + text-decoration: none; + border: none; + cursor: pointer; + box-shadow: 0px 1px 2px rgba(105, 81, 255, 0.05); + background: #86EFAC; + color: #1e1e1e; + transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out; +} + +.btn-figma:hover { + background: #22C55E; + color: #F0FDF4; +} + +.flash-message.notice { + background-color: #d1fae5; + color: #065f46; + border: 1px solid #10b981; +} + +.flash-message.alert { + background-color: #fee2e2; + color: #991b1b; + border: 1px solid #ef4444; +} \ No newline at end of file diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 00fbc30f2c..28a58e2872 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,6 +1,11 @@ class AdminController < ApplicationController - def index - # Renderiza a página com os botões de Importar e Atualizar + layout 'gerenciamento' + + def gerenciamento + @templates = Template.all + end + + def avaliacoes end def importar_sigaa @@ -8,13 +13,13 @@ def importar_sigaa case resultado when /sucesso/i - redirect_to admin_path, notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." + redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." when /alguns dados/i - redirect_to admin_path, notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" + redirect_to admin_gerenciamento_path, notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" when /já existem/i - redirect_to admin_path, alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" + redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" else - redirect_to admin_path, alert: "erro informando que a importação falhou" + redirect_to admin_gerenciamento_path, alert: "erro informando que a importação falhou" end end @@ -23,13 +28,13 @@ def atualizar_sigaa case resultado when /alguns dados/i - redirect_to admin_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" + redirect_to admin_gerenciamento_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" when /já estão atualizados/i - redirect_to admin_path, alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" + redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" when /atualiza/i - redirect_to admin_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." + redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." else - redirect_to admin_path, alert: "erro informando que a atualização falhou" + redirect_to admin_gerenciamento_path, alert: "erro informando que a atualização falhou" end end end diff --git a/app/views/admin/avaliacoes.html.erb b/app/views/admin/avaliacoes.html.erb new file mode 100644 index 0000000000..fd3f3db2ab --- /dev/null +++ b/app/views/admin/avaliacoes.html.erb @@ -0,0 +1,3 @@ +
+

Teste

+
\ No newline at end of file diff --git a/app/views/admin/gerenciamento.html.erb b/app/views/admin/gerenciamento.html.erb new file mode 100644 index 0000000000..3ccc50c2ff --- /dev/null +++ b/app/views/admin/gerenciamento.html.erb @@ -0,0 +1,18 @@ +
+ +

+ Sincronização +

+ + <%= button_to "Importar dados do SIGAA", importar_sigaa_path, method: :post, class: "btn-figma" %> + + <%= button_to "Atualizar dados do SIGAA", atualizar_sigaa_path, method: :post, class: "btn-figma" %> + + <%= button_to "Editar Template", importar_sigaa_path, method: :post, class: "btn-figma" %> + + <%= button_to "Enviar Formulários", atualizar_sigaa_path, method: :post, class: "btn-figma" %> + + <%= button_to "Resultados", importar_sigaa_path, method: :post, class: "btn-figma" %> + + +
\ No newline at end of file diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb deleted file mode 100644 index 15865b2adb..0000000000 --- a/app/views/admin/index.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -
-

Ações de Importação SIGAA

- -
- <%= button_to "Importar dados do SIGAA", importar_sigaa_path, method: :post, class: "btn btn-primary" %> - <%= button_to "Atualizar com dados do SIGAA", atualizar_sigaa_path, method: :post, class: "btn btn-secondary" %> -
-
diff --git a/app/views/layouts/gerenciamento.html.erb b/app/views/layouts/gerenciamento.html.erb new file mode 100644 index 0000000000..3c2abe2174 --- /dev/null +++ b/app/views/layouts/gerenciamento.html.erb @@ -0,0 +1,57 @@ + + + + CAMAAR - Gerenciamento + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + <%= stylesheet_link_tag "gerenciamento", "data-turbo-track": "reload" %> + + + +
+ +
+
+

Visão Geral

+
+
+ +
+ +
+ +
U
+
+
+ +
+ + + +
+ <% flash.each do |type, message| %> +
+ <%= message %> +
+ <% end %> + <%= yield %> +
+ +
+
+ + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b465569b9e..7ce6ec51a2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,11 +32,15 @@ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. - get "up" => "rails/health#show", as: :rails_health_check - get "admin", to: "admin#index", as: :admin + get "/admin", to: redirect("/admin/avaliacoes") + + get "/admin/gerenciamento", to: "admin#gerenciamento", as: :admin_gerenciamento + get "/admin/avaliacoes", to: "admin#avaliacoes", as: :admin_avaliacoes + post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa post "admin/atualizar_sigaa", to: "admin#atualizar_sigaa", as: :atualizar_sigaa + get "up" => "rails/health#show", as: :rails_health_check # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest # get "service-worker" => "rails/pwa#service_worker", as: :pwa_service_worker From 7672a95b4908d2281e3c03c964373576f23cfc93 Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Thu, 11 Jun 2026 11:10:09 -0300 Subject: [PATCH 23/55] feat: teamplate page --- app/assets/images/icons/create.svg | 3 + app/assets/images/icons/edit.svg | 3 + app/assets/images/icons/trash.svg | 3 + app/assets/stylesheets/gerenciamento.css | 79 ++++++++++++++++++++++++ app/controllers/admin_controller.rb | 8 ++- app/helpers/application_helper.rb | 9 +++ app/views/admin/gerenciamento.html.erb | 2 +- app/views/admin/templates.html.erb | 19 ++++++ app/views/layouts/gerenciamento.html.erb | 5 +- config/routes.rb | 3 +- 10 files changed, 127 insertions(+), 7 deletions(-) create mode 100644 app/assets/images/icons/create.svg create mode 100644 app/assets/images/icons/edit.svg create mode 100644 app/assets/images/icons/trash.svg create mode 100644 app/views/admin/templates.html.erb diff --git a/app/assets/images/icons/create.svg b/app/assets/images/icons/create.svg new file mode 100644 index 0000000000..117c7630c8 --- /dev/null +++ b/app/assets/images/icons/create.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/assets/images/icons/edit.svg b/app/assets/images/icons/edit.svg new file mode 100644 index 0000000000..275fa03b2b --- /dev/null +++ b/app/assets/images/icons/edit.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/assets/images/icons/trash.svg b/app/assets/images/icons/trash.svg new file mode 100644 index 0000000000..28e3f31b34 --- /dev/null +++ b/app/assets/images/icons/trash.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/assets/stylesheets/gerenciamento.css b/app/assets/stylesheets/gerenciamento.css index dcc3bff573..e2049f702e 100644 --- a/app/assets/stylesheets/gerenciamento.css +++ b/app/assets/stylesheets/gerenciamento.css @@ -162,4 +162,83 @@ body, html { background-color: #fee2e2; color: #991b1b; border: 1px solid #ef4444; +} + +.templates-grid { + display: grid; + grid-template-columns: repeat(auto-fill, 278px); + gap: 50px; + padding: 25px 43px; + width: 100%; + justify-content: flex-start; +} + +.card { + width: 278px; + height: 82px; + background: #FFFFFF; + border-radius: 8px; + padding: 24px; + display: flex; + justify-content: space-between; + align-items: center; + box-sizing: border-box; +} + +.template-title { + font-family: 'Roboto', sans-serif; + font-size: 24px; + font-weight: 500; + margin: 0; + color: #000000; +} + +.template-semester { + font-family: 'Roboto', sans-serif; + font-size: 16px; + font-weight: 400; + margin: 5px 0 0 0; + color: #000000; +} + +.card-actions { + display: flex; + gap: 10px; +} + +.action-btn { + background: none; + border: none; + cursor: pointer; + font-size: 16px; +} + +.card-create-new { + width: 278px; + height: 82px; + background: #FFFFFF; + border-radius: 8px; + display: flex; + justify-content: center; + align-items: center; + text-decoration: none; + color: #000; + border: 2px dashed #000000; + box-sizing: border-box; +} + +.plus-icon { + font-size: 30px; + font-weight: bold; +} + +.icon-wrapper svg { + width: 14px; + height: 14px; + fill: #000000; + transition: fill 0.2s; +} + +.action-btn:hover .icon-wrapper svg { + fill: #6C2365; } \ No newline at end of file diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 28a58e2872..3e6489ae82 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,13 +1,17 @@ class AdminController < ApplicationController layout 'gerenciamento' + def avaliacoes + end + def gerenciamento - @templates = Template.all end - def avaliacoes + def templates + @templates = Template.all end + def importar_sigaa resultado = SigaaImporter.import_from_files("classes.json", "members.json") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be7945c..9667b0963d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,11 @@ module ApplicationHelper + def svg_icon(name, options = {}) + file_path = Rails.root.join('app', 'assets', 'images', 'icons', "#{name}.svg") + if File.exist?(file_path) + svg = File.read(file_path).html_safe + content_tag(:span, svg, options.merge(class: "icon-wrapper #{options[:class]}")) + else + "(ícone não encontrado)" + end + end end diff --git a/app/views/admin/gerenciamento.html.erb b/app/views/admin/gerenciamento.html.erb index 3ccc50c2ff..4cd1795094 100644 --- a/app/views/admin/gerenciamento.html.erb +++ b/app/views/admin/gerenciamento.html.erb @@ -8,7 +8,7 @@ <%= button_to "Atualizar dados do SIGAA", atualizar_sigaa_path, method: :post, class: "btn-figma" %> - <%= button_to "Editar Template", importar_sigaa_path, method: :post, class: "btn-figma" %> + <%= link_to "Editar Template", admin_templates_path, class: "btn-figma" %> <%= button_to "Enviar Formulários", atualizar_sigaa_path, method: :post, class: "btn-figma" %> diff --git a/app/views/admin/templates.html.erb b/app/views/admin/templates.html.erb new file mode 100644 index 0000000000..63a974bc6a --- /dev/null +++ b/app/views/admin/templates.html.erb @@ -0,0 +1,19 @@ +
+ <% @templates.each do |template| %> +
+
+

<%= template.nome %>

+

Semestre: N/A

+
+ +
+ <%= link_to svg_icon('edit', class: 'icon-edit'), "#", class: "action-btn" %> + <%= link_to svg_icon('trash', class: 'icon-delete'), "#", class: "action-btn" %> +
+
+ <% end %> + + +
+
+
+
\ No newline at end of file diff --git a/app/views/layouts/gerenciamento.html.erb b/app/views/layouts/gerenciamento.html.erb index 3c2abe2174..e9c6234870 100644 --- a/app/views/layouts/gerenciamento.html.erb +++ b/app/views/layouts/gerenciamento.html.erb @@ -30,14 +30,13 @@
diff --git a/config/routes.rb b/config/routes.rb index 7ce6ec51a2..ddd882ffa8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,8 +34,9 @@ # Can be used by load balancers and uptime monitors to verify that the app is live. get "/admin", to: redirect("/admin/avaliacoes") - get "/admin/gerenciamento", to: "admin#gerenciamento", as: :admin_gerenciamento get "/admin/avaliacoes", to: "admin#avaliacoes", as: :admin_avaliacoes + get "/admin/gerenciamento", to: "admin#gerenciamento", as: :admin_gerenciamento + get "/admin/templates", to: "admin#templates", as: :admin_templates post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa post "admin/atualizar_sigaa", to: "admin#atualizar_sigaa", as: :atualizar_sigaa From c1932dd9467386b28854b3b67b4e46b365ab7b56 Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Thu, 11 Jun 2026 21:14:57 -0300 Subject: [PATCH 24/55] feat: functional templates --- app/assets/stylesheets/gerenciamento.css | 191 +++++++++++++++ app/controllers/admin_controller.rb | 5 - app/controllers/templates_controller.rb | 30 ++- app/models/elemento.rb | 5 +- app/models/template.rb | 39 ++- app/views/admin/templates.html.erb | 19 -- app/views/templates/_form.html.erb | 255 ++++++++++++++++++-- app/views/templates/_grid.html.erb | 34 +++ app/views/templates/_template.html.erb | 7 - app/views/templates/_template_form.html.erb | 11 + app/views/templates/edit.html.erb | 14 +- app/views/templates/edit_template.html.erb | 1 + app/views/templates/index.html.erb | 17 +- app/views/templates/new.html.erb | 13 +- app/views/templates/show.html.erb | 10 - config/routes.rb | 6 +- features/step_definitions/template_steps.rb | 168 +++++++++++++ 17 files changed, 717 insertions(+), 108 deletions(-) delete mode 100644 app/views/admin/templates.html.erb create mode 100644 app/views/templates/_grid.html.erb delete mode 100644 app/views/templates/_template.html.erb create mode 100644 app/views/templates/_template_form.html.erb create mode 100644 app/views/templates/edit_template.html.erb delete mode 100644 app/views/templates/show.html.erb diff --git a/app/assets/stylesheets/gerenciamento.css b/app/assets/stylesheets/gerenciamento.css index e2049f702e..62a43f3997 100644 --- a/app/assets/stylesheets/gerenciamento.css +++ b/app/assets/stylesheets/gerenciamento.css @@ -241,4 +241,195 @@ body, html { .action-btn:hover .icon-wrapper svg { fill: #6C2365; +} + +.template-modal { + width: 453px; + background: #FFFFFF; + box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); + padding: 20px; + margin: 85px auto; + border-radius: 8px; +} + +.form-group { + display: flex; + align-items: center; + gap: 10px; + margin-bottom: 20px; +} + +input[type="text"], .dropdown { + border: none; + border-bottom: 1px solid #000; + width: 280px; + padding: 5px; +} + +.btn-save { + background: #22C55E; + color: #F0FDF4; + border: none; + padding: 12px 18px; + border-radius: 6px; + width: 125px; + margin: 0 auto; + display: block; + cursor: pointer; +} + +.modal-overlay { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background: rgba(0, 0, 0, 0.3); + display: flex; + justify-content: center; + align-items: center; + z-index: 1000; +} + +.figma-form-card { + width: 453px; + background: #FFFFFF; + box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); + border-radius: 8px; + padding: 20px 24px; + display: flex; + flex-direction: column; + gap: 20px; +} + +.figma-form-content { + display: flex; + flex-direction: column; + gap: 20px; +} + +/* Nome do template */ +.form-header-group { + display: flex; + align-items: center; + gap: 15px; +} + +.figma-label { + font-family: 'Inter', sans-serif; + font-size: 14px; + color: #000000; + white-space: nowrap; +} + +.figma-input-line { + border: none; + border-bottom: 1px solid #000000; + width: 100%; + font-family: 'Roboto', sans-serif; + font-size: 13px; + padding: 5px 0; + outline: none; + background: transparent; +} + +.figma-input-line::placeholder { + color: #8E8E8E; +} + +/* Blocos de Questão */ +.question-block { + display: flex; + flex-direction: column; + gap: 14px; +} + +.question-title { + font-family: 'Roboto', sans-serif; + font-size: 16px; + font-weight: 500; + color: #000000; + margin: 0; +} + +.question-row { + display: flex; + align-items: center; + gap: 15px; +} + +.figma-label-small { + font-family: 'Inter', sans-serif; + font-size: 12px; + color: #000000; + width: 50px; +} + +.figma-dropdown { + background: #FFFFFF; + border: 1px solid #E0E0E0; + border-radius: 8px; + padding: 6px 12px; + font-family: 'Inter', sans-serif; + font-size: 12px; + color: #828282; + width: 163px; + outline: none; +} + +.figma-input-line-full { + border: none; + border-bottom: 1px solid #000000; + flex-grow: 1; + font-family: 'Roboto', sans-serif; + font-size: 13px; + padding: 5px 0; + outline: none; +} + +/* Botão roxo de adicionar (+) */ +.add-question-btn { + width: 34px; + height: 34px; + background: #6C2365; + color: #FFF; + display: flex; + justify-content: center; + align-items: center; + font-size: 20px; + font-weight: bold; + border-radius: 4px; + cursor: pointer; + margin: 0 auto; +} + +.submit-row { + display: flex; + justify-content: center; + margin-top: 10px; +} + +.btn-figma-success { + background: #22C55E; + color: #F0FDF4; + font-family: 'Poppins', sans-serif; + font-weight: 500; + font-size: 16px; + border: none; + border-radius: 6px; + padding: 10px 30px; + cursor: pointer; + box-shadow: 0px 1px 2px rgba(105, 81, 255, 0.05); +} + +.cancel-row { + display: flex; + justify-content: center; +} + +.btn-cancel { + font-family: 'Inter', sans-serif; + font-size: 12px; + color: #828282; + text-decoration: underline; } \ No newline at end of file diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3e6489ae82..05f5a12e18 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -7,11 +7,6 @@ def avaliacoes def gerenciamento end - def templates - @templates = Template.all - end - - def importar_sigaa resultado = SigaaImporter.import_from_files("classes.json", "members.json") diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index 82c191cb0b..cf4ec4e62e 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -1,4 +1,7 @@ class TemplatesController < ApplicationController + + layout 'gerenciamento' + before_action :set_template, only: %i[ show edit update destroy ] # GET /templates or /templates.json @@ -8,15 +11,24 @@ def index # GET /templates/1 or /templates/1.json def show + redirect_to admin_templates_path end # GET /templates/new def new + @templates = Template.all @template = Template.new + elemento = @template.elementos.build + elemento.campos.build end # GET /templates/1/edit def edit + @templates = Template.all + if @template.elementos.empty? + elemento = @template.elementos.build + elemento.campos.build + end end # POST /templates or /templates.json @@ -25,9 +37,10 @@ def create respond_to do |format| if @template.save - format.html { redirect_to @template, notice: "Template was successfully created." } + format.html { redirect_to admin_templates_path, notice: "Template criado com sucesso!" } format.json { render :show, status: :created, location: @template } else + @templates = Template.all format.html { render :new, status: :unprocessable_content } format.json { render json: @template.errors, status: :unprocessable_content } end @@ -38,9 +51,10 @@ def create def update respond_to do |format| if @template.update(template_params) - format.html { redirect_to @template, notice: "Template was successfully updated.", status: :see_other } + format.html { redirect_to admin_templates_path, notice: "Template atualizado com sucesso!" } format.json { render :show, status: :ok, location: @template } else + @templates = Template.all format.html { render :edit, status: :unprocessable_content } format.json { render json: @template.errors, status: :unprocessable_content } end @@ -50,9 +64,9 @@ def update # DELETE /templates/1 or /templates/1.json def destroy @template.destroy! - respond_to do |format| - format.html { redirect_to templates_path, notice: "Template was successfully destroyed.", status: :see_other } + # Mude templates_path para admin_templates_path + format.html { redirect_to admin_templates_path, notice: "Template deletado com sucesso!", status: :see_other } format.json { head :no_content } end end @@ -65,6 +79,12 @@ def set_template # Only allow a list of trusted parameters through. def template_params - params.expect(template: [ :nome ]) + params.require(:template).permit( + :nome, + elementos_attributes: [ + :id, :enunciado, :ordem, :_destroy, + campos_attributes: [:id, :tipo_elemento, :enunciado, :ordem, :_destroy] + ] + ) end end diff --git a/app/models/elemento.rb b/app/models/elemento.rb index 04b87fa8ac..e5cbad7bf3 100644 --- a/app/models/elemento.rb +++ b/app/models/elemento.rb @@ -1,6 +1,5 @@ class Elemento < ApplicationRecord belongs_to :template - has_many :campos, dependent: :destroy - validates :ordem, presence: true - validates :ordem, uniqueness: { scope: :template_id } + has_many :campos, dependent: :destroy + accepts_nested_attributes_for :campos, allow_destroy: true end \ No newline at end of file diff --git a/app/models/template.rb b/app/models/template.rb index 95b585e4d9..a930f94b9c 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -1,4 +1,41 @@ class Template < ApplicationRecord has_many :elementos, dependent: :destroy - validates :nome, presence: true + accepts_nested_attributes_for :elementos, allow_destroy: true + + validate :validar_titulo + validate :validar_elementos + validate :validar_preenchimento + + private + + def validar_titulo + if nome.blank? + errors.add(:base, "Título não pode ficar em branco!") + end + end + + def validar_elementos + if elementos.reject(&:marked_for_destruction?).empty? + errors.add(:base, "Template deve ter pelo menos um elemento!") + end + end + + def validar_preenchimento + return if errors.any? + elementos.reject(&:marked_for_destruction?).each do |elemento| + + if elemento.enunciado.blank? + errors.add(:base, "O texto de todas as questões deve ser preenchido!") + return # Para a execução aqui para não repetir a mensagem várias vezes + end + + elemento.campos.reject(&:marked_for_destruction?).each do |campo| + if campo.tipo_elemento != 'Texto' && campo.enunciado.blank? + errors.add(:base, "Todas as opções das questões devem ser preenchidas!") + return + end + + end + end + end end \ No newline at end of file diff --git a/app/views/admin/templates.html.erb b/app/views/admin/templates.html.erb deleted file mode 100644 index 63a974bc6a..0000000000 --- a/app/views/admin/templates.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -
- <% @templates.each do |template| %> -
-
-

<%= template.nome %>

-

Semestre: N/A

-
- -
- <%= link_to svg_icon('edit', class: 'icon-edit'), "#", class: "action-btn" %> - <%= link_to svg_icon('trash', class: 'icon-delete'), "#", class: "action-btn" %> -
-
- <% end %> - - -
+
-
-
\ No newline at end of file diff --git a/app/views/templates/_form.html.erb b/app/views/templates/_form.html.erb index 556b3bf170..889644706f 100644 --- a/app/views/templates/_form.html.erb +++ b/app/views/templates/_form.html.erb @@ -1,22 +1,243 @@ -<%= form_with(model: template) do |form| %> - <% if template.errors.any? %> -
-

<%= pluralize(template.errors.count, "error") %> prohibited this template from being saved:

- -
    - <% template.errors.each do |error| %> -
  • <%= error.full_message %>
  • +
-
- <% end %> +
+ + -
- <%= form.label :nome, style: "display: block" %> - <%= form.text_field :nome %> +
+ <%= f.submit @template.persisted? ? "Salvar" : "Criar", class: "btn-figma-success" %> +
+ +
+ <%= link_to "Cancelar", admin_templates_path, data: { turbo_frame: "_top" }, class: "btn-cancel" %> +
+ + <% end %>
+
+ + + + \ No newline at end of file diff --git a/app/views/templates/_grid.html.erb b/app/views/templates/_grid.html.erb new file mode 100644 index 0000000000..2b8bd1021b --- /dev/null +++ b/app/views/templates/_grid.html.erb @@ -0,0 +1,34 @@ +<% if @templates.empty? %> +
+

Nenhum template encontrado.

+ <%= link_to "Criar novo template", new_admin_template_path, class: "btn-figma-success", style: "text-decoration: none;" %> +
+<% else %> +
+ <% @templates.each do |template| %> +
+
+

<%= template.nome %>

+
+ +
+ <%= link_to edit_admin_template_path(template), class: "action-btn", aria: { label: "Editar" } do %> + <%= svg_icon('edit') %> + <% end %> + + <%= button_to admin_template_path(template), method: :delete, + form: { data: { turbo_confirm: "..." } }, + class: "action-btn button-to-clean", + aria: { label: "Deletar" } do %> + <%= svg_icon('trash') %> + <% end %> +
+
+ <% end %> + + <%= link_to new_admin_template_path, class: "card-create-new" do %> + Adicionar novo template + + + <% end %> +
+<% end %> \ No newline at end of file diff --git a/app/views/templates/_template.html.erb b/app/views/templates/_template.html.erb deleted file mode 100644 index e9fdcd5bdd..0000000000 --- a/app/views/templates/_template.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -
-
- Nome: - <%= template.nome %> -
- -
diff --git a/app/views/templates/_template_form.html.erb b/app/views/templates/_template_form.html.erb new file mode 100644 index 0000000000..2c40c5344d --- /dev/null +++ b/app/views/templates/_template_form.html.erb @@ -0,0 +1,11 @@ +<%= form_with model: @template, + url: @template.persisted? ? update_admin_template_path(@template) : create_admin_template_path, + method: @template.persisted? ? :patch : :post do |f| %> + +
+ <%= f.label :nome, "Nome do template:" %> + <%= f.text_field :nome, placeholder: "Digite o nome..." %> +
+ + <%= f.submit @template.persisted? ? "Salvar Alterações" : "Criar Template", class: "btn-save" %> +<% end %> \ No newline at end of file diff --git a/app/views/templates/edit.html.erb b/app/views/templates/edit.html.erb index 2fe355a9c7..0e96116b60 100644 --- a/app/views/templates/edit.html.erb +++ b/app/views/templates/edit.html.erb @@ -1,12 +1,2 @@ -<% content_for :title, "Editing template" %> - -

Editing template

- -<%= render "form", template: @template %> - -
- -
- <%= link_to "Show this template", @template %> | - <%= link_to "Back to templates", templates_path %> -
+<%= render 'grid' %> +<%= render 'form' %> \ No newline at end of file diff --git a/app/views/templates/edit_template.html.erb b/app/views/templates/edit_template.html.erb new file mode 100644 index 0000000000..09df7eee18 --- /dev/null +++ b/app/views/templates/edit_template.html.erb @@ -0,0 +1 @@ +<%= render 'template_form' %> \ No newline at end of file diff --git a/app/views/templates/index.html.erb b/app/views/templates/index.html.erb index 93d4cd21c2..30669cb98c 100644 --- a/app/views/templates/index.html.erb +++ b/app/views/templates/index.html.erb @@ -1,16 +1 @@ -

<%= notice %>

- -<% content_for :title, "Templates" %> - -

Templates

- -
- <% @templates.each do |template| %> - <%= render template %> -

- <%= link_to "Show this template", template %> -

- <% end %> -
- -<%= link_to "New template", new_template_path %> +<%= render 'grid' %> \ No newline at end of file diff --git a/app/views/templates/new.html.erb b/app/views/templates/new.html.erb index bd2d47148d..0e96116b60 100644 --- a/app/views/templates/new.html.erb +++ b/app/views/templates/new.html.erb @@ -1,11 +1,2 @@ -<% content_for :title, "New template" %> - -

New template

- -<%= render "form", template: @template %> - -
- -
- <%= link_to "Back to templates", templates_path %> -
+<%= render 'grid' %> +<%= render 'form' %> \ No newline at end of file diff --git a/app/views/templates/show.html.erb b/app/views/templates/show.html.erb deleted file mode 100644 index e610456e09..0000000000 --- a/app/views/templates/show.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -

<%= notice %>

- -<%= render @template %> - -
- <%= link_to "Edit this template", edit_template_path(@template) %> | - <%= link_to "Back to templates", templates_path %> - - <%= button_to "Destroy this template", @template, method: :delete %> -
diff --git a/config/routes.rb b/config/routes.rb index ddd882ffa8..3fc5c0aefb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,7 +20,6 @@ resources :formularios resources :campos resources :elementos - resources :templates resources :docentes resources :discentes resources :usuarios @@ -36,7 +35,10 @@ get "/admin/avaliacoes", to: "admin#avaliacoes", as: :admin_avaliacoes get "/admin/gerenciamento", to: "admin#gerenciamento", as: :admin_gerenciamento - get "/admin/templates", to: "admin#templates", as: :admin_templates + + scope '/admin', as: 'admin' do + resources :templates + end post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa post "admin/atualizar_sigaa", to: "admin#atualizar_sigaa", as: :atualizar_sigaa diff --git a/features/step_definitions/template_steps.rb b/features/step_definitions/template_steps.rb index e69de29bb2..fa3ec3e681 100644 --- a/features/step_definitions/template_steps.rb +++ b/features/step_definitions/template_steps.rb @@ -0,0 +1,168 @@ + + +Given(/^I [aA]m authenticated as an "([^"]*)"$/) do |role| + depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') + @admin = Usuario.find_or_create_by!(email: 'admin@unb.br') do |u| + u.senha_hash = '123456' + u.nome = 'Admin' + u.type = role + u.matricula = '123456789' + u.departamento = depto + end + allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) +end + +Given('I Am on the home page') do + visit inicio_path +end + +Given('I go to the {string} page') do |page| + visit admin_templates_path if page == "Meus Templates" +end + +Given('I am on the {string} page') do |page_name| + expect(page).to have_content("Nome do template:") +end + +When('I follow {string}') do |link| + if link == "Adicionar novo template" + visit new_admin_template_path + else + click_link_or_button(link) + end +end + +When('I follow {string} for {string}') do |acao, template_nome| + card = find('.card', text: template_nome) + card.find("[aria-label='#{acao}']").click +end + +When('I press {string}') do |botao| + if page.has_button?('Criar') + click_button 'Criar' + else + click_button 'Salvar' + end +end + +When('I confirm the deletion') do +end + +Given('I have added the template') do |table| + dados = table.rows_hash + valor = dados['titulo'].gsub(/^"|"$/, '') + fill_in "Nome do template:", with: valor +end + +Given('I add the following elementos:') do |table| + table.hashes.each_with_index do |row, index| + find('.add-question-btn', visible: :all).click if index > 0 + + within all('.question-block:not(.deleted-block)').last do + find('.figma-input-line-full[placeholder="Digite a pergunta..."]').set(row['enunciado_elemento']) + + tipo = row['tipo_campo'] == 'multipla_escolha' ? 'Múltipla Escolha' : 'Texto' + find('.select-tipo').find("option[value='#{tipo}']").select_option + + if tipo == 'Múltipla Escolha' + opcoes = row['enunciado_campo'].split(':').map(&:strip).reject(&:empty?) + opcoes.each_with_index do |opcao, opt_idx| + find('.btn-add-option').click if opt_idx > 0 + all('.option-row:not(.deleted-option) input.figma-input-line-full').last.set(opcao) + end + end + end + end +end + +Given('I dont add elementos') do + find('input.destroy-question-input', visible: :hidden).set('1') +end + +When('I change the {string} to {string}') do |campo, valor| + fill_in "Nome do template:", with: valor if campo == "titulo" +end + +When('I change the elemento {string} to {string}') do |antigo, novo| + if novo.empty? + input = find("input.figma-input-line-full[value='#{antigo.strip}']") + bloco = input.ancestor('.question-block') + within(bloco) do + find('input.destroy-question-input', visible: :hidden).set('1') + end + else + input = find("input.figma-input-line-full[value='#{antigo.strip}']") + input.set(novo) + end +end + +Then('I should see a success message {string}') do |msg| + expect(page).to have_content(msg) +end + +Then('I should see an error message {string}') do |msg| + expect(page).to have_content(msg) +end + +Then('the template {string} should be listed in my templates') do |nome| + expect(page).to have_content(nome) +end + +Then('I should see {string}') do |texto| + expect(page).to have_content(texto) +end + +Then('I should not see {string}') do |texto| + expect(page).not_to have_content(texto) +end + +Then('I should see the message {string}') do |msg| + expect(page).to have_content(msg) +end + +Then('I should see options to {string} and {string} for each template') do |acao1, acao2| + expect(page).to have_selector("[aria-label='#{acao1}']") + expect(page).to have_selector("[aria-label='#{acao2}']") +end + +Then('I should see a button {string}') do |botao| + expect(page).to have_selector("a, button", text: botao) +end + +Then('the template {string} should have the following elementos:') do |nome, table| + template = Template.find_by(nome: nome) + expect(template.elementos.count).to eq(table.hashes.count) +end + +Given('I have the following templates saved:') do |table| + table.hashes.each do |row| + template = Template.new(nome: row['titulo']) + elemento = template.elementos.build(enunciado: "Questão Fantasma", ordem: 1) + elemento.campos.build(tipo_elemento: "Texto", ordem: 1) + template.save! + end +end + +Given('the template {string} has the following elementos:') do |nome, table| + template = Template.find_by(nome: nome) + template.elementos.destroy_all # Limpa a fantasma + + table.hashes.each_with_index do |row, index| + tipo = row['tipo_campo'] == 'multipla_escolha' ? 'Múltipla Escolha' : 'Texto' + elemento = template.elementos.create!(enunciado: row['enunciado_elemento'], ordem: index + 1) + + if tipo == 'Múltipla Escolha' + opcoes = row['enunciado_campo'].split(':').map(&:strip).reject(&:empty?) + opcoes.each_with_index do |opcao, opt_idx| + elemento.campos.create!(tipo_elemento: tipo, enunciado: opcao, ordem: opt_idx + 1) + end + else + elemento.campos.create!(tipo_elemento: tipo, ordem: 1) + end + end +end + +Given('I have no templates saved') do + Template.destroy_all +end + From 8604ae79d28ab10fc07b61b68223412361de3c6c Mon Sep 17 00:00:00 2001 From: leitaonerd Date: Sun, 14 Jun 2026 16:59:45 -0300 Subject: [PATCH 25/55] fix completo lembrar de incluir dados do .env para rodar o mailer adequadamente --- .env.example | 30 ++++++++++++++++++++++++++++++ .gitignore | 3 ++- Gemfile | 3 +++ Gemfile.lock | 5 +++++ app/mailers/application_mailer.rb | 2 +- config/database.yml | 4 ++-- config/environments/development.rb | 21 +++++++++++++++++++-- config/environments/production.rb | 30 +++++++++++++++++++----------- db/seeds.rb | 9 +++++++++ 9 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000..8463db78b3 --- /dev/null +++ b/.env.example @@ -0,0 +1,30 @@ +# ============================================ +# CAMAAR - Email Configuration +# ============================================ +# Copy this file to .env and fill in the values: +# cp .env.example .env +# +# GMAIL SETUP (Recommended): +# 1. Enable 2-Step Verification on your Google account: +# https://myaccount.google.com/security +# 2. Generate an App Password: +# https://myaccount.google.com/apppasswords +# 3. Use that App Password below (NOT your regular Gmail password) +# +# For other providers, change SMTP_ADDRESS, SMTP_PORT, SMTP_DOMAIN accordingly. +# ============================================ + +# Sender email address (shown as "From" in sent emails) +MAILER_FROM_ADDRESS=camaar@gmail.com + +# SMTP Configuration (Gmail defaults shown) +SMTP_ADDRESS=smtp.gmail.com +SMTP_PORT=587 +SMTP_USERNAME=your_email@gmail.com +SMTP_PASSWORD=your_16_digit_app_password +SMTP_DOMAIN=gmail.com + +# Application URL (used in email links for production) +# In development, this defaults to http://localhost:3000 +APP_HOST=localhost:3000 +APP_PROTOCOL=http \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7158ded4dd..8410f141a8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,9 @@ # Ignore bundler config. /.bundle -# Ignore all environment files. +# Ignore all environment files (but keep .env.example in the repo). /.env* +!/.env.example # Ignore all logfiles and tempfiles. /log/* diff --git a/Gemfile b/Gemfile index 892d972fbd..7cb9a240b1 100644 --- a/Gemfile +++ b/Gemfile @@ -44,6 +44,9 @@ group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri windows ], require: "debug/prelude" + # Load environment variables from .env file + gem "dotenv-rails" + # Audits gems for known security defects (use config/bundler-audit.yml to ignore issues) gem "bundler-audit", require: false diff --git a/Gemfile.lock b/Gemfile.lock index c6a237f391..12f9946b0b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -144,6 +144,9 @@ GEM reline (>= 0.3.8) diff-lcs (1.6.2) dotenv (3.2.0) + dotenv-rails (3.2.0) + dotenv (= 3.2.0) + railties (>= 6.1) drb (2.2.3) ed25519 (1.4.0) erb (6.0.4) @@ -457,6 +460,7 @@ DEPENDENCIES cucumber-rails database_cleaner debug + dotenv-rails image_processing (~> 1.2) importmap-rails jbuilder @@ -521,6 +525,7 @@ CHECKSUMS debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6 diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962 dotenv (3.2.0) sha256=e375b83121ea7ca4ce20f214740076129ab8514cd81378161f11c03853fe619d + dotenv-rails (3.2.0) sha256=657e25554ba622ffc95d8c4f1670286510f47f2edda9f68293c3f661b303beab drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373 ed25519 (1.4.0) sha256=16e97f5198689a154247169f3453ef4cfd3f7a47481fde0ae33206cdfdcac506 erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9 diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 3c34c8148f..19b2c9e98c 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,4 +1,4 @@ class ApplicationMailer < ActionMailer::Base - default from: "from@example.com" + default from: ENV.fetch("MAILER_FROM_ADDRESS", "camaar@gmail.com") layout "mailer" end diff --git a/config/database.yml b/config/database.yml index 63ad6ca8d5..a857bdc858 100644 --- a/config/database.yml +++ b/config/database.yml @@ -13,8 +13,8 @@ default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - username: camaar - password: senha_do_camaar + username: root + password: root socket: /var/run/mysqld/mysqld.sock development: diff --git a/config/environments/development.rb b/config/environments/development.rb index 4a6ea19c9c..da8e70d7ad 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -36,13 +36,30 @@ config.active_storage.service = :local # Don't care if the mailer can't send. - config.action_mailer.raise_delivery_errors = false + config.action_mailer.raise_delivery_errors = true # Make template changes take effect immediately. config.action_mailer.perform_caching = false # Set localhost to be used by links generated in mailer templates. - config.action_mailer.default_url_options = { host: "localhost", port: 3000 } + config.action_mailer.default_url_options = { + host: ENV.fetch("APP_HOST", "localhost:3000"), + protocol: ENV.fetch("APP_PROTOCOL", "http") + } + + # Gmail SMTP configuration via environment variables + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: ENV.fetch("SMTP_ADDRESS", "smtp.gmail.com"), + port: ENV.fetch("SMTP_PORT", 587).to_i, + domain: ENV.fetch("SMTP_DOMAIN", "gmail.com"), + user_name: ENV.fetch("SMTP_USERNAME", ""), + password: ENV.fetch("SMTP_PASSWORD", ""), + authentication: :plain, + enable_starttls_auto: true, + open_timeout: 10, + read_timeout: 10 + } # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/config/environments/production.rb b/config/environments/production.rb index f5763e04e5..f7a4759303 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -55,19 +55,27 @@ # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false + config.action_mailer.raise_delivery_errors = true # Set host to be used by links generated in mailer templates. - config.action_mailer.default_url_options = { host: "example.com" } - - # Specify outgoing SMTP server. Remember to add smtp/* credentials via bin/rails credentials:edit. - # config.action_mailer.smtp_settings = { - # user_name: Rails.application.credentials.dig(:smtp, :user_name), - # password: Rails.application.credentials.dig(:smtp, :password), - # address: "smtp.example.com", - # port: 587, - # authentication: :plain - # } + config.action_mailer.default_url_options = { + host: ENV.fetch("APP_HOST", "example.com"), + protocol: ENV.fetch("APP_PROTOCOL", "https") + } + + # Gmail SMTP configuration via environment variables + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: ENV.fetch("SMTP_ADDRESS", "smtp.gmail.com"), + port: ENV.fetch("SMTP_PORT", 587).to_i, + domain: ENV.fetch("SMTP_DOMAIN", "gmail.com"), + user_name: ENV.fetch("SMTP_USERNAME", ""), + password: ENV.fetch("SMTP_PASSWORD", ""), + authentication: :plain, + enable_starttls_auto: true, + open_timeout: 10, + read_timeout: 10 + } # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). diff --git a/db/seeds.rb b/db/seeds.rb index 134d68ef30..df5a6b48db 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -57,6 +57,15 @@ admin.departamento = dept_cic admin.save! +docente = Docente.find_or_initialize_by(email: "gusfring.a@gmail.com") +docente.nome ||= "GUS" +docente.matricula ||= "241000004" +docente.senha = "teste123" +docente.senha_confirmation = "teste123" +docente.departamento = dept_cic +docente.formacao = "doutorado" +docente.save! + # Vinculando Usuários às Turmas discente.turmas << turma_a unless discente.turmas.include?(turma_a) docente.turmas << turma_a unless docente.turmas.include?(turma_a) From cc262fb48cc3923502ceec83722b6393d2e08c4f Mon Sep 17 00:00:00 2001 From: neatzzy Date: Sun, 14 Jun 2026 17:37:39 -0300 Subject: [PATCH 26/55] :wrench: fix: fluxo da importacao do sigaa corrigida --- app/controllers/admin_controller.rb | 62 +++++++++++++------ app/services/sigaa_importer.rb | 45 ++++++-------- app/views/admin/gerenciamento.html.erb | 15 ++--- app/views/admin/sincronizar_sigaa.html.erb | 22 +++++++ config/database.yml | 4 +- config/routes.rb | 4 +- .../atualizar_dados_sigaa_steps.rb | 20 +++--- .../importar_dados_sigaa_steps.rb | 23 ++++--- 8 files changed, 118 insertions(+), 77 deletions(-) create mode 100644 app/views/admin/sincronizar_sigaa.html.erb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 05f5a12e18..abb6b0dea6 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -7,33 +7,59 @@ def avaliacoes def gerenciamento end - def importar_sigaa - resultado = SigaaImporter.import_from_files("classes.json", "members.json") - - case resultado - when /sucesso/i - redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." - when /alguns dados/i - redirect_to admin_gerenciamento_path, notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" - when /já existem/i - redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" - else - redirect_to admin_gerenciamento_path, alert: "erro informando que a importação falhou" + def sincronizar_sigaa + if request.get? + render :sincronizar_sigaa + elsif request.post? + processar_sincronizacao end end - def atualizar_sigaa - resultado = SigaaImporter.update_from_files("classes.json", "members.json") + private + + def processar_sincronizacao + acao = params[:acao] + arquivo = params[:arquivo_sigaa] + unless arquivo.present? + redirect_to admin_gerenciamento_path, alert: "Por favor, selecione um arquivo" + return + end + + temp_file = arquivo.path + resultado = case acao + when 'importar' + SigaaImporter.import_from_files(temp_file, temp_file) + when 'atualizar' + SigaaImporter.update_from_files(temp_file, temp_file) + else + "ação inválida" + end + + processar_resultado(resultado, acao) + end + + def processar_resultado(resultado, acao) case resultado when /alguns dados/i - redirect_to admin_gerenciamento_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" + if acao == 'importar' + redirect_to admin_gerenciamento_path, notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" + else + redirect_to admin_gerenciamento_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" + end + when /sucesso/i + if acao == 'importar' + redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." + else + redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." + end + when /já existem/i + redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" when /já estão atualizados/i redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" - when /atualiza/i - redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." else - redirect_to admin_gerenciamento_path, alert: "erro informando que a atualização falhou" + nome_acao = acao == 'importar' ? 'importação' : 'atualização' + redirect_to admin_gerenciamento_path, alert: "erro informando que a #{nome_acao} falhou" end end end diff --git a/app/services/sigaa_importer.rb b/app/services/sigaa_importer.rb index 461d42b0a2..65d5991dbd 100644 --- a/app/services/sigaa_importer.rb +++ b/app/services/sigaa_importer.rb @@ -4,11 +4,14 @@ def self.import_from_files(classes_path, members_path) ignored = 0 ActiveRecord::Base.transaction do + dep_padrao = Departamento.find_or_create_by(codigo: "NAO_ESP") { |d| d.nome = "Não especificado" } + # classes.json classes = JSON.parse(File.read(classes_path)) classes.each do |c| disciplina = Disciplina.find_or_create_by(codigo: c["code"]) do |d| d.nome = c["name"] + d.departamento = dep_padrao end class_info = c["class"] || {} @@ -36,15 +39,12 @@ def self.import_from_files(classes_path, members_path) # docente if m["docente"].is_a?(Hash) - dep = Departamento.find_or_create_by(nome: m["docente"]["departamento"]) if m["docente"]["departamento"] - usuario = Usuario.find_or_create_by(usuario: m["docente"]["usuario"]) do |u| - u.nome = m["docente"]["nome"] - u.email = m["docente"]["email"] - end - docente = Docente.find_or_create_by(usuario: usuario.usuario) do |dct| - dct.nome = usuario.nome - dct.email = usuario.email - dct.departamento = dep if dep + dep = m["docente"]["departamento"].present? ? Departamento.find_or_create_by(nome: m["docente"]["departamento"]) : dep_padrao + docente = Docente.find_or_create_by(email: m["docente"]["email"]) do |dct| + dct.nome = m["docente"]["nome"] + dct.matricula = m["docente"]["matricula"] || m["docente"]["usuario"] + dct.formacao = m["docente"]["formacao"] || "docente" + dct.departamento = dep end unless docente.turmas.exists?(turma.id) docente.turmas << turma @@ -57,14 +57,11 @@ def self.import_from_files(classes_path, members_path) # discentes Array(m["dicente"]).each do |aluno| next unless aluno.is_a?(Hash) - curso = Curso.find_or_create_by(nome: aluno["curso"]) if aluno["curso"] - usuario = Usuario.find_or_create_by(matricula: aluno["matricula"]) do |u| - u.nome = aluno["nome"] - u.email = aluno["email"] - end + curso = Curso.find_or_create_by(nome: aluno["curso"]) { |c| c.departamento = dep_padrao } if aluno["curso"] discente = Discente.find_or_create_by(matricula: aluno["matricula"]) do |d| - d.nome = usuario.nome - d.usuario = usuario.usuario if usuario.respond_to?(:usuario) + d.nome = aluno["nome"] + d.email = aluno["email"] + d.formacao = aluno["formacao"] || "graduando" d.curso = curso if curso end unless discente.turmas.exists?(turma.id) @@ -112,21 +109,17 @@ def self.update_from_files(classes_path, members_path) if m["docente"].is_a?(Hash) dep = Departamento.find_or_create_by(nome: m["docente"]["departamento"]) if m["docente"]["departamento"] - usuario = Usuario.find_by(usuario: m["docente"]["usuario"]) - usuario.update(nome: m["docente"]["nome"], email: m["docente"]["email"]) if usuario - docente = Docente.find_by(usuario: m["docente"]["usuario"]) - docente.update(nome: m["docente"]["nome"], email: m["docente"]["email"], departamento: dep) if docente - docente.turmas << turma unless docente.turmas.exists?(turma.id) + docente = Docente.find_by(email: m["docente"]["email"]) + docente.update(nome: m["docente"]["nome"], departamento: dep) if docente + docente.turmas << turma if docente && !docente.turmas.exists?(turma.id) end Array(m["dicente"]).each do |aluno| next unless aluno.is_a?(Hash) - curso = Curso.find_or_create_by(nome: aluno["curso"]) if aluno["curso"] - usuario = Usuario.find_by(matricula: aluno["matricula"]) - usuario.update(nome: aluno["nome"], email: aluno["email"]) if usuario + curso = Curso.find_by(nome: aluno["curso"]) if aluno["curso"] discente = Discente.find_by(matricula: aluno["matricula"]) - discente.update(nome: aluno["nome"], curso: curso) if discente - discente.turmas << turma unless discente.turmas.exists?(turma.id) + discente.update(nome: aluno["nome"], email: aluno["email"], curso: curso) if discente + discente.turmas << turma if discente && !discente.turmas.exists?(turma.id) end end end diff --git a/app/views/admin/gerenciamento.html.erb b/app/views/admin/gerenciamento.html.erb index 4cd1795094..f277202f0e 100644 --- a/app/views/admin/gerenciamento.html.erb +++ b/app/views/admin/gerenciamento.html.erb @@ -1,18 +1,11 @@
- +

- Sincronização + Ações de Gerenciamento

- <%= button_to "Importar dados do SIGAA", importar_sigaa_path, method: :post, class: "btn-figma" %> - - <%= button_to "Atualizar dados do SIGAA", atualizar_sigaa_path, method: :post, class: "btn-figma" %> + <%= link_to "Importar / Atualizar dados do SIGAA", admin_sincronizar_sigaa_path, class: "btn-figma" %> <%= link_to "Editar Template", admin_templates_path, class: "btn-figma" %> - - <%= button_to "Enviar Formulários", atualizar_sigaa_path, method: :post, class: "btn-figma" %> - - <%= button_to "Resultados", importar_sigaa_path, method: :post, class: "btn-figma" %> - -
\ No newline at end of file + diff --git a/app/views/admin/sincronizar_sigaa.html.erb b/app/views/admin/sincronizar_sigaa.html.erb new file mode 100644 index 0000000000..2b092b27da --- /dev/null +++ b/app/views/admin/sincronizar_sigaa.html.erb @@ -0,0 +1,22 @@ +
+

+ Sincronizar dados do SIGAA +

+ + <%= form_with local: true, url: admin_sincronizar_sigaa_path, method: :post, multipart: true do |f| %> +
+ <%= f.label :acao, "Tipo de sincronização:", style: "display: block; margin-bottom: 10px;" %> + <%= f.select :acao, [["Importar dados", "importar"], ["Atualizar dados", "atualizar"]], {}, class: "form-control" %> +
+ +
+ <%= f.label :arquivo_sigaa, "Selecione o arquivo JSON:", style: "display: block; margin-bottom: 10px;" %> + <%= f.file_field :arquivo_sigaa, accept: "application/json", required: true %> +
+ +
+ <%= f.submit "Sincronizar", class: "btn-figma" %> + <%= link_to "Cancelar", admin_gerenciamento_path, class: "btn-figma" %> +
+ <% end %> +
diff --git a/config/database.yml b/config/database.yml index 63ad6ca8d5..a857bdc858 100644 --- a/config/database.yml +++ b/config/database.yml @@ -13,8 +13,8 @@ default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - username: camaar - password: senha_do_camaar + username: root + password: root socket: /var/run/mysqld/mysqld.sock development: diff --git a/config/routes.rb b/config/routes.rb index 3fc5c0aefb..80995c5afc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -40,8 +40,8 @@ resources :templates end - post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa - post "admin/atualizar_sigaa", to: "admin#atualizar_sigaa", as: :atualizar_sigaa + get "admin/sincronizar_sigaa", to: "admin#sincronizar_sigaa", as: :admin_sincronizar_sigaa + post "admin/sincronizar_sigaa", to: "admin#sincronizar_sigaa" get "up" => "rails/health#show", as: :rails_health_check # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) diff --git a/features/step_definitions/atualizar_dados_sigaa_steps.rb b/features/step_definitions/atualizar_dados_sigaa_steps.rb index 493818ef95..fcc2b76e51 100644 --- a/features/step_definitions/atualizar_dados_sigaa_steps.rb +++ b/features/step_definitions/atualizar_dados_sigaa_steps.rb @@ -2,26 +2,30 @@ Dado('que os dados do SIGAA foram atualizados com sucesso') do allow(SigaaImporter).to receive(:update_from_files).and_return("atualização realizada com sucesso") - page.driver.post(atualizar_sigaa_path) - visit admin_path + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path, { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path end Dado('que eu tentei atualizar os dados do SIGAA mas ocorreu um erro') do allow(SigaaImporter).to receive(:update_from_files).and_return("falha") - page.driver.post(atualizar_sigaa_path) - visit admin_path + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path, { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path end Dado('que os dados do SIGAA já estão atualizados na base de dados do sistema') do allow(SigaaImporter).to receive(:update_from_files).and_return("os dados do SIGAA já estão atualizados e não serão atualizados novamente") - page.driver.post(atualizar_sigaa_path) - visit admin_path + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path, { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path end Dado('que alguns dados do SIGAA já estão atualizados na base de dados do sistema') do allow(SigaaImporter).to receive(:update_from_files).and_return("alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso") - page.driver.post(atualizar_sigaa_path) - visit admin_path + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path, { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path end Então('as turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA') do diff --git a/features/step_definitions/importar_dados_sigaa_steps.rb b/features/step_definitions/importar_dados_sigaa_steps.rb index dde28c469f..d8aa9377af 100644 --- a/features/step_definitions/importar_dados_sigaa_steps.rb +++ b/features/step_definitions/importar_dados_sigaa_steps.rb @@ -1,31 +1,34 @@ - Dado('que os dados do SIGAA estão disponíveis para importação') do - # Por padrão, o SigaaImporter importará os dados dos arquivos "classes.json" e "members.json", então não é necessário configurar nada aqui para simular a disponibilidade dos dados do SIGAA. + # Por padrão, o SigaaImporter importará os dados do arquivo JSON enviado, então não é necessário configurar nada aqui. end Dado('que os dados do SIGAA foram importados com sucesso') do allow(SigaaImporter).to receive(:import_from_files).and_return("importação realizada com sucesso") - page.driver.post(importar_sigaa_path) - visit admin_path + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path, { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path end Dado('que eu tentei importar os dados do SIGAA mas ocorreu um erro') do allow(SigaaImporter).to receive(:import_from_files).and_return("a importação falhou") - page.driver.post(importar_sigaa_path) - visit admin_path + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path, { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path end Dado('que os dados do SIGAA já existem na base de dados do sistema') do allow(SigaaImporter).to receive(:import_from_files).and_return("os dados já existem e não foram duplicados") - page.driver.post(importar_sigaa_path) - visit admin_path + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path, { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path end Dado('que alguns dados do SIGAA já existem na base de dados do sistema') do allow(SigaaImporter).to receive(:import_from_files).and_return("alguns dados já foram importados e não serão importados novamente") - page.driver.post(importar_sigaa_path) - visit admin_path + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path, { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path end Então('as turmas, matérias e participantes do SIGAA estão presentes no sistema') do From f93f02a08354476ee6ec59a2229929b978c47424 Mon Sep 17 00:00:00 2001 From: Liferoijrm Date: Mon, 15 Jun 2026 04:45:56 -0300 Subject: [PATCH 27/55] =?UTF-8?q?:construction:feat:=20p=C3=A1gina=20de=20?= =?UTF-8?q?download=20de=20resultados=20em=20csv?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 10 + app/views/admin/gerenciamento.html.erb | 2 +- app/views/admin/resultados.html.erb | 42 ++++ config/routes.rb | 1 + db/seeds.rb | 236 ++++++++++++++++++----- features/gerar_relatorio_csv.feature | 33 ++++ features/step_definitions/login_steps.rb | 3 +- 7 files changed, 280 insertions(+), 47 deletions(-) create mode 100644 app/views/admin/resultados.html.erb create mode 100644 features/gerar_relatorio_csv.feature diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 05f5a12e18..1ba7fb72f9 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -4,6 +4,16 @@ class AdminController < ApplicationController def avaliacoes end + def resultados + @admin = Administrador.find_by(id: session[:usuario_id]) + + if @admin + @formularios = Formulario.joins(turma: :disciplina).where(disciplinas: { departamento_id: @admin.departamento_id }).includes(turma: :disciplina) + else + redirect_to root_path, alert: "Acesso não autorizado." + end + end + def gerenciamento end diff --git a/app/views/admin/gerenciamento.html.erb b/app/views/admin/gerenciamento.html.erb index 4cd1795094..ac092ec6cc 100644 --- a/app/views/admin/gerenciamento.html.erb +++ b/app/views/admin/gerenciamento.html.erb @@ -12,7 +12,7 @@ <%= button_to "Enviar Formulários", atualizar_sigaa_path, method: :post, class: "btn-figma" %> - <%= button_to "Resultados", importar_sigaa_path, method: :post, class: "btn-figma" %> + <%= button_to "Resultados", admin_resultados_path, method: :get, class: "btn-figma" %> \ No newline at end of file diff --git a/app/views/admin/resultados.html.erb b/app/views/admin/resultados.html.erb new file mode 100644 index 0000000000..1cbae455bc --- /dev/null +++ b/app/views/admin/resultados.html.erb @@ -0,0 +1,42 @@ +
+ + <% if @formularios.present? %> +
+ + <% @formularios.each do |formulario| %> +
+ +
+

+ <%= formulario.turma.disciplina.nome %> +

+

+ <%= formulario.turma.semestre %> +

+

+ <%= formulario.turma.horario %> +

+
+ +
+

+ <%# Caso a relação no seu model seja diferente, ajuste '.docentes' para o nome correto %> + <%= formulario.turma.docentes.first&.nome || "Professor(a) não alocado(a)" %> +

+ + <%= link_to "Baixar Resultado", "#", style: "display: block; text-align: center; background-color: #612F65; color: white; text-decoration: none; padding: 10px 16px; border-radius: 4px; font-weight: bold; font-size: 0.9rem;" %> +
+ +
+ <% end %> + +
+ <% else %> + +
+

Nenhum formulário encontrado para o seu departamento neste semestre.

+
+ + <% end %> + +
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3fc5c0aefb..a25b15fa2c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,6 +42,7 @@ post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa post "admin/atualizar_sigaa", to: "admin#atualizar_sigaa", as: :atualizar_sigaa + get "/admin/resultados", to: "admin#resultados", as: :admin_resultados get "up" => "rails/health#show", as: :rails_health_check # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) diff --git a/db/seeds.rb b/db/seeds.rb index 134d68ef30..91c5d10df1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -22,33 +22,54 @@ d.departamento = dept_cic end +disc_isc = Disciplina.find_or_create_by!(codigo: "CIC0002") do |d| + d.nome = "Introdução aos Sistemas de Computação" + d.departamento = dept_cic +end + +disc_apc = Disciplina.find_or_create_by!(codigo: "CIC0003") do |d| + d.nome = "Algoritmos e Programação de Computadores" + d.departamento = dept_cic +end + # Turmas -turma_a = Turma.find_or_create_by!(numero_da_turma: "A", semestre: "2026.1", disciplina: disc_ed) do |t| +turma_ed_a = Turma.find_or_create_by!(numero_da_turma: "A", semestre: "2026.1", disciplina: disc_ed) do |t| t.horario = "35T23" end +turma_ed_b = Turma.find_or_create_by!(numero_da_turma: "B", semestre: "2026.1", disciplina: disc_ed) do |t| + t.horario = "35M23" +end + +# Introdução aos Sistemas de Computação - Turma A +turma_isc_a = Turma.find_or_create_by!(numero_da_turma: "A", semestre: "2026.1", disciplina: disc_isc) do |t| + t.horario = "24T23" +end + # Usuários (Docente, Discente, Admin) # A migration AjustaNulosParaSti permite que curso e departamento sejam nulos, # mas vamos associá-los aos nossos testes para dados mais ricos. -docente = Docente.find_or_initialize_by(email: "docente@teste.com") -docente.nome ||= "Docente Teste" -docente.matricula ||= "241000001" -docente.senha = "teste123" -docente.senha_confirmation = "teste123" -docente.departamento = dept_cic -docente.formacao = "doutorado" -docente.save! - -discente = Discente.find_or_initialize_by(email: "discente@teste.com") -discente.nome ||= "Discente Teste" -discente.matricula ||= "241000002" -discente.senha = "teste123" -discente.senha_confirmation = "teste123" -discente.curso = curso_cc -docente.formacao = "graduacao" -discente.save! - +# Docentes +docente_1 = Docente.find_or_initialize_by(email: "docente1@teste.com") +docente_1.nome ||= "Professor de ED" +docente_1.matricula ||= "241000001" +docente_1.senha = "teste123" +docente_1.senha_confirmation = "teste123" +docente_1.departamento = dept_cic +docente_1.formacao = "doutorado" +docente_1.save! + +docente_2 = Docente.find_or_initialize_by(email: "docente2@teste.com") +docente_2.nome ||= "Professor de ISC" +docente_2.matricula ||= "241000011" +docente_2.senha = "teste123" +docente_2.senha_confirmation = "teste123" +docente_2.departamento = dept_cic +docente_2.formacao = "doutorado" +docente_2.save! + +# Admin admin = Administrador.find_or_initialize_by(email: "admin@teste.com") admin.nome ||= "Admin Teste" admin.matricula ||= "240000003" @@ -57,41 +78,168 @@ admin.departamento = dept_cic admin.save! -# Vinculando Usuários às Turmas -discente.turmas << turma_a unless discente.turmas.include?(turma_a) -docente.turmas << turma_a unless docente.turmas.include?(turma_a) +# Discentes (Lista de novos alunos) +alunos_dados = [ + { email: "discente1@teste.com", nome: "Ana Silva", matricula: "241000002" }, + { email: "discente2@teste.com", nome: "Bruno Santos", matricula: "241000004" }, + { email: "discente3@teste.com", nome: "Carlos Oliveira", matricula: "241000005" }, + { email: "discente4@teste.com", nome: "Diana Costa", matricula: "241000006" }, + { email: "discente5@teste.com", nome: "Eduardo Ribeiro", matricula: "241000007" } +] + +alunos = alunos_dados.map do |dados| + aluno = Discente.find_or_initialize_by(email: dados[:email]) + aluno.nome ||= dados[:nome] + aluno.matricula ||= dados[:matricula] + aluno.senha = "teste123" + aluno.senha_confirmation = "teste123" + aluno.curso = curso_cc + aluno.save! + aluno +end -# Templates, Elementos e Campos (Estrutura base de formulários) -template = Template.find_or_create_by!(nome: "Avaliação de Disciplina Padrão") +# ========================================== +# VINCULANDO USUÁRIOS ÀS TURMAS +# ========================================== -elemento1 = Elemento.find_or_create_by!(enunciado: "Avalie a didática do professor", template: template) do |e| - e.ordem = 1 -end +# Professores nas turmas +docente_1.turmas << turma_ed_a unless docente_1.turmas.include?(turma_ed_a) +docente_1.turmas << turma_ed_b unless docente_1.turmas.include?(turma_ed_b) +docente_2.turmas << turma_isc_a unless docente_2.turmas.include?(turma_isc_a) -campo1 = Campo.find_or_create_by!(enunciado: "Nota de 1 a 5", elemento: elemento1) do |c| - c.ordem = 1 - c.tipo_elemento = "escala" +# Distribuindo alunos nas turmas para gerar variação de dados +# Turma ED A: Alunos 1, 2 e 3 +[alunos[0], alunos[1], alunos[2]].each do |aluno| + aluno.turmas << turma_ed_a unless aluno.turmas.include?(turma_ed_a) end -# Formulários de Turma, Elementos de Form e Campos de Form -formulario = Formulario.find_or_create_by!(turma: turma_a) - -elemento_form = ElementoForm.find_or_create_by!(enunciado: elemento1.enunciado, formulario: formulario) do |ef| - ef.ordem = elemento1.ordem +# Turma ED B: Alunos 3, 4 e 5 +[alunos[2], alunos[3], alunos[4]].each do |aluno| + aluno.turmas << turma_ed_b unless aluno.turmas.include?(turma_ed_b) end -campo_form = CampoForm.find_or_create_by!(enunciado: campo1.enunciado, elemento_form: elemento_form) do |cf| - cf.ordem = campo1.ordem +# Turma ISC A: Alunos 1, 4 e 5 +[alunos[0], alunos[4], alunos[3]].each do |aluno| + aluno.turmas << turma_isc_a unless aluno.turmas.include?(turma_isc_a) end -# Respostas (Simulando uma resposta de um Discente) -resposta_form = RespostaForm.find_or_create_by!(formulario: formulario, usuario: discente) do |rf| - rf.data_submissao = Date.today +# ========================================== +# TEMPLATES E ESTRUTURA BASE DE FORMULÁRIOS +# ========================================== +# Usamos find_or_initialize_by para evitar o salvamento imediato e não quebrar a validação +template = Template.find_or_initialize_by(nome: "Avaliação de Disciplina Padrão") + +if template.new_record? + # --------------------------------------------------------- + # Elemento 1: Múltipla Escolha (1 a 5) + # --------------------------------------------------------- + elemento_nota = template.elementos.build(enunciado: "Avalie a didática do professor", ordem: 1) + + (1..5).each do |valor| + elemento_nota.campos.build(enunciado: valor.to_s, ordem: valor, tipo_elemento: "Múltipla Escolha") + end + + # --------------------------------------------------------- + # Elemento 2: Múltipla Escolha (Dificuldade) + # --------------------------------------------------------- + elemento_opcoes = template.elementos.build(enunciado: "Como você avalia a dificuldade das listas de exercícios?", ordem: 2) + + ["Muito Fácil", "Adequada", "Muito Difícil"].each_with_index do |opcao, index| + elemento_opcoes.campos.build(enunciado: opcao, ordem: index + 1, tipo_elemento: "Múltipla Escolha") + end + + # --------------------------------------------------------- + # Elemento 3: Texto Livre + # --------------------------------------------------------- + elemento_texto = template.elementos.build(enunciado: "Deixe um comentário ou sugestão sobre a disciplina", ordem: 3) + + elemento_texto.campos.build(enunciado: nil, ordem: 1, tipo_elemento: "Texto") + + # Salva o bloco inteiro (Template + Elementos + Campos) de uma vez, satisfazendo a validação + template.save! end -RespostaElem.find_or_create_by!(resposta_form: resposta_form, elemento_form: elemento_form) do |re| - re.texto_resposta = "5" - re.campo_form = campo_form # campo_form_id pode ser nulo pela sua migration, mas passamos aqui +# ========================================== +# FORMULÁRIOS DAS TURMAS E RESPOSTAS +# ========================================== + +# Método auxiliar corrigido para clonar TODOS os campos e associar a resposta ao campo correto +def configurar_formulario_e_respostas(turma, template_base, dados_alunos) + formulario = Formulario.find_or_create_by!(turma: turma) + + # 1. Clona todos os elementos e TODOS os seus respectivos campos para o formulário + template_base.elementos.order(:ordem).each do |elemento_base| + ef = ElementoForm.find_or_create_by!(enunciado: elemento_base.enunciado, formulario: formulario) do |e| + e.ordem = elemento_base.ordem + end + + # Cria TODOS os campos (opções) atrelados a este elemento + elemento_base.campos.order(:ordem).each do |campo_base| + CampoForm.find_or_create_by!(enunciado: campo_base.enunciado, elemento_form: ef) do |c| + c.ordem = campo_base.ordem + # A linha abaixo foi removida pois CampoForm não possui a coluna tipo_elemento + # c.tipo_elemento = campo_base.tipo_elemento + end + end + end + + # 2. Cria as respostas baseadas nos dados fornecidos + dados_alunos.each do |dado| + aluno = dado[:aluno] + respostas = dado[:respostas] # Array com as strings das respostas na ordem das perguntas + + resposta_form = RespostaForm.find_or_create_by!(formulario: formulario, usuario: aluno) do |rf| + rf.data_submissao = Date.today + end + + # Itera sobre os elementos criados no formulário para salvar cada resposta + formulario.elemento_forms.order(:ordem).each_with_index do |ef, index| + texto_respondido = respostas[index].to_s + + # Busca o campo correspondente: + # - Se for Múltipla Escolha, acha o campo que tem o enunciado igual à opção marcada (ex: "5" ou "Adequada") + # - Se for Texto, pega o único campo disponível (onde o enunciado é nil) + cf = ef.campo_forms.find_by(enunciado: texto_respondido) || ef.campo_forms.first + + RespostaElem.find_or_create_by!(resposta_form: resposta_form, elemento_form: ef) do |re| + re.texto_resposta = texto_respondido + re.campo_form = cf + end + end + end end -puts "Seeds finalizados com sucesso" \ No newline at end of file +# Configurando dados para Estrutura de Dados - Turma A +configurar_formulario_e_respostas( + turma_ed_a, + template, + [ + { aluno: alunos[0], respostas: ["5", "Adequada", "Ótima didática, recomendo!"] }, + { aluno: alunos[1], respostas: ["4", "Muito Difícil", "As listas poderiam ter mais exemplos práticos."] }, + { aluno: alunos[2], respostas: ["5", "Adequada", "Sem reclamações, matéria excelente."] } + ] +) + +# Configurando dados para Estrutura de Dados - Turma B +configurar_formulario_e_respostas( + turma_ed_b, + template, + [ + { aluno: alunos[2], respostas: ["3", "Muito Difícil", "O ritmo das aulas está muito acelerado."] }, + { aluno: alunos[3], respostas: ["4", "Adequada", "Gostei da metodologia."] }, + { aluno: alunos[4], respostas: ["2", "Muito Difícil", "Preciso de mais monitoria para acompanhar."] } + ] +) + +# Configurando dados para Introdução aos Sistemas de Computação - Turma A +configurar_formulario_e_respostas( + turma_isc_a, + template, + [ + { aluno: alunos[0], respostas: ["5", "Muito Fácil", "Projetos práticos são muito divertidos!"] }, + { aluno: alunos[4], respostas: ["5", "Adequada", "O professor tira todas as dúvidas e os projetos ajudam muito."] }, + { aluno: alunos[3], respostas: ["4", "Adequada", "Gostaria de mais exercícios de fixação antes das provas."] } + ] +) + +puts "Seeds finalizados com sucesso! Campos padronizados como Texto e Múltipla Escolha." \ No newline at end of file diff --git a/features/gerar_relatorio_csv.feature b/features/gerar_relatorio_csv.feature new file mode 100644 index 0000000000..f9d6d66440 --- /dev/null +++ b/features/gerar_relatorio_csv.feature @@ -0,0 +1,33 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Download de resultados de formulário em CSV + Eu, como Administrador + Quero baixar um arquivo csv contendo os resultados de um formulário + A fim de avaliar o desempenho das turmas + + Contexto: + Dado que estou autenticado no sistema com o perfil de "Administrador" + E existe a "Turma A" que possui o formulário "Avaliação Semestral" associado a ela + E este formulário já possui respostas enviadas pelos alunos + + Cenário: Baixar resultados do formulário com sucesso (happy path) + Dado que estou na página de detalhes do formulário "Avaliação Semestral" da "Turma A" + Quando eu clico em "Baixar Resultados (CSV)" + Então o download do arquivo "resultados_avaliacao_semestral.csv" é iniciado + E vejo a mensagem "Arquivo exportado com sucesso." + E o arquivo deve conter as colunas correspondentes aos elementos do formulário e suas respectivas respostas + + Cenário: Tentar baixar CSV de um formulário que não possui respostas (sad path) + Dado que a "Turma A" possui outro formulário chamado "Questionário Opcional" + E este formulário não recebeu nenhuma resposta até o momento + E estou na página de detalhes do formulário "Questionário Opcional" + Quando eu clico em "Baixar Resultados (CSV)" + Então vejo a mensagem de erro "Falha na exportação: Este formulário ainda não possui respostas registradas." + E nenhum download de arquivo é iniciado + + Cenário: Instabilidade no servidor interrompe a geração do CSV (sad path) + Dado que estou na página de detalhes do formulário "Avaliação Semestral" da "Turma A" + E o servidor de arquivos encontra-se indisponível no momento + Quando eu clico em "Baixar Resultados (CSV)" + Então vejo a mensagem de erro "Falha no sistema: O servidor demorou muito para responder. Tente novamente em instantes." \ No newline at end of file diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index db564f532e..eef5bb8d43 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -67,6 +67,5 @@ end Então('sou direcionado para a página inicial') do - # expect(page).to have_current_path(avaliacoes_path) - # implementar quando o nome da rota for determinado + expect(page).to have_current_path(inicio_path) end \ No newline at end of file From 61807551b5d6caf580a8e6ca5e20b5db256a6a6a Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Mon, 15 Jun 2026 09:01:08 -0300 Subject: [PATCH 28/55] fix: aninha rotas de template por admin, adiciona relacionamento e corrige testes --- app/controllers/admin_controller.rb | 24 +++++++++---- app/controllers/sessions_controller.rb | 7 +++- app/controllers/templates_controller.rb | 34 ++++++++++++------- app/models/administrador.rb | 1 + app/models/template.rb | 2 ++ app/views/admin/gerenciamento.html.erb | 4 +-- app/views/layouts/gerenciamento.html.erb | 4 +-- app/views/templates/_form.html.erb | 15 ++------ app/views/templates/_grid.html.erb | 9 +++-- app/views/templates/_template_form.html.erb | 2 +- config/routes.rb | 13 +++---- ...20260615105458_add_usuario_to_templates.rb | 5 +++ db/schema.rb | 5 ++- .../{template => }/create_template.feature | 0 .../edit_delete_template.feature | 0 .../atualizar_dados_sigaa_steps.rb | 16 ++++----- features/step_definitions/cadastro_steps.rb | 21 ++++++++++-- .../importar_dados_sigaa_steps.rb | 16 ++++----- features/step_definitions/template_steps.rb | 20 +++++++---- features/{template => }/view_template.feature | 0 20 files changed, 122 insertions(+), 76 deletions(-) create mode 100644 db/migrate/20260615105458_add_usuario_to_templates.rb rename features/{template => }/create_template.feature (100%) rename features/{template => }/edit_delete_template.feature (100%) rename features/{template => }/view_template.feature (100%) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index abb6b0dea6..b6146c5a11 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,6 +1,8 @@ class AdminController < ApplicationController layout 'gerenciamento' + before_action :set_admin + def avaliacoes end @@ -17,6 +19,14 @@ def sincronizar_sigaa private + def set_admin + @admin = Administrador.find(params[:admin_id]) + + if @admin.id != session[:usuario_id] + redirect_to inicio_path, alert: "Acesso negado! Você só pode acessar as suas próprias páginas." + end + end + def processar_sincronizacao acao = params[:acao] arquivo = params[:arquivo_sigaa] @@ -43,23 +53,23 @@ def processar_resultado(resultado, acao) case resultado when /alguns dados/i if acao == 'importar' - redirect_to admin_gerenciamento_path, notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" + redirect_to admin_gerenciamento_path(@admin), notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" else - redirect_to admin_gerenciamento_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" + redirect_to admin_gerenciamento_path(@admin), notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" end when /sucesso/i if acao == 'importar' - redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." + redirect_to admin_gerenciamento_path(@admin), notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." else - redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." + redirect_to admin_gerenciamento_path(@admin), notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." end when /já existem/i - redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" + redirect_to admin_gerenciamento_path(@admin), alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" when /já estão atualizados/i - redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" + redirect_to admin_gerenciamento_path(@admin), alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" else nome_acao = acao == 'importar' ? 'importação' : 'atualização' - redirect_to admin_gerenciamento_path, alert: "erro informando que a #{nome_acao} falhou" + redirect_to admin_gerenciamento_path(@admin), alert: "erro informando que a #{nome_acao} falhou" end end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index aafb6f4339..fc3cfffe07 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -34,7 +34,12 @@ def create end session[:usuario_id] = usuario.id - redirect_to inicio_path, notice: "Login realizado com sucesso." + if usuario.is_a?(Administrador) + redirect_to admin_avaliacoes_path(usuario.id), notice: "Login realizado com sucesso." + else + redirect_to inicio_path, notice: "Login realizado com sucesso." + end + end def destroy diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index cf4ec4e62e..ee3f02c3b7 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -2,29 +2,30 @@ class TemplatesController < ApplicationController layout 'gerenciamento' + before_action :set_admin before_action :set_template, only: %i[ show edit update destroy ] # GET /templates or /templates.json def index - @templates = Template.all + @templates = @admin.templates.includes(elementos: :campos) end # GET /templates/1 or /templates/1.json def show - redirect_to admin_templates_path + redirect_to admin_templates_path(@admin) end # GET /templates/new def new - @templates = Template.all - @template = Template.new + @templates = @admin.templates + @template = @admin.templates.build elemento = @template.elementos.build elemento.campos.build end # GET /templates/1/edit def edit - @templates = Template.all + @templates = @admin.templates if @template.elementos.empty? elemento = @template.elementos.build elemento.campos.build @@ -33,14 +34,14 @@ def edit # POST /templates or /templates.json def create - @template = Template.new(template_params) + @template = @admin.templates.build(template_params) respond_to do |format| if @template.save - format.html { redirect_to admin_templates_path, notice: "Template criado com sucesso!" } + format.html { redirect_to admin_templates_path(@admin), notice: "Template criado com sucesso!" } format.json { render :show, status: :created, location: @template } else - @templates = Template.all + @templates = @admin.templates format.html { render :new, status: :unprocessable_content } format.json { render json: @template.errors, status: :unprocessable_content } end @@ -51,10 +52,10 @@ def create def update respond_to do |format| if @template.update(template_params) - format.html { redirect_to admin_templates_path, notice: "Template atualizado com sucesso!" } + format.html { redirect_to admin_templates_path(@admin), notice: "Template atualizado com sucesso!" } format.json { render :show, status: :ok, location: @template } else - @templates = Template.all + @templates = @admin.templates format.html { render :edit, status: :unprocessable_content } format.json { render json: @template.errors, status: :unprocessable_content } end @@ -65,16 +66,23 @@ def update def destroy @template.destroy! respond_to do |format| - # Mude templates_path para admin_templates_path - format.html { redirect_to admin_templates_path, notice: "Template deletado com sucesso!", status: :see_other } + format.html { redirect_to admin_templates_path(@admin), notice: "Template deletado com sucesso!", status: :see_other } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. + + def set_admin + @admin = Administrador.find(params[:admin_id]) + if @admin.id != session[:usuario_id] + redirect_to inicio_path, alert: "Acesso negado! Você só pode acessar as suas próprias páginas." + end + end + def set_template - @template = Template.find(params.expect(:id)) + @template = @admin.templates.find(params.expect(:id)) end # Only allow a list of trusted parameters through. diff --git a/app/models/administrador.rb b/app/models/administrador.rb index 9746052fd7..bece08ee98 100644 --- a/app/models/administrador.rb +++ b/app/models/administrador.rb @@ -1,3 +1,4 @@ class Administrador < Usuario + has_many :templates, foreign_key: 'usuario_id', dependent: :destroy validates :departamento_id, presence: true end \ No newline at end of file diff --git a/app/models/template.rb b/app/models/template.rb index a930f94b9c..a2dc12e3c5 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -1,4 +1,6 @@ class Template < ApplicationRecord + + belongs_to :administrador, foreign_key: 'usuario_id', class_name: 'Administrador' has_many :elementos, dependent: :destroy accepts_nested_attributes_for :elementos, allow_destroy: true diff --git a/app/views/admin/gerenciamento.html.erb b/app/views/admin/gerenciamento.html.erb index f277202f0e..8f23084f86 100644 --- a/app/views/admin/gerenciamento.html.erb +++ b/app/views/admin/gerenciamento.html.erb @@ -4,8 +4,8 @@ Ações de Gerenciamento - <%= link_to "Importar / Atualizar dados do SIGAA", admin_sincronizar_sigaa_path, class: "btn-figma" %> + <%= link_to "Importar / Atualizar dados do SIGAA", admin_sincronizar_sigaa_path(@admin), class: "btn-figma" %> - <%= link_to "Editar Template", admin_templates_path, class: "btn-figma" %> + <%= link_to "Editar Template", admin_templates_path(@admin), class: "btn-figma" %> diff --git a/app/views/layouts/gerenciamento.html.erb b/app/views/layouts/gerenciamento.html.erb index e9c6234870..ce5e333a2f 100644 --- a/app/views/layouts/gerenciamento.html.erb +++ b/app/views/layouts/gerenciamento.html.erb @@ -32,11 +32,11 @@ diff --git a/app/views/templates/_form.html.erb b/app/views/templates/_form.html.erb index 889644706f..97afdf87fe 100644 --- a/app/views/templates/_form.html.erb +++ b/app/views/templates/_form.html.erb @@ -13,7 +13,7 @@ <% end %> <%= form_with model: @template, - url: @template.persisted? ? admin_template_path(@template) : admin_templates_path, + url: @template.persisted? ? admin_template_path(@admin, @template) : admin_templates_path(@admin), method: @template.persisted? ? :patch : :post, data: { turbo_frame: "_top" }, class: "figma-form-content" do |f| %> @@ -79,7 +79,7 @@
- <%= link_to "Cancelar", admin_templates_path, data: { turbo_frame: "_top" }, class: "btn-cancel" %> + <%= link_to "Cancelar", admin_templates_path(@admin), data: { turbo_frame: "_top" }, class: "btn-cancel" %>
<% end %> @@ -131,19 +131,15 @@ \ No newline at end of file diff --git a/app/views/templates/_grid.html.erb b/app/views/templates/_grid.html.erb index 2b8bd1021b..e2951eb863 100644 --- a/app/views/templates/_grid.html.erb +++ b/app/views/templates/_grid.html.erb @@ -6,17 +6,20 @@ <% else %>
<% @templates.each do |template| %> + + <% next if template.new_record? %> +

<%= template.nome %>

- <%= link_to edit_admin_template_path(template), class: "action-btn", aria: { label: "Editar" } do %> + <%= link_to edit_admin_template_path(@admin, template), class: "action-btn", aria: { label: "Editar" } do %> <%= svg_icon('edit') %> <% end %> - <%= button_to admin_template_path(template), method: :delete, + <%= button_to admin_template_path(@admin, template), method: :delete, form: { data: { turbo_confirm: "..." } }, class: "action-btn button-to-clean", aria: { label: "Deletar" } do %> @@ -26,7 +29,7 @@
<% end %> - <%= link_to new_admin_template_path, class: "card-create-new" do %> + <%= link_to new_admin_template_path(@admin), class: "card-create-new" do %> Adicionar novo template + <% end %> diff --git a/app/views/templates/_template_form.html.erb b/app/views/templates/_template_form.html.erb index 2c40c5344d..75ca947616 100644 --- a/app/views/templates/_template_form.html.erb +++ b/app/views/templates/_template_form.html.erb @@ -1,5 +1,5 @@ <%= form_with model: @template, - url: @template.persisted? ? update_admin_template_path(@template) : create_admin_template_path, + url: @template.persisted? ? update_admin_template_path(@admin, @template) : create_admin_template_path, method: @template.persisted? ? :patch : :post do |f| %>
diff --git a/config/routes.rb b/config/routes.rb index 80995c5afc..a5ca73a271 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,18 +31,15 @@ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. - get "/admin", to: redirect("/admin/avaliacoes") - get "/admin/avaliacoes", to: "admin#avaliacoes", as: :admin_avaliacoes - get "/admin/gerenciamento", to: "admin#gerenciamento", as: :admin_gerenciamento - - scope '/admin', as: 'admin' do + scope '/admin/:admin_id', as: 'admin' do + get "avaliacoes", to: "admin#avaliacoes", as: :avaliacoes + get "gerenciamento", to: "admin#gerenciamento", as: :gerenciamento resources :templates + get "sincronizar_sigaa", to: "admin#sincronizar_sigaa", as: :sincronizar_sigaa + post "sincronizar_sigaa", to: "admin#sincronizar_sigaa" end - get "admin/sincronizar_sigaa", to: "admin#sincronizar_sigaa", as: :admin_sincronizar_sigaa - post "admin/sincronizar_sigaa", to: "admin#sincronizar_sigaa" - get "up" => "rails/health#show", as: :rails_health_check # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest diff --git a/db/migrate/20260615105458_add_usuario_to_templates.rb b/db/migrate/20260615105458_add_usuario_to_templates.rb new file mode 100644 index 0000000000..ae90001208 --- /dev/null +++ b/db/migrate/20260615105458_add_usuario_to_templates.rb @@ -0,0 +1,5 @@ +class AddUsuarioToTemplates < ActiveRecord::Migration[8.1] + def change + add_reference :templates, :usuario, null: false, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index d039b4be04..fb72ec4a1b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_06_02_090000) do +ActiveRecord::Schema[8.1].define(version: 2026_06_15_105458) do create_table "campo_forms", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.datetime "created_at", null: false t.bigint "elemento_form_id", null: false @@ -119,6 +119,8 @@ t.datetime "created_at", null: false t.string "nome" t.datetime "updated_at", null: false + t.bigint "usuario_id", null: false + t.index ["usuario_id"], name: "index_templates_on_usuario_id" end create_table "turmas", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| @@ -165,6 +167,7 @@ add_foreign_key "resposta_elems", "resposta_forms" add_foreign_key "resposta_forms", "formularios" add_foreign_key "resposta_forms", "usuarios" + add_foreign_key "templates", "usuarios" add_foreign_key "turmas", "disciplinas" add_foreign_key "usuarios", "cursos" add_foreign_key "usuarios", "departamentos" diff --git a/features/template/create_template.feature b/features/create_template.feature similarity index 100% rename from features/template/create_template.feature rename to features/create_template.feature diff --git a/features/template/edit_delete_template.feature b/features/edit_delete_template.feature similarity index 100% rename from features/template/edit_delete_template.feature rename to features/edit_delete_template.feature diff --git a/features/step_definitions/atualizar_dados_sigaa_steps.rb b/features/step_definitions/atualizar_dados_sigaa_steps.rb index fcc2b76e51..d0cd1d5a9d 100644 --- a/features/step_definitions/atualizar_dados_sigaa_steps.rb +++ b/features/step_definitions/atualizar_dados_sigaa_steps.rb @@ -3,29 +3,29 @@ Dado('que os dados do SIGAA foram atualizados com sucesso') do allow(SigaaImporter).to receive(:update_from_files).and_return("atualização realizada com sucesso") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path, { acao: 'atualizar', arquivo_sigaa: arquivo }) - visit admin_gerenciamento_path + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) end Dado('que eu tentei atualizar os dados do SIGAA mas ocorreu um erro') do allow(SigaaImporter).to receive(:update_from_files).and_return("falha") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path, { acao: 'atualizar', arquivo_sigaa: arquivo }) - visit admin_gerenciamento_path + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) end Dado('que os dados do SIGAA já estão atualizados na base de dados do sistema') do allow(SigaaImporter).to receive(:update_from_files).and_return("os dados do SIGAA já estão atualizados e não serão atualizados novamente") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path, { acao: 'atualizar', arquivo_sigaa: arquivo }) - visit admin_gerenciamento_path + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) end Dado('que alguns dados do SIGAA já estão atualizados na base de dados do sistema') do allow(SigaaImporter).to receive(:update_from_files).and_return("alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path, { acao: 'atualizar', arquivo_sigaa: arquivo }) - visit admin_gerenciamento_path + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) end Então('as turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA') do diff --git a/features/step_definitions/cadastro_steps.rb b/features/step_definitions/cadastro_steps.rb index 64f06b8b6f..05c69983e4 100644 --- a/features/step_definitions/cadastro_steps.rb +++ b/features/step_definitions/cadastro_steps.rb @@ -1,6 +1,23 @@ Dado('que estou na página de gerenciamento') do - # expect(page).to have_current_path(gerenciamento_path) - # implementar quando o nome da rota for determinado + departamento = Departamento.first || Departamento.create!(nome: "Ciência da Computação", codigo: "CIC") + @admin = Administrador.first || Administrador.create!( + nome: "Admin Teste", + matricula: "admin", + email: "admin@teste.com", + senha: "Senha123", + departamento: departamento + ) + + allow_any_instance_of(AdminController).to receive(:set_admin) do |controller| + controller.instance_variable_set(:@admin, Administrador.find(controller.params[:admin_id])) + end + + allow_any_instance_of(TemplatesController).to receive(:set_admin) do |controller| + controller.instance_variable_set(:@admin, Administrador.find(controller.params[:admin_id])) + end + + visit admin_gerenciamento_path(@admin) + end Dado('que eu importei os dados do SIGAA com sucesso') do diff --git a/features/step_definitions/importar_dados_sigaa_steps.rb b/features/step_definitions/importar_dados_sigaa_steps.rb index d8aa9377af..f2fa158a39 100644 --- a/features/step_definitions/importar_dados_sigaa_steps.rb +++ b/features/step_definitions/importar_dados_sigaa_steps.rb @@ -6,29 +6,29 @@ Dado('que os dados do SIGAA foram importados com sucesso') do allow(SigaaImporter).to receive(:import_from_files).and_return("importação realizada com sucesso") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path, { acao: 'importar', arquivo_sigaa: arquivo }) - visit admin_gerenciamento_path + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) end Dado('que eu tentei importar os dados do SIGAA mas ocorreu um erro') do allow(SigaaImporter).to receive(:import_from_files).and_return("a importação falhou") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path, { acao: 'importar', arquivo_sigaa: arquivo }) - visit admin_gerenciamento_path + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) end Dado('que os dados do SIGAA já existem na base de dados do sistema') do allow(SigaaImporter).to receive(:import_from_files).and_return("os dados já existem e não foram duplicados") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path, { acao: 'importar', arquivo_sigaa: arquivo }) - visit admin_gerenciamento_path + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) end Dado('que alguns dados do SIGAA já existem na base de dados do sistema') do allow(SigaaImporter).to receive(:import_from_files).and_return("alguns dados já foram importados e não serão importados novamente") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path, { acao: 'importar', arquivo_sigaa: arquivo }) - visit admin_gerenciamento_path + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) end Então('as turmas, matérias e participantes do SIGAA estão presentes no sistema') do diff --git a/features/step_definitions/template_steps.rb b/features/step_definitions/template_steps.rb index fa3ec3e681..67ee81cc08 100644 --- a/features/step_definitions/template_steps.rb +++ b/features/step_definitions/template_steps.rb @@ -1,15 +1,18 @@ - - Given(/^I [aA]m authenticated as an "([^"]*)"$/) do |role| depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') - @admin = Usuario.find_or_create_by!(email: 'admin@unb.br') do |u| + + @admin = Administrador.find_or_create_by!(email: 'admin@unb.br') do |u| u.senha_hash = '123456' u.nome = 'Admin' - u.type = role u.matricula = '123456789' u.departamento = depto end + allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) + + allow_any_instance_of(TemplatesController).to receive(:set_admin) do |controller| + controller.instance_variable_set(:@admin, @admin) + end end Given('I Am on the home page') do @@ -17,7 +20,8 @@ end Given('I go to the {string} page') do |page| - visit admin_templates_path if page == "Meus Templates" + admin = Administrador.first + visit admin_templates_path(admin) if page == "Meus Templates" end Given('I am on the {string} page') do |page_name| @@ -26,7 +30,8 @@ When('I follow {string}') do |link| if link == "Adicionar novo template" - visit new_admin_template_path + admin = Administrador.first + visit new_admin_template_path(admin) else click_link_or_button(link) end @@ -135,8 +140,9 @@ end Given('I have the following templates saved:') do |table| + admin = Administrador.first table.hashes.each do |row| - template = Template.new(nome: row['titulo']) + template = Template.new(nome: row['titulo'], administrador: admin) elemento = template.elementos.build(enunciado: "Questão Fantasma", ordem: 1) elemento.campos.build(tipo_elemento: "Texto", ordem: 1) template.save! diff --git a/features/template/view_template.feature b/features/view_template.feature similarity index 100% rename from features/template/view_template.feature rename to features/view_template.feature From 3e9b221b21c8773e98a94fb1512317340b53f735 Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Mon, 15 Jun 2026 09:06:59 -0300 Subject: [PATCH 29/55] fix: view template --- app/views/templates/_form.html.erb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/templates/_form.html.erb b/app/views/templates/_form.html.erb index 97afdf87fe..8901960cb7 100644 --- a/app/views/templates/_form.html.erb +++ b/app/views/templates/_form.html.erb @@ -47,7 +47,7 @@
- <%= campo_form.select :tipo_elemento, ["Texto", "Múltipla Escolha", "Dropdown"], {}, { class: "figma-dropdown select-tipo", onchange: "window.toggleOptionsVisibility(this)" } %> + <%= campo_form.select :tipo_elemento, ["Texto", "Múltipla Escolha"], {}, { class: "figma-dropdown select-tipo", onchange: "window.toggleOptionsVisibility(this)" } %>
@@ -108,7 +108,6 @@
From b216bcf47a6674733782ef6e960c3843786f31cc Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Mon, 15 Jun 2026 14:33:03 -0300 Subject: [PATCH 30/55] feat: template and admin rspec test --- .rspec | 1 + spec/helpers/admin_helper_spec.rb | 15 -- spec/helpers/campo_forms_helper_spec.rb | 15 -- spec/helpers/campos_helper_spec.rb | 15 -- spec/helpers/cursos_helper_spec.rb | 15 -- spec/helpers/departamentos_helper_spec.rb | 15 -- spec/helpers/discentes_helper_spec.rb | 15 -- spec/helpers/disciplinas_helper_spec.rb | 15 -- spec/helpers/docentes_helper_spec.rb | 15 -- spec/helpers/elemento_forms_helper_spec.rb | 15 -- spec/helpers/elementos_helper_spec.rb | 15 -- spec/helpers/formularios_helper_spec.rb | 15 -- spec/helpers/resposta_elems_helper_spec.rb | 15 -- spec/helpers/resposta_forms_helper_spec.rb | 15 -- spec/helpers/templates_helper_spec.rb | 15 -- spec/helpers/turmas_helper_spec.rb | 15 -- spec/helpers/usuarios_helper_spec.rb | 15 -- spec/models/administrador_spec.rb | 40 ++++++ spec/models/template_spec.rb | 41 +++++- spec/rails_helper.rb | 72 ++++++++++ spec/requests/admin_spec.rb | 7 - spec/requests/campo_forms_spec.rb | 131 ------------------ spec/requests/campos_spec.rb | 131 ------------------ spec/requests/cursos_spec.rb | 131 ------------------ spec/requests/departamentos_spec.rb | 131 ------------------ spec/requests/discentes_spec.rb | 131 ------------------ spec/requests/disciplinas_spec.rb | 131 ------------------ spec/requests/docentes_spec.rb | 131 ------------------ spec/requests/elemento_forms_spec.rb | 131 ------------------ spec/requests/elementos_spec.rb | 131 ------------------ spec/requests/formularios_spec.rb | 131 ------------------ spec/requests/resposta_elems_spec.rb | 131 ------------------ spec/requests/resposta_forms_spec.rb | 131 ------------------ spec/requests/templates_spec.rb | 131 ------------------ spec/requests/turmas_spec.rb | 131 ------------------ spec/requests/usuarios_spec.rb | 131 ------------------ spec/routing/campo_forms_routing_spec.rb | 38 ----- spec/routing/campos_routing_spec.rb | 38 ----- spec/routing/cursos_routing_spec.rb | 38 ----- spec/routing/departamentos_routing_spec.rb | 38 ----- spec/routing/discentes_routing_spec.rb | 38 ----- spec/routing/disciplinas_routing_spec.rb | 38 ----- spec/routing/docentes_routing_spec.rb | 38 ----- spec/routing/elemento_forms_routing_spec.rb | 38 ----- spec/routing/elementos_routing_spec.rb | 38 ----- spec/routing/formularios_routing_spec.rb | 38 ----- spec/routing/resposta_elems_routing_spec.rb | 38 ----- spec/routing/resposta_forms_routing_spec.rb | 38 ----- spec/routing/templates_routing_spec.rb | 38 ----- spec/routing/turmas_routing_spec.rb | 38 ----- spec/routing/usuarios_routing_spec.rb | 38 ----- spec/spec_helper.rb | 94 +++++++++++++ spec/views/campo_forms/edit.html.erb_spec.rb | 28 ---- spec/views/campo_forms/index.html.erb_spec.rb | 26 ---- spec/views/campo_forms/new.html.erb_spec.rb | 24 ---- spec/views/campo_forms/show.html.erb_spec.rb | 18 --- spec/views/campos/edit.html.erb_spec.rb | 31 ----- spec/views/campos/index.html.erb_spec.rb | 29 ---- spec/views/campos/new.html.erb_spec.rb | 27 ---- spec/views/campos/show.html.erb_spec.rb | 20 --- spec/views/cursos/edit.html.erb_spec.rb | 28 ---- spec/views/cursos/index.html.erb_spec.rb | 26 ---- spec/views/cursos/new.html.erb_spec.rb | 24 ---- spec/views/cursos/show.html.erb_spec.rb | 18 --- .../views/departamentos/edit.html.erb_spec.rb | 25 ---- .../departamentos/index.html.erb_spec.rb | 23 --- spec/views/departamentos/new.html.erb_spec.rb | 21 --- .../views/departamentos/show.html.erb_spec.rb | 16 --- spec/views/discentes/edit.html.erb_spec.rb | 34 ----- spec/views/discentes/index.html.erb_spec.rb | 32 ----- spec/views/discentes/new.html.erb_spec.rb | 30 ---- spec/views/discentes/show.html.erb_spec.rb | 22 --- spec/views/disciplinas/edit.html.erb_spec.rb | 28 ---- spec/views/disciplinas/index.html.erb_spec.rb | 26 ---- spec/views/disciplinas/new.html.erb_spec.rb | 24 ---- spec/views/disciplinas/show.html.erb_spec.rb | 18 --- spec/views/docentes/edit.html.erb_spec.rb | 31 ----- spec/views/docentes/index.html.erb_spec.rb | 29 ---- spec/views/docentes/new.html.erb_spec.rb | 27 ---- spec/views/docentes/show.html.erb_spec.rb | 20 --- .../elemento_forms/edit.html.erb_spec.rb | 28 ---- .../elemento_forms/index.html.erb_spec.rb | 26 ---- .../views/elemento_forms/new.html.erb_spec.rb | 24 ---- .../elemento_forms/show.html.erb_spec.rb | 18 --- spec/views/elementos/edit.html.erb_spec.rb | 28 ---- spec/views/elementos/index.html.erb_spec.rb | 26 ---- spec/views/elementos/new.html.erb_spec.rb | 24 ---- spec/views/elementos/show.html.erb_spec.rb | 18 --- spec/views/formularios/edit.html.erb_spec.rb | 22 --- spec/views/formularios/index.html.erb_spec.rb | 20 --- spec/views/formularios/new.html.erb_spec.rb | 18 --- spec/views/formularios/show.html.erb_spec.rb | 14 -- .../resposta_elems/edit.html.erb_spec.rb | 31 ----- .../resposta_elems/index.html.erb_spec.rb | 29 ---- .../views/resposta_elems/new.html.erb_spec.rb | 27 ---- .../resposta_elems/show.html.erb_spec.rb | 20 --- .../resposta_forms/edit.html.erb_spec.rb | 25 ---- .../resposta_forms/index.html.erb_spec.rb | 23 --- .../views/resposta_forms/new.html.erb_spec.rb | 21 --- .../resposta_forms/show.html.erb_spec.rb | 16 --- spec/views/templates/edit.html.erb_spec.rb | 22 --- spec/views/templates/index.html.erb_spec.rb | 20 --- spec/views/templates/new.html.erb_spec.rb | 18 --- spec/views/templates/show.html.erb_spec.rb | 14 -- spec/views/turmas/edit.html.erb_spec.rb | 31 ----- spec/views/turmas/index.html.erb_spec.rb | 29 ---- spec/views/turmas/new.html.erb_spec.rb | 27 ---- spec/views/turmas/show.html.erb_spec.rb | 20 --- spec/views/usuarios/edit.html.erb_spec.rb | 34 ----- spec/views/usuarios/index.html.erb_spec.rb | 32 ----- spec/views/usuarios/new.html.erb_spec.rb | 30 ---- spec/views/usuarios/show.html.erb_spec.rb | 22 --- 112 files changed, 246 insertions(+), 4246 deletions(-) create mode 100644 .rspec delete mode 100644 spec/helpers/admin_helper_spec.rb delete mode 100644 spec/helpers/campo_forms_helper_spec.rb delete mode 100644 spec/helpers/campos_helper_spec.rb delete mode 100644 spec/helpers/cursos_helper_spec.rb delete mode 100644 spec/helpers/departamentos_helper_spec.rb delete mode 100644 spec/helpers/discentes_helper_spec.rb delete mode 100644 spec/helpers/disciplinas_helper_spec.rb delete mode 100644 spec/helpers/docentes_helper_spec.rb delete mode 100644 spec/helpers/elemento_forms_helper_spec.rb delete mode 100644 spec/helpers/elementos_helper_spec.rb delete mode 100644 spec/helpers/formularios_helper_spec.rb delete mode 100644 spec/helpers/resposta_elems_helper_spec.rb delete mode 100644 spec/helpers/resposta_forms_helper_spec.rb delete mode 100644 spec/helpers/templates_helper_spec.rb delete mode 100644 spec/helpers/turmas_helper_spec.rb delete mode 100644 spec/helpers/usuarios_helper_spec.rb create mode 100644 spec/models/administrador_spec.rb create mode 100644 spec/rails_helper.rb delete mode 100644 spec/requests/admin_spec.rb delete mode 100644 spec/requests/campo_forms_spec.rb delete mode 100644 spec/requests/campos_spec.rb delete mode 100644 spec/requests/cursos_spec.rb delete mode 100644 spec/requests/departamentos_spec.rb delete mode 100644 spec/requests/discentes_spec.rb delete mode 100644 spec/requests/disciplinas_spec.rb delete mode 100644 spec/requests/docentes_spec.rb delete mode 100644 spec/requests/elemento_forms_spec.rb delete mode 100644 spec/requests/elementos_spec.rb delete mode 100644 spec/requests/formularios_spec.rb delete mode 100644 spec/requests/resposta_elems_spec.rb delete mode 100644 spec/requests/resposta_forms_spec.rb delete mode 100644 spec/requests/templates_spec.rb delete mode 100644 spec/requests/turmas_spec.rb delete mode 100644 spec/requests/usuarios_spec.rb delete mode 100644 spec/routing/campo_forms_routing_spec.rb delete mode 100644 spec/routing/campos_routing_spec.rb delete mode 100644 spec/routing/cursos_routing_spec.rb delete mode 100644 spec/routing/departamentos_routing_spec.rb delete mode 100644 spec/routing/discentes_routing_spec.rb delete mode 100644 spec/routing/disciplinas_routing_spec.rb delete mode 100644 spec/routing/docentes_routing_spec.rb delete mode 100644 spec/routing/elemento_forms_routing_spec.rb delete mode 100644 spec/routing/elementos_routing_spec.rb delete mode 100644 spec/routing/formularios_routing_spec.rb delete mode 100644 spec/routing/resposta_elems_routing_spec.rb delete mode 100644 spec/routing/resposta_forms_routing_spec.rb delete mode 100644 spec/routing/templates_routing_spec.rb delete mode 100644 spec/routing/turmas_routing_spec.rb delete mode 100644 spec/routing/usuarios_routing_spec.rb create mode 100644 spec/spec_helper.rb delete mode 100644 spec/views/campo_forms/edit.html.erb_spec.rb delete mode 100644 spec/views/campo_forms/index.html.erb_spec.rb delete mode 100644 spec/views/campo_forms/new.html.erb_spec.rb delete mode 100644 spec/views/campo_forms/show.html.erb_spec.rb delete mode 100644 spec/views/campos/edit.html.erb_spec.rb delete mode 100644 spec/views/campos/index.html.erb_spec.rb delete mode 100644 spec/views/campos/new.html.erb_spec.rb delete mode 100644 spec/views/campos/show.html.erb_spec.rb delete mode 100644 spec/views/cursos/edit.html.erb_spec.rb delete mode 100644 spec/views/cursos/index.html.erb_spec.rb delete mode 100644 spec/views/cursos/new.html.erb_spec.rb delete mode 100644 spec/views/cursos/show.html.erb_spec.rb delete mode 100644 spec/views/departamentos/edit.html.erb_spec.rb delete mode 100644 spec/views/departamentos/index.html.erb_spec.rb delete mode 100644 spec/views/departamentos/new.html.erb_spec.rb delete mode 100644 spec/views/departamentos/show.html.erb_spec.rb delete mode 100644 spec/views/discentes/edit.html.erb_spec.rb delete mode 100644 spec/views/discentes/index.html.erb_spec.rb delete mode 100644 spec/views/discentes/new.html.erb_spec.rb delete mode 100644 spec/views/discentes/show.html.erb_spec.rb delete mode 100644 spec/views/disciplinas/edit.html.erb_spec.rb delete mode 100644 spec/views/disciplinas/index.html.erb_spec.rb delete mode 100644 spec/views/disciplinas/new.html.erb_spec.rb delete mode 100644 spec/views/disciplinas/show.html.erb_spec.rb delete mode 100644 spec/views/docentes/edit.html.erb_spec.rb delete mode 100644 spec/views/docentes/index.html.erb_spec.rb delete mode 100644 spec/views/docentes/new.html.erb_spec.rb delete mode 100644 spec/views/docentes/show.html.erb_spec.rb delete mode 100644 spec/views/elemento_forms/edit.html.erb_spec.rb delete mode 100644 spec/views/elemento_forms/index.html.erb_spec.rb delete mode 100644 spec/views/elemento_forms/new.html.erb_spec.rb delete mode 100644 spec/views/elemento_forms/show.html.erb_spec.rb delete mode 100644 spec/views/elementos/edit.html.erb_spec.rb delete mode 100644 spec/views/elementos/index.html.erb_spec.rb delete mode 100644 spec/views/elementos/new.html.erb_spec.rb delete mode 100644 spec/views/elementos/show.html.erb_spec.rb delete mode 100644 spec/views/formularios/edit.html.erb_spec.rb delete mode 100644 spec/views/formularios/index.html.erb_spec.rb delete mode 100644 spec/views/formularios/new.html.erb_spec.rb delete mode 100644 spec/views/formularios/show.html.erb_spec.rb delete mode 100644 spec/views/resposta_elems/edit.html.erb_spec.rb delete mode 100644 spec/views/resposta_elems/index.html.erb_spec.rb delete mode 100644 spec/views/resposta_elems/new.html.erb_spec.rb delete mode 100644 spec/views/resposta_elems/show.html.erb_spec.rb delete mode 100644 spec/views/resposta_forms/edit.html.erb_spec.rb delete mode 100644 spec/views/resposta_forms/index.html.erb_spec.rb delete mode 100644 spec/views/resposta_forms/new.html.erb_spec.rb delete mode 100644 spec/views/resposta_forms/show.html.erb_spec.rb delete mode 100644 spec/views/templates/edit.html.erb_spec.rb delete mode 100644 spec/views/templates/index.html.erb_spec.rb delete mode 100644 spec/views/templates/new.html.erb_spec.rb delete mode 100644 spec/views/templates/show.html.erb_spec.rb delete mode 100644 spec/views/turmas/edit.html.erb_spec.rb delete mode 100644 spec/views/turmas/index.html.erb_spec.rb delete mode 100644 spec/views/turmas/new.html.erb_spec.rb delete mode 100644 spec/views/turmas/show.html.erb_spec.rb delete mode 100644 spec/views/usuarios/edit.html.erb_spec.rb delete mode 100644 spec/views/usuarios/index.html.erb_spec.rb delete mode 100644 spec/views/usuarios/new.html.erb_spec.rb delete mode 100644 spec/views/usuarios/show.html.erb_spec.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000000..c99d2e7396 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/spec/helpers/admin_helper_spec.rb b/spec/helpers/admin_helper_spec.rb deleted file mode 100644 index aec0cef762..0000000000 --- a/spec/helpers/admin_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the AdminHelper. For example: -# -# describe AdminHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe AdminHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/campo_forms_helper_spec.rb b/spec/helpers/campo_forms_helper_spec.rb deleted file mode 100644 index 03f4e78d98..0000000000 --- a/spec/helpers/campo_forms_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the CampoFormsHelper. For example: -# -# describe CampoFormsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe CampoFormsHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/campos_helper_spec.rb b/spec/helpers/campos_helper_spec.rb deleted file mode 100644 index 6b7b8f6a57..0000000000 --- a/spec/helpers/campos_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the CamposHelper. For example: -# -# describe CamposHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe CamposHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/cursos_helper_spec.rb b/spec/helpers/cursos_helper_spec.rb deleted file mode 100644 index 48e2f77109..0000000000 --- a/spec/helpers/cursos_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the CursosHelper. For example: -# -# describe CursosHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe CursosHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/departamentos_helper_spec.rb b/spec/helpers/departamentos_helper_spec.rb deleted file mode 100644 index 07c9be8f3c..0000000000 --- a/spec/helpers/departamentos_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the DepartamentosHelper. For example: -# -# describe DepartamentosHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe DepartamentosHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/discentes_helper_spec.rb b/spec/helpers/discentes_helper_spec.rb deleted file mode 100644 index 988b0ccdcf..0000000000 --- a/spec/helpers/discentes_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the DiscentesHelper. For example: -# -# describe DiscentesHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe DiscentesHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/disciplinas_helper_spec.rb b/spec/helpers/disciplinas_helper_spec.rb deleted file mode 100644 index 43afb7d2c3..0000000000 --- a/spec/helpers/disciplinas_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the DisciplinasHelper. For example: -# -# describe DisciplinasHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe DisciplinasHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/docentes_helper_spec.rb b/spec/helpers/docentes_helper_spec.rb deleted file mode 100644 index f39a1e5870..0000000000 --- a/spec/helpers/docentes_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the DocentesHelper. For example: -# -# describe DocentesHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe DocentesHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/elemento_forms_helper_spec.rb b/spec/helpers/elemento_forms_helper_spec.rb deleted file mode 100644 index 51c345f796..0000000000 --- a/spec/helpers/elemento_forms_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the ElementoFormsHelper. For example: -# -# describe ElementoFormsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe ElementoFormsHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/elementos_helper_spec.rb b/spec/helpers/elementos_helper_spec.rb deleted file mode 100644 index 908f8b4903..0000000000 --- a/spec/helpers/elementos_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the ElementosHelper. For example: -# -# describe ElementosHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe ElementosHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/formularios_helper_spec.rb b/spec/helpers/formularios_helper_spec.rb deleted file mode 100644 index b5045f4f06..0000000000 --- a/spec/helpers/formularios_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the FormulariosHelper. For example: -# -# describe FormulariosHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe FormulariosHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/resposta_elems_helper_spec.rb b/spec/helpers/resposta_elems_helper_spec.rb deleted file mode 100644 index 67dc42c971..0000000000 --- a/spec/helpers/resposta_elems_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the RespostaElemsHelper. For example: -# -# describe RespostaElemsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe RespostaElemsHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/resposta_forms_helper_spec.rb b/spec/helpers/resposta_forms_helper_spec.rb deleted file mode 100644 index 506dedc8a3..0000000000 --- a/spec/helpers/resposta_forms_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the RespostaFormsHelper. For example: -# -# describe RespostaFormsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe RespostaFormsHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/templates_helper_spec.rb b/spec/helpers/templates_helper_spec.rb deleted file mode 100644 index 5abfcb5dc5..0000000000 --- a/spec/helpers/templates_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the TemplatesHelper. For example: -# -# describe TemplatesHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe TemplatesHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/turmas_helper_spec.rb b/spec/helpers/turmas_helper_spec.rb deleted file mode 100644 index dcae56f9ef..0000000000 --- a/spec/helpers/turmas_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the TurmasHelper. For example: -# -# describe TurmasHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe TurmasHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/usuarios_helper_spec.rb b/spec/helpers/usuarios_helper_spec.rb deleted file mode 100644 index f92d1f5608..0000000000 --- a/spec/helpers/usuarios_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the UsuariosHelper. For example: -# -# describe UsuariosHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe UsuariosHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/administrador_spec.rb b/spec/models/administrador_spec.rb new file mode 100644 index 0000000000..427ed503b0 --- /dev/null +++ b/spec/models/administrador_spec.rb @@ -0,0 +1,40 @@ +require 'rails_helper' + +RSpec.describe Administrador, type: :model do + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + + context "validações de criação" do + it "é válido com todos os atributos obrigatórios" do + admin = Administrador.new( + nome: "Admin Teste", + matricula: "admin123", + email: "admin@unb.br", + senha: "Senha123", + departamento: departamento + ) + expect(admin).to be_valid + end + + it "não é válido sem um nome" do + admin = Administrador.new( + nome: nil, + matricula: "admin123", + email: "admin@unb.br", + senha: "Senha123", + departamento: departamento + ) + expect(admin).not_to be_valid + end + + it "não é válido sem um departamento associado" do + admin = Administrador.new( + nome: "Admin Teste", + matricula: "admin123", + email: "admin@unb.br", + senha: "Senha123", + departamento: nil + ) + expect(admin).not_to be_valid + end + end +end \ No newline at end of file diff --git a/spec/models/template_spec.rb b/spec/models/template_spec.rb index 068ef0ee3c..32eec5e955 100644 --- a/spec/models/template_spec.rb +++ b/spec/models/template_spec.rb @@ -1,5 +1,42 @@ require 'rails_helper' RSpec.describe Template, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + let(:admin) do + Administrador.find_or_create_by!(email: "admin_template@unb.br") do |u| + u.nome = "Admin Template" + u.matricula = "78910" + u.senha = "Senha123" + u.departamento = departamento + end + end + + context "validações de criação e relacionamento" do + it "é válido com nome, um administrador e pelo menos um elemento" do + template = Template.new(nome: "Avaliação da Turma", administrador: admin) + template.elementos.build(enunciado: "Questão 1", ordem: 1) + + expect(template).to be_valid + end + + it "não é válido sem um nome (título)" do + template = Template.new(nome: "", administrador: admin) + template.elementos.build(enunciado: "Questão 1", ordem: 1) + + expect(template).not_to be_valid + end + + it "não é válido sem um administrador associado" do + template = Template.new(nome: "Formulário Fantasma", administrador: nil) + template.elementos.build(enunciado: "Questão 1", ordem: 1) + + expect(template).not_to be_valid + end + + it "não é válido se não possuir nenhum elemento (questão)" do + template = Template.new(nome: "Formulário Vazio", administrador: admin) + + expect(template).not_to be_valid + end + end +end \ No newline at end of file diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000000..ef75d46770 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,72 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file +# that will avoid rails generators crashing because migrations haven't been run yet +# return unless Rails.env.test? +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f } + +# Ensures that the test database schema matches the current schema file. +# If there are pending migrations it will invoke `db:test:prepare` to +# recreate the test database by loading the schema. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + abort e.to_s.strip +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_paths = [ + Rails.root.join('spec/fixtures') + ] + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails uses metadata to mix in different behaviours to your tests, + # for example enabling you to call `get` and `post` in request specs. e.g.: + # + # RSpec.describe UsersController, type: :request do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://rspec.info/features/8-0/rspec-rails + # + # You can also infer these behaviours automatically by location, e.g. + # /spec/models would pull in the same behaviour as `type: :model` but this + # behaviour is considered legacy and will be removed in a future version. + # + # To enable this behaviour uncomment the line below. + # config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/requests/admin_spec.rb b/spec/requests/admin_spec.rb deleted file mode 100644 index 2ce29b5db8..0000000000 --- a/spec/requests/admin_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'rails_helper' - -RSpec.describe "Admins", type: :request do - describe "GET /index" do - pending "add some examples (or delete) #{__FILE__}" - end -end diff --git a/spec/requests/campo_forms_spec.rb b/spec/requests/campo_forms_spec.rb deleted file mode 100644 index a778ebc107..0000000000 --- a/spec/requests/campo_forms_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/campo_forms", type: :request do - - # This should return the minimal set of attributes required to create a valid - # CampoForm. As you add validations to CampoForm, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - CampoForm.create! valid_attributes - get campo_forms_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - campo_form = CampoForm.create! valid_attributes - get campo_form_url(campo_form) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_campo_form_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - campo_form = CampoForm.create! valid_attributes - get edit_campo_form_url(campo_form) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new CampoForm" do - expect { - post campo_forms_url, params: { campo_form: valid_attributes } - }.to change(CampoForm, :count).by(1) - end - - it "redirects to the created campo_form" do - post campo_forms_url, params: { campo_form: valid_attributes } - expect(response).to redirect_to(campo_form_url(CampoForm.last)) - end - end - - context "with invalid parameters" do - it "does not create a new CampoForm" do - expect { - post campo_forms_url, params: { campo_form: invalid_attributes } - }.to change(CampoForm, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post campo_forms_url, params: { campo_form: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested campo_form" do - campo_form = CampoForm.create! valid_attributes - patch campo_form_url(campo_form), params: { campo_form: new_attributes } - campo_form.reload - skip("Add assertions for updated state") - end - - it "redirects to the campo_form" do - campo_form = CampoForm.create! valid_attributes - patch campo_form_url(campo_form), params: { campo_form: new_attributes } - campo_form.reload - expect(response).to redirect_to(campo_form_url(campo_form)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - campo_form = CampoForm.create! valid_attributes - patch campo_form_url(campo_form), params: { campo_form: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested campo_form" do - campo_form = CampoForm.create! valid_attributes - expect { - delete campo_form_url(campo_form) - }.to change(CampoForm, :count).by(-1) - end - - it "redirects to the campo_forms list" do - campo_form = CampoForm.create! valid_attributes - delete campo_form_url(campo_form) - expect(response).to redirect_to(campo_forms_url) - end - end -end diff --git a/spec/requests/campos_spec.rb b/spec/requests/campos_spec.rb deleted file mode 100644 index 2710f29740..0000000000 --- a/spec/requests/campos_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/campos", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Campo. As you add validations to Campo, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Campo.create! valid_attributes - get campos_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - campo = Campo.create! valid_attributes - get campo_url(campo) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_campo_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - campo = Campo.create! valid_attributes - get edit_campo_url(campo) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Campo" do - expect { - post campos_url, params: { campo: valid_attributes } - }.to change(Campo, :count).by(1) - end - - it "redirects to the created campo" do - post campos_url, params: { campo: valid_attributes } - expect(response).to redirect_to(campo_url(Campo.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Campo" do - expect { - post campos_url, params: { campo: invalid_attributes } - }.to change(Campo, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post campos_url, params: { campo: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested campo" do - campo = Campo.create! valid_attributes - patch campo_url(campo), params: { campo: new_attributes } - campo.reload - skip("Add assertions for updated state") - end - - it "redirects to the campo" do - campo = Campo.create! valid_attributes - patch campo_url(campo), params: { campo: new_attributes } - campo.reload - expect(response).to redirect_to(campo_url(campo)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - campo = Campo.create! valid_attributes - patch campo_url(campo), params: { campo: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested campo" do - campo = Campo.create! valid_attributes - expect { - delete campo_url(campo) - }.to change(Campo, :count).by(-1) - end - - it "redirects to the campos list" do - campo = Campo.create! valid_attributes - delete campo_url(campo) - expect(response).to redirect_to(campos_url) - end - end -end diff --git a/spec/requests/cursos_spec.rb b/spec/requests/cursos_spec.rb deleted file mode 100644 index ee0aef9826..0000000000 --- a/spec/requests/cursos_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/cursos", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Curso. As you add validations to Curso, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Curso.create! valid_attributes - get cursos_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - curso = Curso.create! valid_attributes - get curso_url(curso) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_curso_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - curso = Curso.create! valid_attributes - get edit_curso_url(curso) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Curso" do - expect { - post cursos_url, params: { curso: valid_attributes } - }.to change(Curso, :count).by(1) - end - - it "redirects to the created curso" do - post cursos_url, params: { curso: valid_attributes } - expect(response).to redirect_to(curso_url(Curso.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Curso" do - expect { - post cursos_url, params: { curso: invalid_attributes } - }.to change(Curso, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post cursos_url, params: { curso: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested curso" do - curso = Curso.create! valid_attributes - patch curso_url(curso), params: { curso: new_attributes } - curso.reload - skip("Add assertions for updated state") - end - - it "redirects to the curso" do - curso = Curso.create! valid_attributes - patch curso_url(curso), params: { curso: new_attributes } - curso.reload - expect(response).to redirect_to(curso_url(curso)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - curso = Curso.create! valid_attributes - patch curso_url(curso), params: { curso: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested curso" do - curso = Curso.create! valid_attributes - expect { - delete curso_url(curso) - }.to change(Curso, :count).by(-1) - end - - it "redirects to the cursos list" do - curso = Curso.create! valid_attributes - delete curso_url(curso) - expect(response).to redirect_to(cursos_url) - end - end -end diff --git a/spec/requests/departamentos_spec.rb b/spec/requests/departamentos_spec.rb deleted file mode 100644 index ca13d8c22e..0000000000 --- a/spec/requests/departamentos_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/departamentos", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Departamento. As you add validations to Departamento, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Departamento.create! valid_attributes - get departamentos_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - departamento = Departamento.create! valid_attributes - get departamento_url(departamento) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_departamento_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - departamento = Departamento.create! valid_attributes - get edit_departamento_url(departamento) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Departamento" do - expect { - post departamentos_url, params: { departamento: valid_attributes } - }.to change(Departamento, :count).by(1) - end - - it "redirects to the created departamento" do - post departamentos_url, params: { departamento: valid_attributes } - expect(response).to redirect_to(departamento_url(Departamento.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Departamento" do - expect { - post departamentos_url, params: { departamento: invalid_attributes } - }.to change(Departamento, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post departamentos_url, params: { departamento: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested departamento" do - departamento = Departamento.create! valid_attributes - patch departamento_url(departamento), params: { departamento: new_attributes } - departamento.reload - skip("Add assertions for updated state") - end - - it "redirects to the departamento" do - departamento = Departamento.create! valid_attributes - patch departamento_url(departamento), params: { departamento: new_attributes } - departamento.reload - expect(response).to redirect_to(departamento_url(departamento)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - departamento = Departamento.create! valid_attributes - patch departamento_url(departamento), params: { departamento: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested departamento" do - departamento = Departamento.create! valid_attributes - expect { - delete departamento_url(departamento) - }.to change(Departamento, :count).by(-1) - end - - it "redirects to the departamentos list" do - departamento = Departamento.create! valid_attributes - delete departamento_url(departamento) - expect(response).to redirect_to(departamentos_url) - end - end -end diff --git a/spec/requests/discentes_spec.rb b/spec/requests/discentes_spec.rb deleted file mode 100644 index f7ab13b634..0000000000 --- a/spec/requests/discentes_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/discentes", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Discente. As you add validations to Discente, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Discente.create! valid_attributes - get discentes_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - discente = Discente.create! valid_attributes - get discente_url(discente) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_discente_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - discente = Discente.create! valid_attributes - get edit_discente_url(discente) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Discente" do - expect { - post discentes_url, params: { discente: valid_attributes } - }.to change(Discente, :count).by(1) - end - - it "redirects to the created discente" do - post discentes_url, params: { discente: valid_attributes } - expect(response).to redirect_to(discente_url(Discente.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Discente" do - expect { - post discentes_url, params: { discente: invalid_attributes } - }.to change(Discente, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post discentes_url, params: { discente: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested discente" do - discente = Discente.create! valid_attributes - patch discente_url(discente), params: { discente: new_attributes } - discente.reload - skip("Add assertions for updated state") - end - - it "redirects to the discente" do - discente = Discente.create! valid_attributes - patch discente_url(discente), params: { discente: new_attributes } - discente.reload - expect(response).to redirect_to(discente_url(discente)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - discente = Discente.create! valid_attributes - patch discente_url(discente), params: { discente: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested discente" do - discente = Discente.create! valid_attributes - expect { - delete discente_url(discente) - }.to change(Discente, :count).by(-1) - end - - it "redirects to the discentes list" do - discente = Discente.create! valid_attributes - delete discente_url(discente) - expect(response).to redirect_to(discentes_url) - end - end -end diff --git a/spec/requests/disciplinas_spec.rb b/spec/requests/disciplinas_spec.rb deleted file mode 100644 index a962a5c82f..0000000000 --- a/spec/requests/disciplinas_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/disciplinas", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Disciplina. As you add validations to Disciplina, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Disciplina.create! valid_attributes - get disciplinas_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - disciplina = Disciplina.create! valid_attributes - get disciplina_url(disciplina) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_disciplina_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - disciplina = Disciplina.create! valid_attributes - get edit_disciplina_url(disciplina) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Disciplina" do - expect { - post disciplinas_url, params: { disciplina: valid_attributes } - }.to change(Disciplina, :count).by(1) - end - - it "redirects to the created disciplina" do - post disciplinas_url, params: { disciplina: valid_attributes } - expect(response).to redirect_to(disciplina_url(Disciplina.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Disciplina" do - expect { - post disciplinas_url, params: { disciplina: invalid_attributes } - }.to change(Disciplina, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post disciplinas_url, params: { disciplina: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested disciplina" do - disciplina = Disciplina.create! valid_attributes - patch disciplina_url(disciplina), params: { disciplina: new_attributes } - disciplina.reload - skip("Add assertions for updated state") - end - - it "redirects to the disciplina" do - disciplina = Disciplina.create! valid_attributes - patch disciplina_url(disciplina), params: { disciplina: new_attributes } - disciplina.reload - expect(response).to redirect_to(disciplina_url(disciplina)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - disciplina = Disciplina.create! valid_attributes - patch disciplina_url(disciplina), params: { disciplina: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested disciplina" do - disciplina = Disciplina.create! valid_attributes - expect { - delete disciplina_url(disciplina) - }.to change(Disciplina, :count).by(-1) - end - - it "redirects to the disciplinas list" do - disciplina = Disciplina.create! valid_attributes - delete disciplina_url(disciplina) - expect(response).to redirect_to(disciplinas_url) - end - end -end diff --git a/spec/requests/docentes_spec.rb b/spec/requests/docentes_spec.rb deleted file mode 100644 index 568fa565f6..0000000000 --- a/spec/requests/docentes_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/docentes", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Docente. As you add validations to Docente, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Docente.create! valid_attributes - get docentes_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - docente = Docente.create! valid_attributes - get docente_url(docente) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_docente_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - docente = Docente.create! valid_attributes - get edit_docente_url(docente) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Docente" do - expect { - post docentes_url, params: { docente: valid_attributes } - }.to change(Docente, :count).by(1) - end - - it "redirects to the created docente" do - post docentes_url, params: { docente: valid_attributes } - expect(response).to redirect_to(docente_url(Docente.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Docente" do - expect { - post docentes_url, params: { docente: invalid_attributes } - }.to change(Docente, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post docentes_url, params: { docente: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested docente" do - docente = Docente.create! valid_attributes - patch docente_url(docente), params: { docente: new_attributes } - docente.reload - skip("Add assertions for updated state") - end - - it "redirects to the docente" do - docente = Docente.create! valid_attributes - patch docente_url(docente), params: { docente: new_attributes } - docente.reload - expect(response).to redirect_to(docente_url(docente)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - docente = Docente.create! valid_attributes - patch docente_url(docente), params: { docente: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested docente" do - docente = Docente.create! valid_attributes - expect { - delete docente_url(docente) - }.to change(Docente, :count).by(-1) - end - - it "redirects to the docentes list" do - docente = Docente.create! valid_attributes - delete docente_url(docente) - expect(response).to redirect_to(docentes_url) - end - end -end diff --git a/spec/requests/elemento_forms_spec.rb b/spec/requests/elemento_forms_spec.rb deleted file mode 100644 index f8d3541e4a..0000000000 --- a/spec/requests/elemento_forms_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/elemento_forms", type: :request do - - # This should return the minimal set of attributes required to create a valid - # ElementoForm. As you add validations to ElementoForm, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - ElementoForm.create! valid_attributes - get elemento_forms_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - elemento_form = ElementoForm.create! valid_attributes - get elemento_form_url(elemento_form) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_elemento_form_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - elemento_form = ElementoForm.create! valid_attributes - get edit_elemento_form_url(elemento_form) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new ElementoForm" do - expect { - post elemento_forms_url, params: { elemento_form: valid_attributes } - }.to change(ElementoForm, :count).by(1) - end - - it "redirects to the created elemento_form" do - post elemento_forms_url, params: { elemento_form: valid_attributes } - expect(response).to redirect_to(elemento_form_url(ElementoForm.last)) - end - end - - context "with invalid parameters" do - it "does not create a new ElementoForm" do - expect { - post elemento_forms_url, params: { elemento_form: invalid_attributes } - }.to change(ElementoForm, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post elemento_forms_url, params: { elemento_form: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested elemento_form" do - elemento_form = ElementoForm.create! valid_attributes - patch elemento_form_url(elemento_form), params: { elemento_form: new_attributes } - elemento_form.reload - skip("Add assertions for updated state") - end - - it "redirects to the elemento_form" do - elemento_form = ElementoForm.create! valid_attributes - patch elemento_form_url(elemento_form), params: { elemento_form: new_attributes } - elemento_form.reload - expect(response).to redirect_to(elemento_form_url(elemento_form)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - elemento_form = ElementoForm.create! valid_attributes - patch elemento_form_url(elemento_form), params: { elemento_form: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested elemento_form" do - elemento_form = ElementoForm.create! valid_attributes - expect { - delete elemento_form_url(elemento_form) - }.to change(ElementoForm, :count).by(-1) - end - - it "redirects to the elemento_forms list" do - elemento_form = ElementoForm.create! valid_attributes - delete elemento_form_url(elemento_form) - expect(response).to redirect_to(elemento_forms_url) - end - end -end diff --git a/spec/requests/elementos_spec.rb b/spec/requests/elementos_spec.rb deleted file mode 100644 index ee5a0a13dc..0000000000 --- a/spec/requests/elementos_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/elementos", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Elemento. As you add validations to Elemento, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Elemento.create! valid_attributes - get elementos_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - elemento = Elemento.create! valid_attributes - get elemento_url(elemento) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_elemento_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - elemento = Elemento.create! valid_attributes - get edit_elemento_url(elemento) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Elemento" do - expect { - post elementos_url, params: { elemento: valid_attributes } - }.to change(Elemento, :count).by(1) - end - - it "redirects to the created elemento" do - post elementos_url, params: { elemento: valid_attributes } - expect(response).to redirect_to(elemento_url(Elemento.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Elemento" do - expect { - post elementos_url, params: { elemento: invalid_attributes } - }.to change(Elemento, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post elementos_url, params: { elemento: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested elemento" do - elemento = Elemento.create! valid_attributes - patch elemento_url(elemento), params: { elemento: new_attributes } - elemento.reload - skip("Add assertions for updated state") - end - - it "redirects to the elemento" do - elemento = Elemento.create! valid_attributes - patch elemento_url(elemento), params: { elemento: new_attributes } - elemento.reload - expect(response).to redirect_to(elemento_url(elemento)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - elemento = Elemento.create! valid_attributes - patch elemento_url(elemento), params: { elemento: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested elemento" do - elemento = Elemento.create! valid_attributes - expect { - delete elemento_url(elemento) - }.to change(Elemento, :count).by(-1) - end - - it "redirects to the elementos list" do - elemento = Elemento.create! valid_attributes - delete elemento_url(elemento) - expect(response).to redirect_to(elementos_url) - end - end -end diff --git a/spec/requests/formularios_spec.rb b/spec/requests/formularios_spec.rb deleted file mode 100644 index 7c7db4ab28..0000000000 --- a/spec/requests/formularios_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/formularios", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Formulario. As you add validations to Formulario, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Formulario.create! valid_attributes - get formularios_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - formulario = Formulario.create! valid_attributes - get formulario_url(formulario) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_formulario_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - formulario = Formulario.create! valid_attributes - get edit_formulario_url(formulario) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Formulario" do - expect { - post formularios_url, params: { formulario: valid_attributes } - }.to change(Formulario, :count).by(1) - end - - it "redirects to the created formulario" do - post formularios_url, params: { formulario: valid_attributes } - expect(response).to redirect_to(formulario_url(Formulario.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Formulario" do - expect { - post formularios_url, params: { formulario: invalid_attributes } - }.to change(Formulario, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post formularios_url, params: { formulario: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested formulario" do - formulario = Formulario.create! valid_attributes - patch formulario_url(formulario), params: { formulario: new_attributes } - formulario.reload - skip("Add assertions for updated state") - end - - it "redirects to the formulario" do - formulario = Formulario.create! valid_attributes - patch formulario_url(formulario), params: { formulario: new_attributes } - formulario.reload - expect(response).to redirect_to(formulario_url(formulario)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - formulario = Formulario.create! valid_attributes - patch formulario_url(formulario), params: { formulario: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested formulario" do - formulario = Formulario.create! valid_attributes - expect { - delete formulario_url(formulario) - }.to change(Formulario, :count).by(-1) - end - - it "redirects to the formularios list" do - formulario = Formulario.create! valid_attributes - delete formulario_url(formulario) - expect(response).to redirect_to(formularios_url) - end - end -end diff --git a/spec/requests/resposta_elems_spec.rb b/spec/requests/resposta_elems_spec.rb deleted file mode 100644 index 839d8680ce..0000000000 --- a/spec/requests/resposta_elems_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/resposta_elems", type: :request do - - # This should return the minimal set of attributes required to create a valid - # RespostaElem. As you add validations to RespostaElem, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - RespostaElem.create! valid_attributes - get resposta_elems_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - resposta_elem = RespostaElem.create! valid_attributes - get resposta_elem_url(resposta_elem) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_resposta_elem_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - resposta_elem = RespostaElem.create! valid_attributes - get edit_resposta_elem_url(resposta_elem) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new RespostaElem" do - expect { - post resposta_elems_url, params: { resposta_elem: valid_attributes } - }.to change(RespostaElem, :count).by(1) - end - - it "redirects to the created resposta_elem" do - post resposta_elems_url, params: { resposta_elem: valid_attributes } - expect(response).to redirect_to(resposta_elem_url(RespostaElem.last)) - end - end - - context "with invalid parameters" do - it "does not create a new RespostaElem" do - expect { - post resposta_elems_url, params: { resposta_elem: invalid_attributes } - }.to change(RespostaElem, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post resposta_elems_url, params: { resposta_elem: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested resposta_elem" do - resposta_elem = RespostaElem.create! valid_attributes - patch resposta_elem_url(resposta_elem), params: { resposta_elem: new_attributes } - resposta_elem.reload - skip("Add assertions for updated state") - end - - it "redirects to the resposta_elem" do - resposta_elem = RespostaElem.create! valid_attributes - patch resposta_elem_url(resposta_elem), params: { resposta_elem: new_attributes } - resposta_elem.reload - expect(response).to redirect_to(resposta_elem_url(resposta_elem)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - resposta_elem = RespostaElem.create! valid_attributes - patch resposta_elem_url(resposta_elem), params: { resposta_elem: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested resposta_elem" do - resposta_elem = RespostaElem.create! valid_attributes - expect { - delete resposta_elem_url(resposta_elem) - }.to change(RespostaElem, :count).by(-1) - end - - it "redirects to the resposta_elems list" do - resposta_elem = RespostaElem.create! valid_attributes - delete resposta_elem_url(resposta_elem) - expect(response).to redirect_to(resposta_elems_url) - end - end -end diff --git a/spec/requests/resposta_forms_spec.rb b/spec/requests/resposta_forms_spec.rb deleted file mode 100644 index 9f35a868f2..0000000000 --- a/spec/requests/resposta_forms_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/resposta_forms", type: :request do - - # This should return the minimal set of attributes required to create a valid - # RespostaForm. As you add validations to RespostaForm, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - RespostaForm.create! valid_attributes - get resposta_forms_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - resposta_form = RespostaForm.create! valid_attributes - get resposta_form_url(resposta_form) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_resposta_form_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - resposta_form = RespostaForm.create! valid_attributes - get edit_resposta_form_url(resposta_form) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new RespostaForm" do - expect { - post resposta_forms_url, params: { resposta_form: valid_attributes } - }.to change(RespostaForm, :count).by(1) - end - - it "redirects to the created resposta_form" do - post resposta_forms_url, params: { resposta_form: valid_attributes } - expect(response).to redirect_to(resposta_form_url(RespostaForm.last)) - end - end - - context "with invalid parameters" do - it "does not create a new RespostaForm" do - expect { - post resposta_forms_url, params: { resposta_form: invalid_attributes } - }.to change(RespostaForm, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post resposta_forms_url, params: { resposta_form: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested resposta_form" do - resposta_form = RespostaForm.create! valid_attributes - patch resposta_form_url(resposta_form), params: { resposta_form: new_attributes } - resposta_form.reload - skip("Add assertions for updated state") - end - - it "redirects to the resposta_form" do - resposta_form = RespostaForm.create! valid_attributes - patch resposta_form_url(resposta_form), params: { resposta_form: new_attributes } - resposta_form.reload - expect(response).to redirect_to(resposta_form_url(resposta_form)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - resposta_form = RespostaForm.create! valid_attributes - patch resposta_form_url(resposta_form), params: { resposta_form: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested resposta_form" do - resposta_form = RespostaForm.create! valid_attributes - expect { - delete resposta_form_url(resposta_form) - }.to change(RespostaForm, :count).by(-1) - end - - it "redirects to the resposta_forms list" do - resposta_form = RespostaForm.create! valid_attributes - delete resposta_form_url(resposta_form) - expect(response).to redirect_to(resposta_forms_url) - end - end -end diff --git a/spec/requests/templates_spec.rb b/spec/requests/templates_spec.rb deleted file mode 100644 index f5401cd1fd..0000000000 --- a/spec/requests/templates_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/templates", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Template. As you add validations to Template, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Template.create! valid_attributes - get templates_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - template = Template.create! valid_attributes - get template_url(template) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_template_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - template = Template.create! valid_attributes - get edit_template_url(template) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Template" do - expect { - post templates_url, params: { template: valid_attributes } - }.to change(Template, :count).by(1) - end - - it "redirects to the created template" do - post templates_url, params: { template: valid_attributes } - expect(response).to redirect_to(template_url(Template.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Template" do - expect { - post templates_url, params: { template: invalid_attributes } - }.to change(Template, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post templates_url, params: { template: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested template" do - template = Template.create! valid_attributes - patch template_url(template), params: { template: new_attributes } - template.reload - skip("Add assertions for updated state") - end - - it "redirects to the template" do - template = Template.create! valid_attributes - patch template_url(template), params: { template: new_attributes } - template.reload - expect(response).to redirect_to(template_url(template)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - template = Template.create! valid_attributes - patch template_url(template), params: { template: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested template" do - template = Template.create! valid_attributes - expect { - delete template_url(template) - }.to change(Template, :count).by(-1) - end - - it "redirects to the templates list" do - template = Template.create! valid_attributes - delete template_url(template) - expect(response).to redirect_to(templates_url) - end - end -end diff --git a/spec/requests/turmas_spec.rb b/spec/requests/turmas_spec.rb deleted file mode 100644 index c86cc681fc..0000000000 --- a/spec/requests/turmas_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/turmas", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Turma. As you add validations to Turma, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Turma.create! valid_attributes - get turmas_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - turma = Turma.create! valid_attributes - get turma_url(turma) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_turma_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - turma = Turma.create! valid_attributes - get edit_turma_url(turma) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Turma" do - expect { - post turmas_url, params: { turma: valid_attributes } - }.to change(Turma, :count).by(1) - end - - it "redirects to the created turma" do - post turmas_url, params: { turma: valid_attributes } - expect(response).to redirect_to(turma_url(Turma.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Turma" do - expect { - post turmas_url, params: { turma: invalid_attributes } - }.to change(Turma, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post turmas_url, params: { turma: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested turma" do - turma = Turma.create! valid_attributes - patch turma_url(turma), params: { turma: new_attributes } - turma.reload - skip("Add assertions for updated state") - end - - it "redirects to the turma" do - turma = Turma.create! valid_attributes - patch turma_url(turma), params: { turma: new_attributes } - turma.reload - expect(response).to redirect_to(turma_url(turma)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - turma = Turma.create! valid_attributes - patch turma_url(turma), params: { turma: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested turma" do - turma = Turma.create! valid_attributes - expect { - delete turma_url(turma) - }.to change(Turma, :count).by(-1) - end - - it "redirects to the turmas list" do - turma = Turma.create! valid_attributes - delete turma_url(turma) - expect(response).to redirect_to(turmas_url) - end - end -end diff --git a/spec/requests/usuarios_spec.rb b/spec/requests/usuarios_spec.rb deleted file mode 100644 index 4f9aabef93..0000000000 --- a/spec/requests/usuarios_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe "/usuarios", type: :request do - - # This should return the minimal set of attributes required to create a valid - # Usuario. As you add validations to Usuario, be sure to - # adjust the attributes here as well. - let(:valid_attributes) { - skip("Add a hash of attributes valid for your model") - } - - let(:invalid_attributes) { - skip("Add a hash of attributes invalid for your model") - } - - describe "GET /index" do - it "renders a successful response" do - Usuario.create! valid_attributes - get usuarios_url - expect(response).to be_successful - end - end - - describe "GET /show" do - it "renders a successful response" do - usuario = Usuario.create! valid_attributes - get usuario_url(usuario) - expect(response).to be_successful - end - end - - describe "GET /new" do - it "renders a successful response" do - get new_usuario_url - expect(response).to be_successful - end - end - - describe "GET /edit" do - it "renders a successful response" do - usuario = Usuario.create! valid_attributes - get edit_usuario_url(usuario) - expect(response).to be_successful - end - end - - describe "POST /create" do - context "with valid parameters" do - it "creates a new Usuario" do - expect { - post usuarios_url, params: { usuario: valid_attributes } - }.to change(Usuario, :count).by(1) - end - - it "redirects to the created usuario" do - post usuarios_url, params: { usuario: valid_attributes } - expect(response).to redirect_to(usuario_url(Usuario.last)) - end - end - - context "with invalid parameters" do - it "does not create a new Usuario" do - expect { - post usuarios_url, params: { usuario: invalid_attributes } - }.to change(Usuario, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post usuarios_url, params: { usuario: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "PATCH /update" do - context "with valid parameters" do - let(:new_attributes) { - skip("Add a hash of attributes valid for your model") - } - - it "updates the requested usuario" do - usuario = Usuario.create! valid_attributes - patch usuario_url(usuario), params: { usuario: new_attributes } - usuario.reload - skip("Add assertions for updated state") - end - - it "redirects to the usuario" do - usuario = Usuario.create! valid_attributes - patch usuario_url(usuario), params: { usuario: new_attributes } - usuario.reload - expect(response).to redirect_to(usuario_url(usuario)) - end - end - - context "with invalid parameters" do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - usuario = Usuario.create! valid_attributes - patch usuario_url(usuario), params: { usuario: invalid_attributes } - expect(response).to have_http_status(:unprocessable_content) - end - end - end - - describe "DELETE /destroy" do - it "destroys the requested usuario" do - usuario = Usuario.create! valid_attributes - expect { - delete usuario_url(usuario) - }.to change(Usuario, :count).by(-1) - end - - it "redirects to the usuarios list" do - usuario = Usuario.create! valid_attributes - delete usuario_url(usuario) - expect(response).to redirect_to(usuarios_url) - end - end -end diff --git a/spec/routing/campo_forms_routing_spec.rb b/spec/routing/campo_forms_routing_spec.rb deleted file mode 100644 index d9ba61251e..0000000000 --- a/spec/routing/campo_forms_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe CampoFormsController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/campo_forms").to route_to("campo_forms#index") - end - - it "routes to #new" do - expect(get: "/campo_forms/new").to route_to("campo_forms#new") - end - - it "routes to #show" do - expect(get: "/campo_forms/1").to route_to("campo_forms#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/campo_forms/1/edit").to route_to("campo_forms#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/campo_forms").to route_to("campo_forms#create") - end - - it "routes to #update via PUT" do - expect(put: "/campo_forms/1").to route_to("campo_forms#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/campo_forms/1").to route_to("campo_forms#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/campo_forms/1").to route_to("campo_forms#destroy", id: "1") - end - end -end diff --git a/spec/routing/campos_routing_spec.rb b/spec/routing/campos_routing_spec.rb deleted file mode 100644 index 810f809b63..0000000000 --- a/spec/routing/campos_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe CamposController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/campos").to route_to("campos#index") - end - - it "routes to #new" do - expect(get: "/campos/new").to route_to("campos#new") - end - - it "routes to #show" do - expect(get: "/campos/1").to route_to("campos#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/campos/1/edit").to route_to("campos#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/campos").to route_to("campos#create") - end - - it "routes to #update via PUT" do - expect(put: "/campos/1").to route_to("campos#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/campos/1").to route_to("campos#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/campos/1").to route_to("campos#destroy", id: "1") - end - end -end diff --git a/spec/routing/cursos_routing_spec.rb b/spec/routing/cursos_routing_spec.rb deleted file mode 100644 index dfebdeafe5..0000000000 --- a/spec/routing/cursos_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe CursosController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/cursos").to route_to("cursos#index") - end - - it "routes to #new" do - expect(get: "/cursos/new").to route_to("cursos#new") - end - - it "routes to #show" do - expect(get: "/cursos/1").to route_to("cursos#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/cursos/1/edit").to route_to("cursos#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/cursos").to route_to("cursos#create") - end - - it "routes to #update via PUT" do - expect(put: "/cursos/1").to route_to("cursos#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/cursos/1").to route_to("cursos#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/cursos/1").to route_to("cursos#destroy", id: "1") - end - end -end diff --git a/spec/routing/departamentos_routing_spec.rb b/spec/routing/departamentos_routing_spec.rb deleted file mode 100644 index 2535d28303..0000000000 --- a/spec/routing/departamentos_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe DepartamentosController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/departamentos").to route_to("departamentos#index") - end - - it "routes to #new" do - expect(get: "/departamentos/new").to route_to("departamentos#new") - end - - it "routes to #show" do - expect(get: "/departamentos/1").to route_to("departamentos#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/departamentos/1/edit").to route_to("departamentos#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/departamentos").to route_to("departamentos#create") - end - - it "routes to #update via PUT" do - expect(put: "/departamentos/1").to route_to("departamentos#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/departamentos/1").to route_to("departamentos#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/departamentos/1").to route_to("departamentos#destroy", id: "1") - end - end -end diff --git a/spec/routing/discentes_routing_spec.rb b/spec/routing/discentes_routing_spec.rb deleted file mode 100644 index 4c39bdec04..0000000000 --- a/spec/routing/discentes_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe DiscentesController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/discentes").to route_to("discentes#index") - end - - it "routes to #new" do - expect(get: "/discentes/new").to route_to("discentes#new") - end - - it "routes to #show" do - expect(get: "/discentes/1").to route_to("discentes#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/discentes/1/edit").to route_to("discentes#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/discentes").to route_to("discentes#create") - end - - it "routes to #update via PUT" do - expect(put: "/discentes/1").to route_to("discentes#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/discentes/1").to route_to("discentes#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/discentes/1").to route_to("discentes#destroy", id: "1") - end - end -end diff --git a/spec/routing/disciplinas_routing_spec.rb b/spec/routing/disciplinas_routing_spec.rb deleted file mode 100644 index 83819acd29..0000000000 --- a/spec/routing/disciplinas_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe DisciplinasController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/disciplinas").to route_to("disciplinas#index") - end - - it "routes to #new" do - expect(get: "/disciplinas/new").to route_to("disciplinas#new") - end - - it "routes to #show" do - expect(get: "/disciplinas/1").to route_to("disciplinas#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/disciplinas/1/edit").to route_to("disciplinas#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/disciplinas").to route_to("disciplinas#create") - end - - it "routes to #update via PUT" do - expect(put: "/disciplinas/1").to route_to("disciplinas#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/disciplinas/1").to route_to("disciplinas#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/disciplinas/1").to route_to("disciplinas#destroy", id: "1") - end - end -end diff --git a/spec/routing/docentes_routing_spec.rb b/spec/routing/docentes_routing_spec.rb deleted file mode 100644 index 552d560638..0000000000 --- a/spec/routing/docentes_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe DocentesController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/docentes").to route_to("docentes#index") - end - - it "routes to #new" do - expect(get: "/docentes/new").to route_to("docentes#new") - end - - it "routes to #show" do - expect(get: "/docentes/1").to route_to("docentes#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/docentes/1/edit").to route_to("docentes#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/docentes").to route_to("docentes#create") - end - - it "routes to #update via PUT" do - expect(put: "/docentes/1").to route_to("docentes#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/docentes/1").to route_to("docentes#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/docentes/1").to route_to("docentes#destroy", id: "1") - end - end -end diff --git a/spec/routing/elemento_forms_routing_spec.rb b/spec/routing/elemento_forms_routing_spec.rb deleted file mode 100644 index 3884645ada..0000000000 --- a/spec/routing/elemento_forms_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe ElementoFormsController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/elemento_forms").to route_to("elemento_forms#index") - end - - it "routes to #new" do - expect(get: "/elemento_forms/new").to route_to("elemento_forms#new") - end - - it "routes to #show" do - expect(get: "/elemento_forms/1").to route_to("elemento_forms#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/elemento_forms/1/edit").to route_to("elemento_forms#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/elemento_forms").to route_to("elemento_forms#create") - end - - it "routes to #update via PUT" do - expect(put: "/elemento_forms/1").to route_to("elemento_forms#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/elemento_forms/1").to route_to("elemento_forms#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/elemento_forms/1").to route_to("elemento_forms#destroy", id: "1") - end - end -end diff --git a/spec/routing/elementos_routing_spec.rb b/spec/routing/elementos_routing_spec.rb deleted file mode 100644 index 18736f399b..0000000000 --- a/spec/routing/elementos_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe ElementosController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/elementos").to route_to("elementos#index") - end - - it "routes to #new" do - expect(get: "/elementos/new").to route_to("elementos#new") - end - - it "routes to #show" do - expect(get: "/elementos/1").to route_to("elementos#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/elementos/1/edit").to route_to("elementos#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/elementos").to route_to("elementos#create") - end - - it "routes to #update via PUT" do - expect(put: "/elementos/1").to route_to("elementos#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/elementos/1").to route_to("elementos#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/elementos/1").to route_to("elementos#destroy", id: "1") - end - end -end diff --git a/spec/routing/formularios_routing_spec.rb b/spec/routing/formularios_routing_spec.rb deleted file mode 100644 index e097ff7208..0000000000 --- a/spec/routing/formularios_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe FormulariosController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/formularios").to route_to("formularios#index") - end - - it "routes to #new" do - expect(get: "/formularios/new").to route_to("formularios#new") - end - - it "routes to #show" do - expect(get: "/formularios/1").to route_to("formularios#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/formularios/1/edit").to route_to("formularios#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/formularios").to route_to("formularios#create") - end - - it "routes to #update via PUT" do - expect(put: "/formularios/1").to route_to("formularios#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/formularios/1").to route_to("formularios#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/formularios/1").to route_to("formularios#destroy", id: "1") - end - end -end diff --git a/spec/routing/resposta_elems_routing_spec.rb b/spec/routing/resposta_elems_routing_spec.rb deleted file mode 100644 index 484e0f9c5c..0000000000 --- a/spec/routing/resposta_elems_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe RespostaElemsController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/resposta_elems").to route_to("resposta_elems#index") - end - - it "routes to #new" do - expect(get: "/resposta_elems/new").to route_to("resposta_elems#new") - end - - it "routes to #show" do - expect(get: "/resposta_elems/1").to route_to("resposta_elems#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/resposta_elems/1/edit").to route_to("resposta_elems#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/resposta_elems").to route_to("resposta_elems#create") - end - - it "routes to #update via PUT" do - expect(put: "/resposta_elems/1").to route_to("resposta_elems#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/resposta_elems/1").to route_to("resposta_elems#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/resposta_elems/1").to route_to("resposta_elems#destroy", id: "1") - end - end -end diff --git a/spec/routing/resposta_forms_routing_spec.rb b/spec/routing/resposta_forms_routing_spec.rb deleted file mode 100644 index e9631021d7..0000000000 --- a/spec/routing/resposta_forms_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe RespostaFormsController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/resposta_forms").to route_to("resposta_forms#index") - end - - it "routes to #new" do - expect(get: "/resposta_forms/new").to route_to("resposta_forms#new") - end - - it "routes to #show" do - expect(get: "/resposta_forms/1").to route_to("resposta_forms#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/resposta_forms/1/edit").to route_to("resposta_forms#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/resposta_forms").to route_to("resposta_forms#create") - end - - it "routes to #update via PUT" do - expect(put: "/resposta_forms/1").to route_to("resposta_forms#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/resposta_forms/1").to route_to("resposta_forms#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/resposta_forms/1").to route_to("resposta_forms#destroy", id: "1") - end - end -end diff --git a/spec/routing/templates_routing_spec.rb b/spec/routing/templates_routing_spec.rb deleted file mode 100644 index b4097ab2ec..0000000000 --- a/spec/routing/templates_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe TemplatesController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/templates").to route_to("templates#index") - end - - it "routes to #new" do - expect(get: "/templates/new").to route_to("templates#new") - end - - it "routes to #show" do - expect(get: "/templates/1").to route_to("templates#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/templates/1/edit").to route_to("templates#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/templates").to route_to("templates#create") - end - - it "routes to #update via PUT" do - expect(put: "/templates/1").to route_to("templates#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/templates/1").to route_to("templates#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/templates/1").to route_to("templates#destroy", id: "1") - end - end -end diff --git a/spec/routing/turmas_routing_spec.rb b/spec/routing/turmas_routing_spec.rb deleted file mode 100644 index 02948b90ab..0000000000 --- a/spec/routing/turmas_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe TurmasController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/turmas").to route_to("turmas#index") - end - - it "routes to #new" do - expect(get: "/turmas/new").to route_to("turmas#new") - end - - it "routes to #show" do - expect(get: "/turmas/1").to route_to("turmas#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/turmas/1/edit").to route_to("turmas#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/turmas").to route_to("turmas#create") - end - - it "routes to #update via PUT" do - expect(put: "/turmas/1").to route_to("turmas#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/turmas/1").to route_to("turmas#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/turmas/1").to route_to("turmas#destroy", id: "1") - end - end -end diff --git a/spec/routing/usuarios_routing_spec.rb b/spec/routing/usuarios_routing_spec.rb deleted file mode 100644 index 93560e3542..0000000000 --- a/spec/routing/usuarios_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe UsuariosController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/usuarios").to route_to("usuarios#index") - end - - it "routes to #new" do - expect(get: "/usuarios/new").to route_to("usuarios#new") - end - - it "routes to #show" do - expect(get: "/usuarios/1").to route_to("usuarios#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/usuarios/1/edit").to route_to("usuarios#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/usuarios").to route_to("usuarios#create") - end - - it "routes to #update via PUT" do - expect(put: "/usuarios/1").to route_to("usuarios#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/usuarios/1").to route_to("usuarios#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/usuarios/1").to route_to("usuarios#destroy", id: "1") - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000000..327b58ea1f --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,94 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ + config.disable_monkey_patching! + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end diff --git a/spec/views/campo_forms/edit.html.erb_spec.rb b/spec/views/campo_forms/edit.html.erb_spec.rb deleted file mode 100644 index f5eb4f1a89..0000000000 --- a/spec/views/campo_forms/edit.html.erb_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'rails_helper' - -RSpec.describe "campo_forms/edit", type: :view do - let(:campo_form) { - CampoForm.create!( - ordem: 1, - enunciado: "MyString", - elemento_form: nil - ) - } - - before(:each) do - assign(:campo_form, campo_form) - end - - it "renders the edit campo_form form" do - render - - assert_select "form[action=?][method=?]", campo_form_path(campo_form), "post" do - - assert_select "input[name=?]", "campo_form[ordem]" - - assert_select "input[name=?]", "campo_form[enunciado]" - - assert_select "input[name=?]", "campo_form[elemento_form_id]" - end - end -end diff --git a/spec/views/campo_forms/index.html.erb_spec.rb b/spec/views/campo_forms/index.html.erb_spec.rb deleted file mode 100644 index 15106f323f..0000000000 --- a/spec/views/campo_forms/index.html.erb_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -RSpec.describe "campo_forms/index", type: :view do - before(:each) do - assign(:campo_forms, [ - CampoForm.create!( - ordem: 2, - enunciado: "Enunciado", - elemento_form: nil - ), - CampoForm.create!( - ordem: 2, - enunciado: "Enunciado", - elemento_form: nil - ) - ]) - end - - it "renders a list of campo_forms" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new(2.to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Enunciado".to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/campo_forms/new.html.erb_spec.rb b/spec/views/campo_forms/new.html.erb_spec.rb deleted file mode 100644 index ce55db9ba5..0000000000 --- a/spec/views/campo_forms/new.html.erb_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -RSpec.describe "campo_forms/new", type: :view do - before(:each) do - assign(:campo_form, CampoForm.new( - ordem: 1, - enunciado: "MyString", - elemento_form: nil - )) - end - - it "renders new campo_form form" do - render - - assert_select "form[action=?][method=?]", campo_forms_path, "post" do - - assert_select "input[name=?]", "campo_form[ordem]" - - assert_select "input[name=?]", "campo_form[enunciado]" - - assert_select "input[name=?]", "campo_form[elemento_form_id]" - end - end -end diff --git a/spec/views/campo_forms/show.html.erb_spec.rb b/spec/views/campo_forms/show.html.erb_spec.rb deleted file mode 100644 index fa8c4b8bbc..0000000000 --- a/spec/views/campo_forms/show.html.erb_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe "campo_forms/show", type: :view do - before(:each) do - assign(:campo_form, CampoForm.create!( - ordem: 2, - enunciado: "Enunciado", - elemento_form: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/2/) - expect(rendered).to match(/Enunciado/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/campos/edit.html.erb_spec.rb b/spec/views/campos/edit.html.erb_spec.rb deleted file mode 100644 index 4d41e61ea8..0000000000 --- a/spec/views/campos/edit.html.erb_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'rails_helper' - -RSpec.describe "campos/edit", type: :view do - let(:campo) { - Campo.create!( - ordem: 1, - enunciado: "MyString", - tipo_elemento: "MyString", - elemento: nil - ) - } - - before(:each) do - assign(:campo, campo) - end - - it "renders the edit campo form" do - render - - assert_select "form[action=?][method=?]", campo_path(campo), "post" do - - assert_select "input[name=?]", "campo[ordem]" - - assert_select "input[name=?]", "campo[enunciado]" - - assert_select "input[name=?]", "campo[tipo_elemento]" - - assert_select "input[name=?]", "campo[elemento_id]" - end - end -end diff --git a/spec/views/campos/index.html.erb_spec.rb b/spec/views/campos/index.html.erb_spec.rb deleted file mode 100644 index 049bf5f10a..0000000000 --- a/spec/views/campos/index.html.erb_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'rails_helper' - -RSpec.describe "campos/index", type: :view do - before(:each) do - assign(:campos, [ - Campo.create!( - ordem: 2, - enunciado: "Enunciado", - tipo_elemento: "Tipo Elemento", - elemento: nil - ), - Campo.create!( - ordem: 2, - enunciado: "Enunciado", - tipo_elemento: "Tipo Elemento", - elemento: nil - ) - ]) - end - - it "renders a list of campos" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new(2.to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Enunciado".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Tipo Elemento".to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/campos/new.html.erb_spec.rb b/spec/views/campos/new.html.erb_spec.rb deleted file mode 100644 index ed753d8787..0000000000 --- a/spec/views/campos/new.html.erb_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -RSpec.describe "campos/new", type: :view do - before(:each) do - assign(:campo, Campo.new( - ordem: 1, - enunciado: "MyString", - tipo_elemento: "MyString", - elemento: nil - )) - end - - it "renders new campo form" do - render - - assert_select "form[action=?][method=?]", campos_path, "post" do - - assert_select "input[name=?]", "campo[ordem]" - - assert_select "input[name=?]", "campo[enunciado]" - - assert_select "input[name=?]", "campo[tipo_elemento]" - - assert_select "input[name=?]", "campo[elemento_id]" - end - end -end diff --git a/spec/views/campos/show.html.erb_spec.rb b/spec/views/campos/show.html.erb_spec.rb deleted file mode 100644 index 13b5a5a9a9..0000000000 --- a/spec/views/campos/show.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe "campos/show", type: :view do - before(:each) do - assign(:campo, Campo.create!( - ordem: 2, - enunciado: "Enunciado", - tipo_elemento: "Tipo Elemento", - elemento: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/2/) - expect(rendered).to match(/Enunciado/) - expect(rendered).to match(/Tipo Elemento/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/cursos/edit.html.erb_spec.rb b/spec/views/cursos/edit.html.erb_spec.rb deleted file mode 100644 index b20d018e98..0000000000 --- a/spec/views/cursos/edit.html.erb_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'rails_helper' - -RSpec.describe "cursos/edit", type: :view do - let(:curso) { - Curso.create!( - codigo: "MyString", - nome: "MyString", - departamento: nil - ) - } - - before(:each) do - assign(:curso, curso) - end - - it "renders the edit curso form" do - render - - assert_select "form[action=?][method=?]", curso_path(curso), "post" do - - assert_select "input[name=?]", "curso[codigo]" - - assert_select "input[name=?]", "curso[nome]" - - assert_select "input[name=?]", "curso[departamento_id]" - end - end -end diff --git a/spec/views/cursos/index.html.erb_spec.rb b/spec/views/cursos/index.html.erb_spec.rb deleted file mode 100644 index c61ac472ee..0000000000 --- a/spec/views/cursos/index.html.erb_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -RSpec.describe "cursos/index", type: :view do - before(:each) do - assign(:cursos, [ - Curso.create!( - codigo: "Codigo", - nome: "Nome", - departamento: nil - ), - Curso.create!( - codigo: "Codigo", - nome: "Nome", - departamento: nil - ) - ]) - end - - it "renders a list of cursos" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new("Codigo".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/cursos/new.html.erb_spec.rb b/spec/views/cursos/new.html.erb_spec.rb deleted file mode 100644 index 61507c55a0..0000000000 --- a/spec/views/cursos/new.html.erb_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -RSpec.describe "cursos/new", type: :view do - before(:each) do - assign(:curso, Curso.new( - codigo: "MyString", - nome: "MyString", - departamento: nil - )) - end - - it "renders new curso form" do - render - - assert_select "form[action=?][method=?]", cursos_path, "post" do - - assert_select "input[name=?]", "curso[codigo]" - - assert_select "input[name=?]", "curso[nome]" - - assert_select "input[name=?]", "curso[departamento_id]" - end - end -end diff --git a/spec/views/cursos/show.html.erb_spec.rb b/spec/views/cursos/show.html.erb_spec.rb deleted file mode 100644 index a96f7138e1..0000000000 --- a/spec/views/cursos/show.html.erb_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe "cursos/show", type: :view do - before(:each) do - assign(:curso, Curso.create!( - codigo: "Codigo", - nome: "Nome", - departamento: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/Codigo/) - expect(rendered).to match(/Nome/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/departamentos/edit.html.erb_spec.rb b/spec/views/departamentos/edit.html.erb_spec.rb deleted file mode 100644 index c043a47855..0000000000 --- a/spec/views/departamentos/edit.html.erb_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'rails_helper' - -RSpec.describe "departamentos/edit", type: :view do - let(:departamento) { - Departamento.create!( - codigo: "MyString", - nome: "MyString" - ) - } - - before(:each) do - assign(:departamento, departamento) - end - - it "renders the edit departamento form" do - render - - assert_select "form[action=?][method=?]", departamento_path(departamento), "post" do - - assert_select "input[name=?]", "departamento[codigo]" - - assert_select "input[name=?]", "departamento[nome]" - end - end -end diff --git a/spec/views/departamentos/index.html.erb_spec.rb b/spec/views/departamentos/index.html.erb_spec.rb deleted file mode 100644 index d7dae7c4b6..0000000000 --- a/spec/views/departamentos/index.html.erb_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -RSpec.describe "departamentos/index", type: :view do - before(:each) do - assign(:departamentos, [ - Departamento.create!( - codigo: "Codigo", - nome: "Nome" - ), - Departamento.create!( - codigo: "Codigo", - nome: "Nome" - ) - ]) - end - - it "renders a list of departamentos" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new("Codigo".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 - end -end diff --git a/spec/views/departamentos/new.html.erb_spec.rb b/spec/views/departamentos/new.html.erb_spec.rb deleted file mode 100644 index 72750b9386..0000000000 --- a/spec/views/departamentos/new.html.erb_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -RSpec.describe "departamentos/new", type: :view do - before(:each) do - assign(:departamento, Departamento.new( - codigo: "MyString", - nome: "MyString" - )) - end - - it "renders new departamento form" do - render - - assert_select "form[action=?][method=?]", departamentos_path, "post" do - - assert_select "input[name=?]", "departamento[codigo]" - - assert_select "input[name=?]", "departamento[nome]" - end - end -end diff --git a/spec/views/departamentos/show.html.erb_spec.rb b/spec/views/departamentos/show.html.erb_spec.rb deleted file mode 100644 index b861f35e57..0000000000 --- a/spec/views/departamentos/show.html.erb_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -RSpec.describe "departamentos/show", type: :view do - before(:each) do - assign(:departamento, Departamento.create!( - codigo: "Codigo", - nome: "Nome" - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/Codigo/) - expect(rendered).to match(/Nome/) - end -end diff --git a/spec/views/discentes/edit.html.erb_spec.rb b/spec/views/discentes/edit.html.erb_spec.rb deleted file mode 100644 index 6036522f78..0000000000 --- a/spec/views/discentes/edit.html.erb_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'rails_helper' - -RSpec.describe "discentes/edit", type: :view do - let(:discente) { - Discente.create!( - matricula: "MyString", - email: "MyString", - nome: "MyString", - formacao: "MyString", - curso: nil - ) - } - - before(:each) do - assign(:discente, discente) - end - - it "renders the edit discente form" do - render - - assert_select "form[action=?][method=?]", discente_path(discente), "post" do - - assert_select "input[name=?]", "discente[matricula]" - - assert_select "input[name=?]", "discente[email]" - - assert_select "input[name=?]", "discente[nome]" - - assert_select "input[name=?]", "discente[formacao]" - - assert_select "input[name=?]", "discente[curso_id]" - end - end -end diff --git a/spec/views/discentes/index.html.erb_spec.rb b/spec/views/discentes/index.html.erb_spec.rb deleted file mode 100644 index d3e2f67e0b..0000000000 --- a/spec/views/discentes/index.html.erb_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'rails_helper' - -RSpec.describe "discentes/index", type: :view do - before(:each) do - assign(:discentes, [ - Discente.create!( - matricula: "Matricula", - email: "Email", - nome: "Nome", - formacao: "Formacao", - curso: nil - ), - Discente.create!( - matricula: "Matricula", - email: "Email", - nome: "Nome", - formacao: "Formacao", - curso: nil - ) - ]) - end - - it "renders a list of discentes" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new("Matricula".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Email".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Formacao".to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/discentes/new.html.erb_spec.rb b/spec/views/discentes/new.html.erb_spec.rb deleted file mode 100644 index de51ff61bd..0000000000 --- a/spec/views/discentes/new.html.erb_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rails_helper' - -RSpec.describe "discentes/new", type: :view do - before(:each) do - assign(:discente, Discente.new( - matricula: "MyString", - email: "MyString", - nome: "MyString", - formacao: "MyString", - curso: nil - )) - end - - it "renders new discente form" do - render - - assert_select "form[action=?][method=?]", discentes_path, "post" do - - assert_select "input[name=?]", "discente[matricula]" - - assert_select "input[name=?]", "discente[email]" - - assert_select "input[name=?]", "discente[nome]" - - assert_select "input[name=?]", "discente[formacao]" - - assert_select "input[name=?]", "discente[curso_id]" - end - end -end diff --git a/spec/views/discentes/show.html.erb_spec.rb b/spec/views/discentes/show.html.erb_spec.rb deleted file mode 100644 index 112906e380..0000000000 --- a/spec/views/discentes/show.html.erb_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'rails_helper' - -RSpec.describe "discentes/show", type: :view do - before(:each) do - assign(:discente, Discente.create!( - matricula: "Matricula", - email: "Email", - nome: "Nome", - formacao: "Formacao", - curso: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/Matricula/) - expect(rendered).to match(/Email/) - expect(rendered).to match(/Nome/) - expect(rendered).to match(/Formacao/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/disciplinas/edit.html.erb_spec.rb b/spec/views/disciplinas/edit.html.erb_spec.rb deleted file mode 100644 index 7e0c14497a..0000000000 --- a/spec/views/disciplinas/edit.html.erb_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'rails_helper' - -RSpec.describe "disciplinas/edit", type: :view do - let(:disciplina) { - Disciplina.create!( - codigo: "MyString", - nome: "MyString", - departamento: nil - ) - } - - before(:each) do - assign(:disciplina, disciplina) - end - - it "renders the edit disciplina form" do - render - - assert_select "form[action=?][method=?]", disciplina_path(disciplina), "post" do - - assert_select "input[name=?]", "disciplina[codigo]" - - assert_select "input[name=?]", "disciplina[nome]" - - assert_select "input[name=?]", "disciplina[departamento_id]" - end - end -end diff --git a/spec/views/disciplinas/index.html.erb_spec.rb b/spec/views/disciplinas/index.html.erb_spec.rb deleted file mode 100644 index a0ce132015..0000000000 --- a/spec/views/disciplinas/index.html.erb_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -RSpec.describe "disciplinas/index", type: :view do - before(:each) do - assign(:disciplinas, [ - Disciplina.create!( - codigo: "Codigo", - nome: "Nome", - departamento: nil - ), - Disciplina.create!( - codigo: "Codigo", - nome: "Nome", - departamento: nil - ) - ]) - end - - it "renders a list of disciplinas" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new("Codigo".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/disciplinas/new.html.erb_spec.rb b/spec/views/disciplinas/new.html.erb_spec.rb deleted file mode 100644 index 399d554eb4..0000000000 --- a/spec/views/disciplinas/new.html.erb_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -RSpec.describe "disciplinas/new", type: :view do - before(:each) do - assign(:disciplina, Disciplina.new( - codigo: "MyString", - nome: "MyString", - departamento: nil - )) - end - - it "renders new disciplina form" do - render - - assert_select "form[action=?][method=?]", disciplinas_path, "post" do - - assert_select "input[name=?]", "disciplina[codigo]" - - assert_select "input[name=?]", "disciplina[nome]" - - assert_select "input[name=?]", "disciplina[departamento_id]" - end - end -end diff --git a/spec/views/disciplinas/show.html.erb_spec.rb b/spec/views/disciplinas/show.html.erb_spec.rb deleted file mode 100644 index c454aa05fe..0000000000 --- a/spec/views/disciplinas/show.html.erb_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe "disciplinas/show", type: :view do - before(:each) do - assign(:disciplina, Disciplina.create!( - codigo: "Codigo", - nome: "Nome", - departamento: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/Codigo/) - expect(rendered).to match(/Nome/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/docentes/edit.html.erb_spec.rb b/spec/views/docentes/edit.html.erb_spec.rb deleted file mode 100644 index 4efd057927..0000000000 --- a/spec/views/docentes/edit.html.erb_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'rails_helper' - -RSpec.describe "docentes/edit", type: :view do - let(:docente) { - Docente.create!( - matricula: "MyString", - email: "MyString", - nome: "MyString", - formacao: "MyString" - ) - } - - before(:each) do - assign(:docente, docente) - end - - it "renders the edit docente form" do - render - - assert_select "form[action=?][method=?]", docente_path(docente), "post" do - - assert_select "input[name=?]", "docente[matricula]" - - assert_select "input[name=?]", "docente[email]" - - assert_select "input[name=?]", "docente[nome]" - - assert_select "input[name=?]", "docente[formacao]" - end - end -end diff --git a/spec/views/docentes/index.html.erb_spec.rb b/spec/views/docentes/index.html.erb_spec.rb deleted file mode 100644 index 607f2ff85b..0000000000 --- a/spec/views/docentes/index.html.erb_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'rails_helper' - -RSpec.describe "docentes/index", type: :view do - before(:each) do - assign(:docentes, [ - Docente.create!( - matricula: "Matricula", - email: "Email", - nome: "Nome", - formacao: "Formacao" - ), - Docente.create!( - matricula: "Matricula", - email: "Email", - nome: "Nome", - formacao: "Formacao" - ) - ]) - end - - it "renders a list of docentes" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new("Matricula".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Email".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Formacao".to_s), count: 2 - end -end diff --git a/spec/views/docentes/new.html.erb_spec.rb b/spec/views/docentes/new.html.erb_spec.rb deleted file mode 100644 index 47b12f4329..0000000000 --- a/spec/views/docentes/new.html.erb_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -RSpec.describe "docentes/new", type: :view do - before(:each) do - assign(:docente, Docente.new( - matricula: "MyString", - email: "MyString", - nome: "MyString", - formacao: "MyString" - )) - end - - it "renders new docente form" do - render - - assert_select "form[action=?][method=?]", docentes_path, "post" do - - assert_select "input[name=?]", "docente[matricula]" - - assert_select "input[name=?]", "docente[email]" - - assert_select "input[name=?]", "docente[nome]" - - assert_select "input[name=?]", "docente[formacao]" - end - end -end diff --git a/spec/views/docentes/show.html.erb_spec.rb b/spec/views/docentes/show.html.erb_spec.rb deleted file mode 100644 index ae9b8987d0..0000000000 --- a/spec/views/docentes/show.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe "docentes/show", type: :view do - before(:each) do - assign(:docente, Docente.create!( - matricula: "Matricula", - email: "Email", - nome: "Nome", - formacao: "Formacao" - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/Matricula/) - expect(rendered).to match(/Email/) - expect(rendered).to match(/Nome/) - expect(rendered).to match(/Formacao/) - end -end diff --git a/spec/views/elemento_forms/edit.html.erb_spec.rb b/spec/views/elemento_forms/edit.html.erb_spec.rb deleted file mode 100644 index a25c3a7389..0000000000 --- a/spec/views/elemento_forms/edit.html.erb_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'rails_helper' - -RSpec.describe "elemento_forms/edit", type: :view do - let(:elemento_form) { - ElementoForm.create!( - ordem: 1, - enunciado: "MyString", - formulario: nil - ) - } - - before(:each) do - assign(:elemento_form, elemento_form) - end - - it "renders the edit elemento_form form" do - render - - assert_select "form[action=?][method=?]", elemento_form_path(elemento_form), "post" do - - assert_select "input[name=?]", "elemento_form[ordem]" - - assert_select "input[name=?]", "elemento_form[enunciado]" - - assert_select "input[name=?]", "elemento_form[formulario_id]" - end - end -end diff --git a/spec/views/elemento_forms/index.html.erb_spec.rb b/spec/views/elemento_forms/index.html.erb_spec.rb deleted file mode 100644 index c86baf8d4a..0000000000 --- a/spec/views/elemento_forms/index.html.erb_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -RSpec.describe "elemento_forms/index", type: :view do - before(:each) do - assign(:elemento_forms, [ - ElementoForm.create!( - ordem: 2, - enunciado: "Enunciado", - formulario: nil - ), - ElementoForm.create!( - ordem: 2, - enunciado: "Enunciado", - formulario: nil - ) - ]) - end - - it "renders a list of elemento_forms" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new(2.to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Enunciado".to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/elemento_forms/new.html.erb_spec.rb b/spec/views/elemento_forms/new.html.erb_spec.rb deleted file mode 100644 index 9fb02ca849..0000000000 --- a/spec/views/elemento_forms/new.html.erb_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -RSpec.describe "elemento_forms/new", type: :view do - before(:each) do - assign(:elemento_form, ElementoForm.new( - ordem: 1, - enunciado: "MyString", - formulario: nil - )) - end - - it "renders new elemento_form form" do - render - - assert_select "form[action=?][method=?]", elemento_forms_path, "post" do - - assert_select "input[name=?]", "elemento_form[ordem]" - - assert_select "input[name=?]", "elemento_form[enunciado]" - - assert_select "input[name=?]", "elemento_form[formulario_id]" - end - end -end diff --git a/spec/views/elemento_forms/show.html.erb_spec.rb b/spec/views/elemento_forms/show.html.erb_spec.rb deleted file mode 100644 index b117069837..0000000000 --- a/spec/views/elemento_forms/show.html.erb_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe "elemento_forms/show", type: :view do - before(:each) do - assign(:elemento_form, ElementoForm.create!( - ordem: 2, - enunciado: "Enunciado", - formulario: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/2/) - expect(rendered).to match(/Enunciado/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/elementos/edit.html.erb_spec.rb b/spec/views/elementos/edit.html.erb_spec.rb deleted file mode 100644 index 7331812d36..0000000000 --- a/spec/views/elementos/edit.html.erb_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'rails_helper' - -RSpec.describe "elementos/edit", type: :view do - let(:elemento) { - Elemento.create!( - ordem: 1, - enunciado: "MyString", - template: nil - ) - } - - before(:each) do - assign(:elemento, elemento) - end - - it "renders the edit elemento form" do - render - - assert_select "form[action=?][method=?]", elemento_path(elemento), "post" do - - assert_select "input[name=?]", "elemento[ordem]" - - assert_select "input[name=?]", "elemento[enunciado]" - - assert_select "input[name=?]", "elemento[template_id]" - end - end -end diff --git a/spec/views/elementos/index.html.erb_spec.rb b/spec/views/elementos/index.html.erb_spec.rb deleted file mode 100644 index b71ab9bc50..0000000000 --- a/spec/views/elementos/index.html.erb_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -RSpec.describe "elementos/index", type: :view do - before(:each) do - assign(:elementos, [ - Elemento.create!( - ordem: 2, - enunciado: "Enunciado", - template: nil - ), - Elemento.create!( - ordem: 2, - enunciado: "Enunciado", - template: nil - ) - ]) - end - - it "renders a list of elementos" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new(2.to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Enunciado".to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/elementos/new.html.erb_spec.rb b/spec/views/elementos/new.html.erb_spec.rb deleted file mode 100644 index a0e976d8f6..0000000000 --- a/spec/views/elementos/new.html.erb_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'rails_helper' - -RSpec.describe "elementos/new", type: :view do - before(:each) do - assign(:elemento, Elemento.new( - ordem: 1, - enunciado: "MyString", - template: nil - )) - end - - it "renders new elemento form" do - render - - assert_select "form[action=?][method=?]", elementos_path, "post" do - - assert_select "input[name=?]", "elemento[ordem]" - - assert_select "input[name=?]", "elemento[enunciado]" - - assert_select "input[name=?]", "elemento[template_id]" - end - end -end diff --git a/spec/views/elementos/show.html.erb_spec.rb b/spec/views/elementos/show.html.erb_spec.rb deleted file mode 100644 index 08e9893960..0000000000 --- a/spec/views/elementos/show.html.erb_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe "elementos/show", type: :view do - before(:each) do - assign(:elemento, Elemento.create!( - ordem: 2, - enunciado: "Enunciado", - template: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/2/) - expect(rendered).to match(/Enunciado/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/formularios/edit.html.erb_spec.rb b/spec/views/formularios/edit.html.erb_spec.rb deleted file mode 100644 index 118f90cb9f..0000000000 --- a/spec/views/formularios/edit.html.erb_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'rails_helper' - -RSpec.describe "formularios/edit", type: :view do - let(:formulario) { - Formulario.create!( - turma: nil - ) - } - - before(:each) do - assign(:formulario, formulario) - end - - it "renders the edit formulario form" do - render - - assert_select "form[action=?][method=?]", formulario_path(formulario), "post" do - - assert_select "input[name=?]", "formulario[turma_id]" - end - end -end diff --git a/spec/views/formularios/index.html.erb_spec.rb b/spec/views/formularios/index.html.erb_spec.rb deleted file mode 100644 index e7eb943e54..0000000000 --- a/spec/views/formularios/index.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe "formularios/index", type: :view do - before(:each) do - assign(:formularios, [ - Formulario.create!( - turma: nil - ), - Formulario.create!( - turma: nil - ) - ]) - end - - it "renders a list of formularios" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/formularios/new.html.erb_spec.rb b/spec/views/formularios/new.html.erb_spec.rb deleted file mode 100644 index 84fd52bf73..0000000000 --- a/spec/views/formularios/new.html.erb_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe "formularios/new", type: :view do - before(:each) do - assign(:formulario, Formulario.new( - turma: nil - )) - end - - it "renders new formulario form" do - render - - assert_select "form[action=?][method=?]", formularios_path, "post" do - - assert_select "input[name=?]", "formulario[turma_id]" - end - end -end diff --git a/spec/views/formularios/show.html.erb_spec.rb b/spec/views/formularios/show.html.erb_spec.rb deleted file mode 100644 index e66b8bc106..0000000000 --- a/spec/views/formularios/show.html.erb_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -RSpec.describe "formularios/show", type: :view do - before(:each) do - assign(:formulario, Formulario.create!( - turma: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(//) - end -end diff --git a/spec/views/resposta_elems/edit.html.erb_spec.rb b/spec/views/resposta_elems/edit.html.erb_spec.rb deleted file mode 100644 index 39fe881633..0000000000 --- a/spec/views/resposta_elems/edit.html.erb_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'rails_helper' - -RSpec.describe "resposta_elems/edit", type: :view do - let(:resposta_elem) { - RespostaElem.create!( - texto_resposta: "MyText", - resposta_form: nil, - elemento_form: nil, - campo_form: nil - ) - } - - before(:each) do - assign(:resposta_elem, resposta_elem) - end - - it "renders the edit resposta_elem form" do - render - - assert_select "form[action=?][method=?]", resposta_elem_path(resposta_elem), "post" do - - assert_select "textarea[name=?]", "resposta_elem[texto_resposta]" - - assert_select "input[name=?]", "resposta_elem[resposta_form_id]" - - assert_select "input[name=?]", "resposta_elem[elemento_form_id]" - - assert_select "input[name=?]", "resposta_elem[campo_form_id]" - end - end -end diff --git a/spec/views/resposta_elems/index.html.erb_spec.rb b/spec/views/resposta_elems/index.html.erb_spec.rb deleted file mode 100644 index 0b4c0af7e9..0000000000 --- a/spec/views/resposta_elems/index.html.erb_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'rails_helper' - -RSpec.describe "resposta_elems/index", type: :view do - before(:each) do - assign(:resposta_elems, [ - RespostaElem.create!( - texto_resposta: "MyText", - resposta_form: nil, - elemento_form: nil, - campo_form: nil - ), - RespostaElem.create!( - texto_resposta: "MyText", - resposta_form: nil, - elemento_form: nil, - campo_form: nil - ) - ]) - end - - it "renders a list of resposta_elems" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new("MyText".to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/resposta_elems/new.html.erb_spec.rb b/spec/views/resposta_elems/new.html.erb_spec.rb deleted file mode 100644 index c8690f2b7c..0000000000 --- a/spec/views/resposta_elems/new.html.erb_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -RSpec.describe "resposta_elems/new", type: :view do - before(:each) do - assign(:resposta_elem, RespostaElem.new( - texto_resposta: "MyText", - resposta_form: nil, - elemento_form: nil, - campo_form: nil - )) - end - - it "renders new resposta_elem form" do - render - - assert_select "form[action=?][method=?]", resposta_elems_path, "post" do - - assert_select "textarea[name=?]", "resposta_elem[texto_resposta]" - - assert_select "input[name=?]", "resposta_elem[resposta_form_id]" - - assert_select "input[name=?]", "resposta_elem[elemento_form_id]" - - assert_select "input[name=?]", "resposta_elem[campo_form_id]" - end - end -end diff --git a/spec/views/resposta_elems/show.html.erb_spec.rb b/spec/views/resposta_elems/show.html.erb_spec.rb deleted file mode 100644 index 630a18fae4..0000000000 --- a/spec/views/resposta_elems/show.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe "resposta_elems/show", type: :view do - before(:each) do - assign(:resposta_elem, RespostaElem.create!( - texto_resposta: "MyText", - resposta_form: nil, - elemento_form: nil, - campo_form: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/MyText/) - expect(rendered).to match(//) - expect(rendered).to match(//) - expect(rendered).to match(//) - end -end diff --git a/spec/views/resposta_forms/edit.html.erb_spec.rb b/spec/views/resposta_forms/edit.html.erb_spec.rb deleted file mode 100644 index 3428042fb5..0000000000 --- a/spec/views/resposta_forms/edit.html.erb_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'rails_helper' - -RSpec.describe "resposta_forms/edit", type: :view do - let(:resposta_form) { - RespostaForm.create!( - formulario: nil, - usuario: nil - ) - } - - before(:each) do - assign(:resposta_form, resposta_form) - end - - it "renders the edit resposta_form form" do - render - - assert_select "form[action=?][method=?]", resposta_form_path(resposta_form), "post" do - - assert_select "input[name=?]", "resposta_form[formulario_id]" - - assert_select "input[name=?]", "resposta_form[usuario_id]" - end - end -end diff --git a/spec/views/resposta_forms/index.html.erb_spec.rb b/spec/views/resposta_forms/index.html.erb_spec.rb deleted file mode 100644 index 01ac5cec14..0000000000 --- a/spec/views/resposta_forms/index.html.erb_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -RSpec.describe "resposta_forms/index", type: :view do - before(:each) do - assign(:resposta_forms, [ - RespostaForm.create!( - formulario: nil, - usuario: nil - ), - RespostaForm.create!( - formulario: nil, - usuario: nil - ) - ]) - end - - it "renders a list of resposta_forms" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/resposta_forms/new.html.erb_spec.rb b/spec/views/resposta_forms/new.html.erb_spec.rb deleted file mode 100644 index e531fe422b..0000000000 --- a/spec/views/resposta_forms/new.html.erb_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -RSpec.describe "resposta_forms/new", type: :view do - before(:each) do - assign(:resposta_form, RespostaForm.new( - formulario: nil, - usuario: nil - )) - end - - it "renders new resposta_form form" do - render - - assert_select "form[action=?][method=?]", resposta_forms_path, "post" do - - assert_select "input[name=?]", "resposta_form[formulario_id]" - - assert_select "input[name=?]", "resposta_form[usuario_id]" - end - end -end diff --git a/spec/views/resposta_forms/show.html.erb_spec.rb b/spec/views/resposta_forms/show.html.erb_spec.rb deleted file mode 100644 index 89e82f5b91..0000000000 --- a/spec/views/resposta_forms/show.html.erb_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'rails_helper' - -RSpec.describe "resposta_forms/show", type: :view do - before(:each) do - assign(:resposta_form, RespostaForm.create!( - formulario: nil, - usuario: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(//) - expect(rendered).to match(//) - end -end diff --git a/spec/views/templates/edit.html.erb_spec.rb b/spec/views/templates/edit.html.erb_spec.rb deleted file mode 100644 index 59b1ad2327..0000000000 --- a/spec/views/templates/edit.html.erb_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'rails_helper' - -RSpec.describe "templates/edit", type: :view do - let(:template) { - Template.create!( - nome: "MyString" - ) - } - - before(:each) do - assign(:template, template) - end - - it "renders the edit template form" do - render - - assert_select "form[action=?][method=?]", template_path(template), "post" do - - assert_select "input[name=?]", "template[nome]" - end - end -end diff --git a/spec/views/templates/index.html.erb_spec.rb b/spec/views/templates/index.html.erb_spec.rb deleted file mode 100644 index cd2287c874..0000000000 --- a/spec/views/templates/index.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe "templates/index", type: :view do - before(:each) do - assign(:templates, [ - Template.create!( - nome: "Nome" - ), - Template.create!( - nome: "Nome" - ) - ]) - end - - it "renders a list of templates" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 - end -end diff --git a/spec/views/templates/new.html.erb_spec.rb b/spec/views/templates/new.html.erb_spec.rb deleted file mode 100644 index 17344a3896..0000000000 --- a/spec/views/templates/new.html.erb_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe "templates/new", type: :view do - before(:each) do - assign(:template, Template.new( - nome: "MyString" - )) - end - - it "renders new template form" do - render - - assert_select "form[action=?][method=?]", templates_path, "post" do - - assert_select "input[name=?]", "template[nome]" - end - end -end diff --git a/spec/views/templates/show.html.erb_spec.rb b/spec/views/templates/show.html.erb_spec.rb deleted file mode 100644 index 760068a39e..0000000000 --- a/spec/views/templates/show.html.erb_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -RSpec.describe "templates/show", type: :view do - before(:each) do - assign(:template, Template.create!( - nome: "Nome" - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/Nome/) - end -end diff --git a/spec/views/turmas/edit.html.erb_spec.rb b/spec/views/turmas/edit.html.erb_spec.rb deleted file mode 100644 index 367c9ec974..0000000000 --- a/spec/views/turmas/edit.html.erb_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'rails_helper' - -RSpec.describe "turmas/edit", type: :view do - let(:turma) { - Turma.create!( - numero_da_turma: "MyString", - semestre: "MyString", - horario: "MyString", - disciplina: nil - ) - } - - before(:each) do - assign(:turma, turma) - end - - it "renders the edit turma form" do - render - - assert_select "form[action=?][method=?]", turma_path(turma), "post" do - - assert_select "input[name=?]", "turma[numero_da_turma]" - - assert_select "input[name=?]", "turma[semestre]" - - assert_select "input[name=?]", "turma[horario]" - - assert_select "input[name=?]", "turma[disciplina_id]" - end - end -end diff --git a/spec/views/turmas/index.html.erb_spec.rb b/spec/views/turmas/index.html.erb_spec.rb deleted file mode 100644 index 6a08b99105..0000000000 --- a/spec/views/turmas/index.html.erb_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'rails_helper' - -RSpec.describe "turmas/index", type: :view do - before(:each) do - assign(:turmas, [ - Turma.create!( - numero_da_turma: "Numero Da Turma", - semestre: "Semestre", - horario: "Horario", - disciplina: nil - ), - Turma.create!( - numero_da_turma: "Numero Da Turma", - semestre: "Semestre", - horario: "Horario", - disciplina: nil - ) - ]) - end - - it "renders a list of turmas" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new("Numero Da Turma".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Semestre".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Horario".to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/turmas/new.html.erb_spec.rb b/spec/views/turmas/new.html.erb_spec.rb deleted file mode 100644 index ed22cbe1d3..0000000000 --- a/spec/views/turmas/new.html.erb_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -RSpec.describe "turmas/new", type: :view do - before(:each) do - assign(:turma, Turma.new( - numero_da_turma: "MyString", - semestre: "MyString", - horario: "MyString", - disciplina: nil - )) - end - - it "renders new turma form" do - render - - assert_select "form[action=?][method=?]", turmas_path, "post" do - - assert_select "input[name=?]", "turma[numero_da_turma]" - - assert_select "input[name=?]", "turma[semestre]" - - assert_select "input[name=?]", "turma[horario]" - - assert_select "input[name=?]", "turma[disciplina_id]" - end - end -end diff --git a/spec/views/turmas/show.html.erb_spec.rb b/spec/views/turmas/show.html.erb_spec.rb deleted file mode 100644 index 0f6e190b67..0000000000 --- a/spec/views/turmas/show.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe "turmas/show", type: :view do - before(:each) do - assign(:turma, Turma.create!( - numero_da_turma: "Numero Da Turma", - semestre: "Semestre", - horario: "Horario", - disciplina: nil - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/Numero Da Turma/) - expect(rendered).to match(/Semestre/) - expect(rendered).to match(/Horario/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/usuarios/edit.html.erb_spec.rb b/spec/views/usuarios/edit.html.erb_spec.rb deleted file mode 100644 index 03ac004182..0000000000 --- a/spec/views/usuarios/edit.html.erb_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'rails_helper' - -RSpec.describe "usuarios/edit", type: :view do - let(:usuario) { - Usuario.create!( - matricula: "MyString", - email: "MyString", - nome: "MyString", - formacao: "MyString", - type: "" - ) - } - - before(:each) do - assign(:usuario, usuario) - end - - it "renders the edit usuario form" do - render - - assert_select "form[action=?][method=?]", usuario_path(usuario), "post" do - - assert_select "input[name=?]", "usuario[matricula]" - - assert_select "input[name=?]", "usuario[email]" - - assert_select "input[name=?]", "usuario[nome]" - - assert_select "input[name=?]", "usuario[formacao]" - - assert_select "input[name=?]", "usuario[type]" - end - end -end diff --git a/spec/views/usuarios/index.html.erb_spec.rb b/spec/views/usuarios/index.html.erb_spec.rb deleted file mode 100644 index 8c9c12b987..0000000000 --- a/spec/views/usuarios/index.html.erb_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'rails_helper' - -RSpec.describe "usuarios/index", type: :view do - before(:each) do - assign(:usuarios, [ - Usuario.create!( - matricula: "Matricula", - email: "Email", - nome: "Nome", - formacao: "Formacao", - type: "Type" - ), - Usuario.create!( - matricula: "Matricula", - email: "Email", - nome: "Nome", - formacao: "Formacao", - type: "Type" - ) - ]) - end - - it "renders a list of usuarios" do - render - cell_selector = 'div>p' - assert_select cell_selector, text: Regexp.new("Matricula".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Email".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Nome".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Formacao".to_s), count: 2 - assert_select cell_selector, text: Regexp.new("Type".to_s), count: 2 - end -end diff --git a/spec/views/usuarios/new.html.erb_spec.rb b/spec/views/usuarios/new.html.erb_spec.rb deleted file mode 100644 index 0db91f114e..0000000000 --- a/spec/views/usuarios/new.html.erb_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rails_helper' - -RSpec.describe "usuarios/new", type: :view do - before(:each) do - assign(:usuario, Usuario.new( - matricula: "MyString", - email: "MyString", - nome: "MyString", - formacao: "MyString", - type: "" - )) - end - - it "renders new usuario form" do - render - - assert_select "form[action=?][method=?]", usuarios_path, "post" do - - assert_select "input[name=?]", "usuario[matricula]" - - assert_select "input[name=?]", "usuario[email]" - - assert_select "input[name=?]", "usuario[nome]" - - assert_select "input[name=?]", "usuario[formacao]" - - assert_select "input[name=?]", "usuario[type]" - end - end -end diff --git a/spec/views/usuarios/show.html.erb_spec.rb b/spec/views/usuarios/show.html.erb_spec.rb deleted file mode 100644 index 871de0d504..0000000000 --- a/spec/views/usuarios/show.html.erb_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'rails_helper' - -RSpec.describe "usuarios/show", type: :view do - before(:each) do - assign(:usuario, Usuario.create!( - matricula: "Matricula", - email: "Email", - nome: "Nome", - formacao: "Formacao", - type: "Type" - )) - end - - it "renders attributes in

" do - render - expect(rendered).to match(/Matricula/) - expect(rendered).to match(/Email/) - expect(rendered).to match(/Nome/) - expect(rendered).to match(/Formacao/) - expect(rendered).to match(/Type/) - end -end From 141573dad670ea1385d1689e7b2f6ceca3ab0f05 Mon Sep 17 00:00:00 2001 From: leitaonerd Date: Mon, 15 Jun 2026 16:00:05 -0300 Subject: [PATCH 31/55] test/formulario administrador --- features/criar_formulario_template.feature | 57 ++++++ .../criar_formulario_template_steps.rb | 163 ++++++++++++++++++ 2 files changed, 220 insertions(+) create mode 100644 features/criar_formulario_template.feature create mode 100644 features/step_definitions/criar_formulario_template_steps.rb diff --git a/features/criar_formulario_template.feature b/features/criar_formulario_template.feature new file mode 100644 index 0000000000..d420bdec7f --- /dev/null +++ b/features/criar_formulario_template.feature @@ -0,0 +1,57 @@ +# language: pt + +Funcionalidade: Criar formulário baseado em template + Como um administrador + Quero criar um formulário baseado em um template para as turmas que eu escolher + A fim de avaliar o desempenho das turmas no semestre atual + + Contexto: + Dado que eu estou logado como administrador + E que existe um template chamado "Avaliação Padrão" com as seguintes perguntas: + | Pergunta | Tipo | Opções | + | Como você avalia o professor? | Múltipla Escolha | Ótimo, Bom, Regular, Ruim | + | Qual seu nível de satisfação? | Escala | 1, 2, 3, 4, 5 | + | Deixe seu comentário | Texto | | + E que existem as seguintes turmas no semestre "2026.1": + | Código | Disciplina | Turma | + | TEC001 | Matemática | A | + | TEC002 | Português | B | + | TEC003 | História | A | + + Cenário: Criar formulário a partir de template para uma turma (Happy Path) + Quando eu acesso a página de criação de formulário a partir de template + E eu seleciono o template "Avaliação Padrão" + E eu seleciono as turmas "TEC001 - Matemática - A" + E eu clico em "Criar Formulário" + Então eu devo ver a mensagem "Formulário criado com sucesso" + E o formulário deve conter as perguntas do template "Avaliação Padrão" + E o formulário deve estar associado à turma "Matemática - A" + + Cenário: Criar formulário a partir de template para múltiplas turmas (Happy Path) + Quando eu acesso a página de criação de formulário a partir de template + E eu seleciono o template "Avaliação Padrão" + E eu seleciono as turmas "TEC001 - Matemática - A" e "TEC002 - Português - B" + E eu clico em "Criar Formulário" + Então eu devo ver a mensagem "Formulários criados com sucesso" + E deve existir um formulário para a turma "Matemática - A" + E deve existir um formulário para a turma "Português - B" + E cada formulário deve conter as perguntas do template "Avaliação Padrão" + + Cenário: Tentar criar formulário sem selecionar template (Sad Path) + Quando eu acesso a página de criação de formulário a partir de template + E eu não seleciono nenhum template + E eu seleciono as turmas "TEC001 - Matemática - A" + E eu clico em "Criar Formulário" + Então eu devo ver a mensagem "Selecione um template para criar o formulário" + + Cenário: Tentar criar formulário sem selecionar turmas (Sad Path) + Quando eu acesso a página de criação de formulário a partir de template + E eu seleciono o template "Avaliação Padrão" + E eu não seleciono nenhuma turma + E eu clico em "Criar Formulário" + Então eu devo ver a mensagem "Selecione pelo menos uma turma" + + Cenário: Visualizar lista de templates disponíveis antes de criar + Quando eu acesso a página de criação de formulário a partir de template + Então eu devo ver a lista de templates disponíveis + E eu devo ver a lista de turmas do semestre "2026.1" disponíveis \ No newline at end of file diff --git a/features/step_definitions/criar_formulario_template_steps.rb b/features/step_definitions/criar_formulario_template_steps.rb new file mode 100644 index 0000000000..1b83bc2923 --- /dev/null +++ b/features/step_definitions/criar_formulario_template_steps.rb @@ -0,0 +1,163 @@ +# frozen_string_literal: true + +# Step definitions for: Criar formulário baseado em template + +Dado('que eu estou logado como administrador') do + # TODO: Implementar autenticação como administrador + # administrador = Administrador.create!( + # nome: "Admin", + # email: "admin@ufpe.br", + # matricula: "admin123", + # departamento: Departamento.first + # ) + # administrador.enviar_email_definicao_senha! + # visit login_path + # fill_in 'login', with: administrador.email + # fill_in 'senha', with: 'senha_temporaria' + # click_button 'Entrar' +end + +Dado('que existe um template chamado {string} com as seguintes perguntas:') do |nome_template, table| + # table is a Cucumber::MultilineArgument::DataTable + # | Pergunta | Tipo | Opções | + # | Como você avalia o professor? | Múltipla Escolha | Ótimo, Bom, Regular, Ruim | + # | Qual seu nível de satisfação? | Escala | 1, 2, 3, 4, 5 | + # | Deixe seu comentário | Texto | | + # + # TODO: Implementar criação de template com elementos e campos + # @template = Template.create!(nome: nome_template) + # + # table.hashes.each do |row| + # elemento = @template.elementos.create!(enunciado: row['Pergunta'], ordem: @template.elementos.count + 1) + # + # case row['Tipo'] + # when 'Múltipla Escolha', 'Escala' + # row['Opções'].split(', ').each_with_index do |opcao, index| + # elemento.campos.create!(tipo_elemento: row['Tipo'], enunciado: opcao, ordem: index + 1) + # end + # when 'Texto' + # elemento.campos.create!(tipo_elemento: 'Texto', enunciado: '', ordem: 1) + # end + # end +end + +Dado('que existem as seguintes turmas no semestre {string}:') do |semestre, table| + # table is a Cucumber::MultilineArgument::DataTable + # | Código | Disciplina | Turma | + # | TEC001 | Matemática | A | + # | TEC002 | Português | B | + # | TEC003 | História | A | + # + # TODO: Implementar criação de turmas + # table.hashes.each do |row| + # departamento = Departamento.find_or_create_by!(nome: 'Departamento Padrão', codigo: 'DEP01') + # disciplina = Disciplina.find_or_create_by!( + # codigo: row['Código'], + # nome: row['Disciplina'], + # departamento: departamento + # ) + # Turma.find_or_create_by!( + # disciplina: disciplina, + # numero_da_turma: row['Turma'], + # semestre: semestre, + # horario: 'Seg 08:00-10:00' + # ) + # end + # @turmas_disponiveis = Turma.where(semestre: semestre) +end + +Quando('eu acesso a página de criação de formulário a partir de template') do + # TODO: Implementar rota para criação de formulário a partir de template + # visit new_formulario_from_template_path +end + +Quando('eu seleciono o template {string}') do |nome_template| + # TODO: Implementar seleção de template na interface + # select nome_template, from: 'template_id' +end + +Quando('eu não seleciono nenhum template') do + # TODO: Garantir que nenhum template está selecionado +end + +Quando('eu seleciono as turmas {string}') do |turmas_texto| + # TODO: Implementar seleção de turmas + # Exemplo de turmas_texto: "TEC001 - Matemática - A" + # turmas_texto.split(' e ').each do |turma_info| + # partes = turma_info.split(' - ') + # codigo = partes[0] + # nome_disciplina = partes[1] + # numero_turma = partes[2] + # + # disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # check "turma_ids_#{turma.id}" + # end +end + +Quando('eu não seleciono nenhuma turma') do + # TODO: Garantir que nenhuma turma está selecionada +end + +Quando('eu clico em {string}') do |nome_botao| + click_button nome_botao +end + +Então('eu devo ver a mensagem {string}') do |mensagem| + expect(page).to have_content(mensagem) +end + +Então('o formulário deve conter as perguntas do template {string}') do |nome_template| + # TODO: Verificar se o formulário foi criado com os elementos copiados do template + # template = Template.find_by!(nome: nome_template) + # formulario = Formulario.last + # expect(formulario.elemento_forms.count).to eq(template.elementos.count) + # formulario.elemento_forms.each_with_index do |ef, i| + # expect(ef.enunciado).to eq(template.elementos[i].enunciado) + # end +end + +Então('o formulário deve estar associado à turma {string}') do |nome_turma_info| + # TODO: Verificar associação com a turma correta + # partes = nome_turma_info.split(' - ') + # nome_disciplina = partes[0] + # numero_turma = partes[1] + # disciplina = Disciplina.find_by!(nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # expect(Formulario.last.turma).to eq(turma) +end + +Então('eu devo ver a mensagem {string}') do |mensagem| + expect(page).to have_content(mensagem) +end + +Então('deve existir um formulário para a turma {string}') do |nome_turma_info| + # TODO: Verificar existência do formulário para a turma + # partes = nome_turma_info.split(' - ') + # nome_disciplina = partes[0] + # numero_turma = partes[1] + # disciplina = Disciplina.find_by!(nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # expect(Formulario.exists?(turma: turma)).to be true +end + +Então('cada formulário deve conter as perguntas do template {string}') do |nome_template| + # template = Template.find_by!(nome: nome_template) + # Formulario.all.each do |formulario| + # expect(formulario.elemento_forms.count).to eq(template.elementos.count) + # end +end + +Então('eu devo ver a lista de templates disponíveis') do + # TODO: Verificar se os templates são exibidos + # Template.all.each do |template| + # expect(page).to have_content(template.nome) + # end +end + +Então('eu devo ver a lista de turmas do semestre {string} disponíveis') do |semestre| + # TODO: Verificar se as turmas do semestre são exibidas + # Turma.where(semestre: semestre).each do |turma| + # expect(page).to have_content(turma.disciplina.nome) + # end +end \ No newline at end of file From 401d1492442f24a6d6e3d680c6b5871a2141087c Mon Sep 17 00:00:00 2001 From: neatzzy Date: Mon, 15 Jun 2026 16:24:38 -0300 Subject: [PATCH 32/55] =?UTF-8?q?:recycle:=20refactor:=20fixes=20do=20lint?= =?UTF-8?q?=20e=20atualiza=C3=A7=C3=A3o=20das=20depend=C3=AAncias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 72 +++++++++---------- app/controllers/admin_controller.rb | 18 ++--- app/controllers/sessions_controller.rb | 1 - app/controllers/templates_controller.rb | 15 ++-- app/helpers/application_helper.rb | 2 +- app/models/administrador.rb | 4 +- app/models/campo.rb | 2 +- app/models/campo_form.rb | 2 +- app/models/curso.rb | 4 +- app/models/departamento.rb | 4 +- app/models/discente.rb | 4 +- app/models/disciplina.rb | 2 +- app/models/docente.rb | 2 +- app/models/elemento.rb | 2 +- app/models/elemento_form.rb | 2 +- app/models/formulario.rb | 2 +- app/models/resposta_elem.rb | 4 +- app/models/resposta_form.rb | 8 +-- app/models/template.rb | 13 ++-- app/models/turma.rb | 8 +-- app/models/usuario.rb | 2 +- config/routes.rb | 2 +- .../20260528002258_ajusta_nulos_para_sti.rb | 2 +- db/seeds.rb | 4 +- features/step_definitions/cadastro_steps.rb | 17 +++-- .../criar_formulario_template_steps.rb | 2 +- features/step_definitions/login_steps.rb | 2 +- .../responder_formulario_steps.rb | 2 +- features/step_definitions/senha_steps.rb | 6 +- features/step_definitions/template_steps.rb | 15 ++-- spec/models/administrador_spec.rb | 4 +- spec/models/template_spec.rb | 12 ++-- 32 files changed, 117 insertions(+), 124 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 12f9946b0b..7b3f9a603e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,9 +83,9 @@ GEM bcrypt_pbkdf (1.1.2) bigdecimal (4.1.2) bindex (0.8.1) - bootsnap (1.24.4) + bootsnap (1.24.6) msgpack (~> 1.2) - brakeman (8.0.4) + brakeman (8.0.5) racc builder (3.3.0) bundler-audit (0.9.3) @@ -120,7 +120,7 @@ GEM cucumber-gherkin (> 36, < 40) cucumber-messages (> 31, < 33) cucumber-tag-expressions (> 6, < 9) - cucumber-cucumber-expressions (19.0.0) + cucumber-cucumber-expressions (19.0.1) bigdecimal cucumber-gherkin (39.1.0) cucumber-messages (>= 31, < 33) @@ -137,7 +137,7 @@ GEM database_cleaner-active_record (2.2.2) activerecord (>= 5.a) database_cleaner-core (~> 2.0) - database_cleaner-core (2.0.1) + database_cleaner-core (2.1.0) date (3.5.1) debug (1.11.1) irb (~> 1.10) @@ -160,7 +160,7 @@ GEM ffi (1.17.4-x64-mingw-ucrt) ffi (1.17.4-x86_64-linux-gnu) ffi (1.17.4-x86_64-linux-musl) - fugit (1.12.1) + fugit (1.12.2) et-orbi (~> 1.4) raabro (~> 1.4) globalid (1.3.0) @@ -180,10 +180,10 @@ GEM prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - jbuilder (2.15.0) + jbuilder (2.15.1) actionview (>= 7.0.0) activesupport (>= 7.0.0) - json (2.19.5) + json (2.19.9) kamal (2.11.0) activesupport (>= 7.0) base64 (~> 0.2) @@ -216,11 +216,11 @@ GEM minitest (6.0.6) drb (~> 2.0) prism (~> 1.5) - msgpack (1.8.0) + msgpack (1.8.3) multi_test (1.1.0) mysql2 (0.5.7) bigdecimal - net-imap (0.6.4) + net-imap (0.6.4.1) date net-protocol net-pop (0.1.2) @@ -250,7 +250,7 @@ GEM nokogiri (1.19.3-x86_64-linux-musl) racc (~> 1.4) ostruct (0.6.3) - parallel (1.28.0) + parallel (2.1.0) parser (3.3.11.1) ast (~> 2.4.1) racc @@ -262,11 +262,11 @@ GEM actionpack (>= 7.0.0) activesupport (>= 7.0.0) rack - psych (5.3.1) + psych (5.4.0) date stringio public_suffix (7.0.5) - puma (8.0.1) + puma (8.0.2) nio4r (~> 2.0) raabro (1.4.0) racc (1.8.1) @@ -335,7 +335,7 @@ GEM rspec-mocks (>= 3.13.0, < 5.0.0) rspec-support (>= 3.13.0, < 5.0.0) rspec-support (3.13.7) - rubocop (1.86.2) + rubocop (1.87.0) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -353,7 +353,7 @@ GEM lint_roller (~> 1.1) rubocop (>= 1.75.0, < 2.0) rubocop-ast (>= 1.47.1, < 2.0) - rubocop-rails (2.35.2) + rubocop-rails (2.35.4) activesupport (>= 4.2.0) lint_roller (~> 1.1) rack (>= 1.1) @@ -367,7 +367,7 @@ GEM ruby-vips (2.3.0) ffi (~> 1.12) logger - rubyzip (3.3.0) + rubyzip (3.4.0) securerandom (0.4.1) selenium-webdriver (4.44.0) base64 (~> 0.2) @@ -375,7 +375,7 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 4.0) websocket (~> 1.0) - solid_cable (3.0.12) + solid_cable (4.0.0) actioncable (>= 7.2) activejob (>= 7.2) activerecord (>= 7.2) @@ -431,14 +431,14 @@ GEM bindex (>= 0.4.0) railties (>= 8.0.0) websocket (1.2.11) - websocket-driver (0.8.0) + websocket-driver (0.8.1) base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) win32ole (1.9.3) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.8.1) + zeitwerk (2.8.2) PLATFORMS aarch64-linux @@ -501,8 +501,8 @@ CHECKSUMS bcrypt_pbkdf (1.1.2) sha256=c2414c23ce66869b3eb9f643d6a3374d8322dfb5078125c82792304c10b94cf6 bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd bindex (0.8.1) sha256=7b1ecc9dc539ed8bccfc8cb4d2732046227b09d6f37582ff12e50a5047ceb17e - bootsnap (1.24.4) sha256=a4d939fc2cc5242a83d3a7cb4fb97743ac58475afe91e0600479a3df6f117541 - brakeman (8.0.4) sha256=7bf921fa9638544835df9aa7b3e720a9a72c0267f34f92135955edd80d4dcf6f + bootsnap (1.24.6) sha256=c60bab88c70332290f0a2636a288f675299eb4f804a02a3c085b42eca9da164a + brakeman (8.0.5) sha256=03735f9690d3fd4b32d66aacbf0a6d15a84266bdd06b32c05c8ecc8f6021d2be builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f bundler-audit (0.9.3) sha256=81c8766c71e47d0d28a0f98c7eed028539f21a6ea3cd8f685eb6f42333c9b4e9 capybara (3.40.0) sha256=42dba720578ea1ca65fd7a41d163dd368502c191804558f6e0f71b391054aeef @@ -512,7 +512,7 @@ CHECKSUMS cucumber (10.2.0) sha256=fdedbd31ecf40858b60f04853f2aa15c44f5c30bbac29c6a227fa1e7005a8158 cucumber-ci-environment (11.0.0) sha256=0df79a9e1d0b015b3d9def680f989200d96fef206f4d19ccf86a338c4f71d1e2 cucumber-core (16.2.0) sha256=592b58a95cf42feef8e5a349f68e363784ba3b6568ffbcf6776e38e136cf970b - cucumber-cucumber-expressions (19.0.0) sha256=33208ff204732ac9bed42b46993a0a243054f71ece08579d57e53df6a1c9d93a + cucumber-cucumber-expressions (19.0.1) sha256=648ec09045190d818fb797af46e1648148599fd67a086a34a7f0e647d9e36c8c cucumber-gherkin (39.1.0) sha256=aed12a0c955d8563d80a012633c1a72075525f4d64d4cc983001df2181b379ed cucumber-html-formatter (22.3.0) sha256=f9768ed05588dbd73a5f3824c2cc648bd86b00206e6972d743af8051281d0729 cucumber-messages (32.3.1) sha256=ddc88e4c1cf7afb96c06005b92a4a6f221a2fa435a8b4ca04677d215fd82771c @@ -520,7 +520,7 @@ CHECKSUMS cucumber-tag-expressions (8.1.0) sha256=9bd8c4b6654f8e5bf2a9c99329b6f32136a75e50cd39d4cfb3927d0fa9f52e21 database_cleaner (2.1.0) sha256=1dcba26e3b1576da692fc6bac10136a4744da5bcc293d248aae19640c65d89cd database_cleaner-active_record (2.2.2) sha256=88296b9f3088c31f7c0d4fcec10f68e4b71c96698043916de59b04debec10388 - database_cleaner-core (2.0.1) sha256=8646574c32162e59ed7b5258a97a208d3c44551b854e510994f24683865d846c + database_cleaner-core (2.1.0) sha256=b2875266d9b26b716e8b669c883e01c5250839f6f2ec56422b5e79aa97fb6927 date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0 debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6 diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962 @@ -538,15 +538,15 @@ CHECKSUMS ffi (1.17.4-x64-mingw-ucrt) sha256=f6ff9618cfccc494138bddade27aa06c74c6c7bc367a1ea1103d80c2fcb9ed35 ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e - fugit (1.12.1) sha256=5898f478ede9b415f0804e42b8f3fd53f814bd85eebffceebdbc34e1107aaf68 + fugit (1.12.2) sha256=643f2bf28db263bd400cbf8e0dd8b76b2c9b94bdb130e12d2394de04d9c20e5e globalid (1.3.0) sha256=05c639ad6eb4594522a0b07983022f04aa7254626ab69445a0e493aa3786ff11 i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5 image_processing (1.14.0) sha256=754cc169c9c262980889bec6bfd325ed1dafad34f85242b5a07b60af004742fb importmap-rails (2.2.3) sha256=7101be2a4dc97cf1558fb8f573a718404c5f6bcfe94f304bf1f39e444feeb16a io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3 - jbuilder (2.15.0) sha256=fe36cd45b47dd88cb2cbebc3adc4348f041825f580d503578594e8255817f889 - json (2.19.5) sha256=218a18553e4801d579ca7e0f5bc72bafd776d7397238a1fb4e74db5b0a812c59 + jbuilder (2.15.1) sha256=2430bec28fb0cebacb5875b1009cf9d8bc3c303ccb810c4c8b062a4b51457637 + json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a kamal (2.11.0) sha256=1408864425e0dec7e0a14d712a3b13f614e9f3a425b7661d3f9d287a51d7dd75 language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87 @@ -559,10 +559,10 @@ CHECKSUMS mini_magick (5.3.1) sha256=29395dfd76badcabb6403ee5aff6f681e867074f8f28ce08d78661e9e4a351c4 mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1 - msgpack (1.8.0) sha256=e64ce0212000d016809f5048b48eb3a65ffb169db22238fb4b72472fecb2d732 + msgpack (1.8.3) sha256=8bda4a6428d3244e50d6bd55854d354edbada88a4e1f4f5731a39a0f86bee6a1 multi_test (1.1.0) sha256=e9e550cdd863fb72becfe344aefdcd4cbd26ebf307847f4a6c039a4082324d10 mysql2 (0.5.7) sha256=ba09ede515a0ae8a7192040a1b778c0fb0f025fa5877e9be895cd325fa5e9d7b - net-imap (0.6.4) sha256=9a5598c67a3022c284d98430ef1d4948e7dbdb62596f61081ea8ca933270a02b + net-imap (0.6.4.1) sha256=29f0360d75a7efd3539f16ac1957dea5c0a51ddeceb348db4553c3120914ea0d net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3 net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8 net-scp (4.1.0) sha256=a99b0b92a1e5d360b0de4ffbf2dc0c91531502d3d4f56c28b0139a7c093d1a5d @@ -578,15 +578,15 @@ CHECKSUMS nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976 nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912 - parallel (1.28.0) sha256=33e6de1484baf2524792d178b0913fc8eb94c628d6cfe45599ad4458c638c970 + parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356 parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54 pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6 prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193 prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85 propshaft (1.3.2) sha256=1d56a3e56a92c21bfc29caf07406b5386b00d4c47ddf357cf989a5a234b1389e - psych (5.3.1) sha256=eb7a57cef10c9d70173ff74e739d843ac3b2c019a003de48447b2963d81b1974 + psych (5.4.0) sha256=14f72d69a611af663d7d70e4a7b67d9eb1f3ae9f8d916b478961d5a0075ba5b7 public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623 - puma (8.0.1) sha256=7b94e50c07655718c1fb8ae41a11fc06c7d61293208b3aa608ff71a46d3ad37c + puma (8.0.2) sha256=c8ed871dfbbe66448ea9ffd46692342d9804d4071522b52b5331b7b6e7b686fb raabro (1.4.0) sha256=d4fa9ff5172391edb92b242eed8be802d1934b1464061ae5e70d80962c5da882 racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2 @@ -608,17 +608,17 @@ CHECKSUMS rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47 rspec-rails (8.0.4) sha256=06235692fc0892683d3d34977e081db867434b3a24ae0dd0c6f3516bad4e22df rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c - rubocop (1.86.2) sha256=bb2e97f635eda42c448f2588f4a6ff78f221b8bdfdf65b1e9b07fbd57521b45d + rubocop (1.87.0) sha256=b9d9ddf55116a513f8ef2c7ae660662d8b49301f118d3f0df61865b33a5c188d rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035 rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834 - rubocop-rails (2.35.2) sha256=088865be9675922a5c8f13c00055a71ab768ea5eed211437cffd2a8b46b64ac2 + rubocop-rails (2.35.4) sha256=3aeaa325439c89950e8327565682ea794065d08e2ecbbfe95032bfa295a35df5 rubocop-rails-omakase (1.1.0) sha256=2af73ac8ee5852de2919abbd2618af9c15c19b512c4cfc1f9a5d3b6ef009109d ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33 ruby-vips (2.3.0) sha256=e685ec02c13969912debbd98019e50492e12989282da5f37d05f5471442f5374 - rubyzip (3.3.0) sha256=a372fc67892a4f8c0bc8ec906b720353d8e48807a64b2e63adf99b1e3583a034 + rubyzip (3.4.0) sha256=6de39bc9eba302b635a476d16c9e16b0872ad24517c2f98f2b3a7ea23caff57b securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1 selenium-webdriver (4.44.0) sha256=6f1df072529af369589c46f0e01132952aabb250cfd683c274d74dc1eb5d8477 - solid_cable (3.0.12) sha256=a168a54731a455d5627af48d8441ea3b554b8c1f6e6cd6074109de493e6b0460 + solid_cable (4.0.0) sha256=8379680ef6bf36e195eb876a6306ea290f87d5fa10bc4a757bc2a918f83229b5 solid_cache (1.0.10) sha256=bc05a2fb3ac78a6f43cbb5946679cf9db67dd30d22939ededc385cb93e120d41 solid_queue (1.4.0) sha256=e6a18d196f0b27cb6e3c77c5b31258b05fb634f8ed64fb1866ed164047216c2a sshkit (1.25.0) sha256=c8c6543cdb60f91f1d277306d585dd11b6a064cb44eab0972827e4311ff96744 @@ -641,11 +641,11 @@ CHECKSUMS useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844 web-console (4.3.0) sha256=e13b71301cdfc2093f155b5aa3a622db80b4672d1f2f713119cc7ec7ac6a6da4 websocket (1.2.11) sha256=b7e7a74e2410b5e85c25858b26b3322f29161e300935f70a0e0d3c35e0462737 - websocket-driver (0.8.0) sha256=ed0dba4b943c22f17f9a734817e808bc84cdce6a7e22045f5315aa57676d4962 + websocket-driver (0.8.1) sha256=5ab238238ce230e5d4b262d2be39624c867914eab99171dc4952b58b577c2d96 websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241 win32ole (1.9.3) sha256=01f43dc5dc13806e6e58204f538b4a28f3d85968ea89074abc9a3cd118e94d96 xpath (3.2.0) sha256=6dfda79d91bb3b949b947ecc5919f042ef2f399b904013eb3ef6d20dd3a4082e - zeitwerk (2.8.1) sha256=1c85e0f28954d68cd16e575da37f26846f609b68d80b5942ccfd31030c2449d5 + zeitwerk (2.8.2) sha256=7212a61311083c604184b1ea2574b9aa05cd14f855a0841c06985cabe9181d12 BUNDLED WITH 4.0.10 diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index b6146c5a11..3fb5c1270a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,5 +1,5 @@ class AdminController < ApplicationController - layout 'gerenciamento' + layout "gerenciamento" before_action :set_admin @@ -21,7 +21,7 @@ def sincronizar_sigaa def set_admin @admin = Administrador.find(params[:admin_id]) - + if @admin.id != session[:usuario_id] redirect_to inicio_path, alert: "Acesso negado! Você só pode acessar as suas próprias páginas." end @@ -38,13 +38,13 @@ def processar_sincronizacao temp_file = arquivo.path resultado = case acao - when 'importar' + when "importar" SigaaImporter.import_from_files(temp_file, temp_file) - when 'atualizar' + when "atualizar" SigaaImporter.update_from_files(temp_file, temp_file) - else + else "ação inválida" - end + end processar_resultado(resultado, acao) end @@ -52,13 +52,13 @@ def processar_sincronizacao def processar_resultado(resultado, acao) case resultado when /alguns dados/i - if acao == 'importar' + if acao == "importar" redirect_to admin_gerenciamento_path(@admin), notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" else redirect_to admin_gerenciamento_path(@admin), notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" end when /sucesso/i - if acao == 'importar' + if acao == "importar" redirect_to admin_gerenciamento_path(@admin), notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." else redirect_to admin_gerenciamento_path(@admin), notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." @@ -68,7 +68,7 @@ def processar_resultado(resultado, acao) when /já estão atualizados/i redirect_to admin_gerenciamento_path(@admin), alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" else - nome_acao = acao == 'importar' ? 'importação' : 'atualização' + nome_acao = acao == "importar" ? "importação" : "atualização" redirect_to admin_gerenciamento_path(@admin), alert: "erro informando que a #{nome_acao} falhou" end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index fc3cfffe07..f3972e0d95 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -39,7 +39,6 @@ def create else redirect_to inicio_path, notice: "Login realizado com sucesso." end - end def destroy diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index ee3f02c3b7..b22654be3b 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -1,7 +1,6 @@ class TemplatesController < ApplicationController + layout "gerenciamento" - layout 'gerenciamento' - before_action :set_admin before_action :set_template, only: %i[ show edit update destroy ] @@ -17,7 +16,7 @@ def show # GET /templates/new def new - @templates = @admin.templates + @templates = @admin.templates @template = @admin.templates.build elemento = @template.elementos.build elemento.campos.build @@ -41,7 +40,7 @@ def create format.html { redirect_to admin_templates_path(@admin), notice: "Template criado com sucesso!" } format.json { render :show, status: :created, location: @template } else - @templates = @admin.templates + @templates = @admin.templates format.html { render :new, status: :unprocessable_content } format.json { render json: @template.errors, status: :unprocessable_content } end @@ -55,7 +54,7 @@ def update format.html { redirect_to admin_templates_path(@admin), notice: "Template atualizado com sucesso!" } format.json { render :show, status: :ok, location: @template } else - @templates = @admin.templates + @templates = @admin.templates format.html { render :edit, status: :unprocessable_content } format.json { render json: @template.errors, status: :unprocessable_content } end @@ -88,10 +87,10 @@ def set_template # Only allow a list of trusted parameters through. def template_params params.require(:template).permit( - :nome, + :nome, elementos_attributes: [ - :id, :enunciado, :ordem, :_destroy, - campos_attributes: [:id, :tipo_elemento, :enunciado, :ordem, :_destroy] + :id, :enunciado, :ordem, :_destroy, + campos_attributes: [ :id, :tipo_elemento, :enunciado, :ordem, :_destroy ] ] ) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9667b0963d..93a8e98dc2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,6 @@ module ApplicationHelper def svg_icon(name, options = {}) - file_path = Rails.root.join('app', 'assets', 'images', 'icons', "#{name}.svg") + file_path = Rails.root.join("app", "assets", "images", "icons", "#{name}.svg") if File.exist?(file_path) svg = File.read(file_path).html_safe content_tag(:span, svg, options.merge(class: "icon-wrapper #{options[:class]}")) diff --git a/app/models/administrador.rb b/app/models/administrador.rb index bece08ee98..414f77fc5f 100644 --- a/app/models/administrador.rb +++ b/app/models/administrador.rb @@ -1,4 +1,4 @@ class Administrador < Usuario - has_many :templates, foreign_key: 'usuario_id', dependent: :destroy + has_many :templates, foreign_key: "usuario_id", dependent: :destroy validates :departamento_id, presence: true -end \ No newline at end of file +end diff --git a/app/models/campo.rb b/app/models/campo.rb index c57f3f257d..109cd4fc03 100644 --- a/app/models/campo.rb +++ b/app/models/campo.rb @@ -3,4 +3,4 @@ class Campo < ApplicationRecord validates :ordem, presence: true validates :ordem, uniqueness: { scope: :elemento_id } validates :tipo_elemento, presence: true -end \ No newline at end of file +end diff --git a/app/models/campo_form.rb b/app/models/campo_form.rb index fa1fbef3cf..f73b7e5efd 100644 --- a/app/models/campo_form.rb +++ b/app/models/campo_form.rb @@ -2,4 +2,4 @@ class CampoForm < ApplicationRecord belongs_to :elemento_form has_many :resposta_elems, dependent: :destroy validates :ordem, presence: true -end \ No newline at end of file +end diff --git a/app/models/curso.rb b/app/models/curso.rb index 181d343c9a..f854546b08 100644 --- a/app/models/curso.rb +++ b/app/models/curso.rb @@ -1,6 +1,6 @@ class Curso < ApplicationRecord belongs_to :departamento - has_many :discentes + has_many :discentes validates :codigo, presence: true, uniqueness: true validates :nome, presence: true -end \ No newline at end of file +end diff --git a/app/models/departamento.rb b/app/models/departamento.rb index 651ac1294d..1197a8801c 100644 --- a/app/models/departamento.rb +++ b/app/models/departamento.rb @@ -1,7 +1,7 @@ class Departamento < ApplicationRecord has_many :cursos, dependent: :restrict_with_error has_many :disciplinas, dependent: :restrict_with_error - has_many :administradores + has_many :administradores validates :codigo, presence: true, uniqueness: true validates :nome, presence: true -end \ No newline at end of file +end diff --git a/app/models/discente.rb b/app/models/discente.rb index d76084e48a..14fdfac827 100644 --- a/app/models/discente.rb +++ b/app/models/discente.rb @@ -1,4 +1,4 @@ class Discente < Usuario - validates :curso_id, presence: true + validates :curso_id, presence: true has_and_belongs_to_many :turmas, join_table: "discentes_turmas" -end \ No newline at end of file +end diff --git a/app/models/disciplina.rb b/app/models/disciplina.rb index f92d5a2f37..23741c99ea 100644 --- a/app/models/disciplina.rb +++ b/app/models/disciplina.rb @@ -3,4 +3,4 @@ class Disciplina < ApplicationRecord has_many :turmas, dependent: :destroy validates :codigo, presence: true, uniqueness: true validates :nome, presence: true -end \ No newline at end of file +end diff --git a/app/models/docente.rb b/app/models/docente.rb index 8c670c642b..cd38cd2af5 100644 --- a/app/models/docente.rb +++ b/app/models/docente.rb @@ -1,4 +1,4 @@ class Docente < Usuario validates :formacao, presence: true has_and_belongs_to_many :turmas, join_table: "docentes_turmas" -end \ No newline at end of file +end diff --git a/app/models/elemento.rb b/app/models/elemento.rb index e5cbad7bf3..135f84e8eb 100644 --- a/app/models/elemento.rb +++ b/app/models/elemento.rb @@ -2,4 +2,4 @@ class Elemento < ApplicationRecord belongs_to :template has_many :campos, dependent: :destroy accepts_nested_attributes_for :campos, allow_destroy: true -end \ No newline at end of file +end diff --git a/app/models/elemento_form.rb b/app/models/elemento_form.rb index 087bb0bdd0..7c232378d5 100644 --- a/app/models/elemento_form.rb +++ b/app/models/elemento_form.rb @@ -2,4 +2,4 @@ class ElementoForm < ApplicationRecord belongs_to :formulario has_many :campo_forms, dependent: :destroy validates :ordem, presence: true -end \ No newline at end of file +end diff --git a/app/models/formulario.rb b/app/models/formulario.rb index f1dc656bfc..87565cbd88 100644 --- a/app/models/formulario.rb +++ b/app/models/formulario.rb @@ -2,4 +2,4 @@ class Formulario < ApplicationRecord belongs_to :turma has_many :elemento_forms, dependent: :destroy has_many :resposta_forms, dependent: :destroy -end \ No newline at end of file +end diff --git a/app/models/resposta_elem.rb b/app/models/resposta_elem.rb index 5d17384907..569231b25d 100644 --- a/app/models/resposta_elem.rb +++ b/app/models/resposta_elem.rb @@ -1,6 +1,6 @@ class RespostaElem < ApplicationRecord belongs_to :resposta_form belongs_to :elemento_form - belongs_to :campo_form, optional: true + belongs_to :campo_form, optional: true validates :texto_resposta, presence: true -end \ No newline at end of file +end diff --git a/app/models/resposta_form.rb b/app/models/resposta_form.rb index d36024340b..d4679476d1 100644 --- a/app/models/resposta_form.rb +++ b/app/models/resposta_form.rb @@ -2,8 +2,8 @@ class RespostaForm < ApplicationRecord belongs_to :formulario belongs_to :usuario has_many :resposta_elems, dependent: :destroy - validates :data_submissao, presence: true - validates :usuario_id, uniqueness: { - scope: :formulario_id, + validates :data_submissao, presence: true + validates :usuario_id, uniqueness: { + scope: :formulario_id } -end \ No newline at end of file +end diff --git a/app/models/template.rb b/app/models/template.rb index a2dc12e3c5..5b57dd4bcf 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -1,6 +1,5 @@ class Template < ApplicationRecord - - belongs_to :administrador, foreign_key: 'usuario_id', class_name: 'Administrador' + belongs_to :administrador, foreign_key: "usuario_id", class_name: "Administrador" has_many :elementos, dependent: :destroy accepts_nested_attributes_for :elementos, allow_destroy: true @@ -25,19 +24,17 @@ def validar_elementos def validar_preenchimento return if errors.any? elementos.reject(&:marked_for_destruction?).each do |elemento| - if elemento.enunciado.blank? errors.add(:base, "O texto de todas as questões deve ser preenchido!") return # Para a execução aqui para não repetir a mensagem várias vezes end - - elemento.campos.reject(&:marked_for_destruction?).each do |campo| - if campo.tipo_elemento != 'Texto' && campo.enunciado.blank? + + elemento.campos.reject(&:marked_for_destruction?).each do |campo| + if campo.tipo_elemento != "Texto" && campo.enunciado.blank? errors.add(:base, "Todas as opções das questões devem ser preenchidas!") return end - end end end -end \ No newline at end of file +end diff --git a/app/models/turma.rb b/app/models/turma.rb index 6015166c43..09762e83c7 100644 --- a/app/models/turma.rb +++ b/app/models/turma.rb @@ -1,11 +1,11 @@ class Turma < ApplicationRecord belongs_to :disciplina - has_many :formularios, dependent: :destroy + has_many :formularios, dependent: :destroy has_and_belongs_to_many :discentes, join_table: "discentes_turmas" has_and_belongs_to_many :docentes, join_table: "docentes_turmas" - validates :numero_da_turma, presence: true, uniqueness: { - scope: [:semestre, :disciplina_id], + validates :numero_da_turma, presence: true, uniqueness: { + scope: [ :semestre, :disciplina_id ] } validates :semestre, presence: true -end \ No newline at end of file +end diff --git a/app/models/usuario.rb b/app/models/usuario.rb index 04f128aa0c..2e3acbb079 100644 --- a/app/models/usuario.rb +++ b/app/models/usuario.rb @@ -74,4 +74,4 @@ def validar_senha def atualizar_senha_hash self.senha_hash = BCrypt::Password.create(senha) end -end \ No newline at end of file +end diff --git a/config/routes.rb b/config/routes.rb index a5ca73a271..ac3cb86169 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,7 +32,7 @@ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. - scope '/admin/:admin_id', as: 'admin' do + scope "/admin/:admin_id", as: "admin" do get "avaliacoes", to: "admin#avaliacoes", as: :avaliacoes get "gerenciamento", to: "admin#gerenciamento", as: :gerenciamento resources :templates diff --git a/db/migrate/20260528002258_ajusta_nulos_para_sti.rb b/db/migrate/20260528002258_ajusta_nulos_para_sti.rb index dda7db719a..c6d3c678ec 100644 --- a/db/migrate/20260528002258_ajusta_nulos_para_sti.rb +++ b/db/migrate/20260528002258_ajusta_nulos_para_sti.rb @@ -4,4 +4,4 @@ def change change_column_null :usuarios, :departamento_id, true change_column_null :resposta_elems, :campo_form_id, true end -end \ No newline at end of file +end diff --git a/db/seeds.rb b/db/seeds.rb index df5a6b48db..32e4facab3 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -62,7 +62,7 @@ docente.matricula ||= "241000004" docente.senha = "teste123" docente.senha_confirmation = "teste123" -docente.departamento = dept_cic +docente.departamento = dept_cic docente.formacao = "doutorado" docente.save! @@ -103,4 +103,4 @@ re.campo_form = campo_form # campo_form_id pode ser nulo pela sua migration, mas passamos aqui end -puts "Seeds finalizados com sucesso" \ No newline at end of file +puts "Seeds finalizados com sucesso" diff --git a/features/step_definitions/cadastro_steps.rb b/features/step_definitions/cadastro_steps.rb index 05c69983e4..69416073bc 100644 --- a/features/step_definitions/cadastro_steps.rb +++ b/features/step_definitions/cadastro_steps.rb @@ -1,23 +1,22 @@ Dado('que estou na página de gerenciamento') do departamento = Departamento.first || Departamento.create!(nome: "Ciência da Computação", codigo: "CIC") @admin = Administrador.first || Administrador.create!( - nome: "Admin Teste", - matricula: "admin", - email: "admin@teste.com", - senha: "Senha123", + nome: "Admin Teste", + matricula: "admin", + email: "admin@teste.com", + senha: "Senha123", departamento: departamento ) allow_any_instance_of(AdminController).to receive(:set_admin) do |controller| controller.instance_variable_set(:@admin, Administrador.find(controller.params[:admin_id])) end - + allow_any_instance_of(TemplatesController).to receive(:set_admin) do |controller| controller.instance_variable_set(:@admin, Administrador.find(controller.params[:admin_id])) end - - visit admin_gerenciamento_path(@admin) + visit admin_gerenciamento_path(@admin) end Dado('que eu importei os dados do SIGAA com sucesso') do @@ -31,6 +30,6 @@ @email_destino = email - enviados = ActionMailer::Base.deliveries.select { |m| m.to == [email] } + enviados = ActionMailer::Base.deliveries.select { |m| m.to == [ email ] } expect(enviados).not_to be_empty -end \ No newline at end of file +end diff --git a/features/step_definitions/criar_formulario_template_steps.rb b/features/step_definitions/criar_formulario_template_steps.rb index 1b83bc2923..d6fadcdfae 100644 --- a/features/step_definitions/criar_formulario_template_steps.rb +++ b/features/step_definitions/criar_formulario_template_steps.rb @@ -160,4 +160,4 @@ # Turma.where(semestre: semestre).each do |turma| # expect(page).to have_content(turma.disciplina.nome) # end -end \ No newline at end of file +end diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index db564f532e..26a3a3bcf4 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -69,4 +69,4 @@ Então('sou direcionado para a página inicial') do # expect(page).to have_current_path(avaliacoes_path) # implementar quando o nome da rota for determinado -end \ No newline at end of file +end diff --git a/features/step_definitions/responder_formulario_steps.rb b/features/step_definitions/responder_formulario_steps.rb index d6186e19f1..eebcbd09dd 100644 --- a/features/step_definitions/responder_formulario_steps.rb +++ b/features/step_definitions/responder_formulario_steps.rb @@ -21,7 +21,7 @@ Então('eu devo visualizar os detalhes e perguntas pertinentes a ele') do # Assumindo que a classe .form-question existirá na view - expect(page).to have_selector('.form-question') + expect(page).to have_selector('.form-question') end Quando('eu respondo a pergunta {string} com a opção {string}') do |pergunta, opcao| diff --git a/features/step_definitions/senha_steps.rb b/features/step_definitions/senha_steps.rb index 51cd2b2ee7..e360e4907b 100644 --- a/features/step_definitions/senha_steps.rb +++ b/features/step_definitions/senha_steps.rb @@ -9,7 +9,7 @@ Quando('eu acesso o link de definição de senha recebido por e-mail') do email_destino = @email_destino || raise("Email de destino não definido nos steps") - mensagem = ActionMailer::Base.deliveries.reverse.find { |m| m.to == [email_destino] } + mensagem = ActionMailer::Base.deliveries.reverse.find { |m| m.to == [ email_destino ] } raise("Nenhum email enviado para #{email_destino}") if mensagem.nil? corpo = mensagem.text_part&.body&.decoded || mensagem.html_part&.body&.decoded || mensagem.body.decoded @@ -47,7 +47,7 @@ @email_destino = email - enviados = ActionMailer::Base.deliveries.select { |m| m.to == [email] } + enviados = ActionMailer::Base.deliveries.select { |m| m.to == [ email ] } expect(enviados).not_to be_empty end @@ -61,7 +61,7 @@ Quando('eu acesso o link de redefinição de senha recebido por e-mail') do email_destino = @email_destino || raise("Email de destino não definido nos steps") - mensagem = ActionMailer::Base.deliveries.reverse.find { |m| m.to == [email_destino] } + mensagem = ActionMailer::Base.deliveries.reverse.find { |m| m.to == [ email_destino ] } raise("Nenhum email enviado para #{email_destino}") if mensagem.nil? corpo = mensagem.text_part&.body&.decoded || mensagem.html_part&.body&.decoded || mensagem.body.decoded diff --git a/features/step_definitions/template_steps.rb b/features/step_definitions/template_steps.rb index 67ee81cc08..4a0a1928ae 100644 --- a/features/step_definitions/template_steps.rb +++ b/features/step_definitions/template_steps.rb @@ -1,15 +1,15 @@ Given(/^I [aA]m authenticated as an "([^"]*)"$/) do |role| depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') - + @admin = Administrador.find_or_create_by!(email: 'admin@unb.br') do |u| u.senha_hash = '123456' u.nome = 'Admin' u.matricula = '123456789' u.departamento = depto end - + allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) - + allow_any_instance_of(TemplatesController).to receive(:set_admin) do |controller| controller.instance_variable_set(:@admin, @admin) end @@ -54,8 +54,8 @@ end Given('I have added the template') do |table| - dados = table.rows_hash - valor = dados['titulo'].gsub(/^"|"$/, '') + dados = table.rows_hash + valor = dados['titulo'].gsub(/^"|"$/, '') fill_in "Nome do template:", with: valor end @@ -152,11 +152,11 @@ Given('the template {string} has the following elementos:') do |nome, table| template = Template.find_by(nome: nome) template.elementos.destroy_all # Limpa a fantasma - + table.hashes.each_with_index do |row, index| tipo = row['tipo_campo'] == 'multipla_escolha' ? 'Múltipla Escolha' : 'Texto' elemento = template.elementos.create!(enunciado: row['enunciado_elemento'], ordem: index + 1) - + if tipo == 'Múltipla Escolha' opcoes = row['enunciado_campo'].split(':').map(&:strip).reject(&:empty?) opcoes.each_with_index do |opcao, opt_idx| @@ -171,4 +171,3 @@ Given('I have no templates saved') do Template.destroy_all end - diff --git a/spec/models/administrador_spec.rb b/spec/models/administrador_spec.rb index 427ed503b0..7ae82480c1 100644 --- a/spec/models/administrador_spec.rb +++ b/spec/models/administrador_spec.rb @@ -9,7 +9,7 @@ nome: "Admin Teste", matricula: "admin123", email: "admin@unb.br", - senha: "Senha123", + senha: "Senha123", departamento: departamento ) expect(admin).to be_valid @@ -37,4 +37,4 @@ expect(admin).not_to be_valid end end -end \ No newline at end of file +end diff --git a/spec/models/template_spec.rb b/spec/models/template_spec.rb index 32eec5e955..13e107ef8c 100644 --- a/spec/models/template_spec.rb +++ b/spec/models/template_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Template, type: :model do let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } - let(:admin) do + let(:admin) do Administrador.find_or_create_by!(email: "admin_template@unb.br") do |u| u.nome = "Admin Template" u.matricula = "78910" @@ -15,28 +15,28 @@ it "é válido com nome, um administrador e pelo menos um elemento" do template = Template.new(nome: "Avaliação da Turma", administrador: admin) template.elementos.build(enunciado: "Questão 1", ordem: 1) - + expect(template).to be_valid end it "não é válido sem um nome (título)" do template = Template.new(nome: "", administrador: admin) template.elementos.build(enunciado: "Questão 1", ordem: 1) - + expect(template).not_to be_valid end it "não é válido sem um administrador associado" do template = Template.new(nome: "Formulário Fantasma", administrador: nil) template.elementos.build(enunciado: "Questão 1", ordem: 1) - + expect(template).not_to be_valid end it "não é válido se não possuir nenhum elemento (questão)" do template = Template.new(nome: "Formulário Vazio", administrador: admin) - + expect(template).not_to be_valid end end -end \ No newline at end of file +end From ae90f5c1dddbb6508736d0bf6e0249ccd0f192bd Mon Sep 17 00:00:00 2001 From: neatzzy Date: Mon, 15 Jun 2026 16:35:30 -0300 Subject: [PATCH 33/55] =?UTF-8?q?:recycle:=20refactor:=20redirect=20das=20?= =?UTF-8?q?rotas=20de=20usu=C3=A1rio=20+=20autentica=C3=A7=C3=A3o=20de=20l?= =?UTF-8?q?ogin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 2 ++ app/controllers/application_controller.rb | 18 ++++++++++++++++++ app/controllers/campo_forms_controller.rb | 1 + app/controllers/campos_controller.rb | 1 + app/controllers/cursos_controller.rb | 1 + app/controllers/departamentos_controller.rb | 1 + app/controllers/discentes_controller.rb | 1 + app/controllers/disciplinas_controller.rb | 1 + app/controllers/docentes_controller.rb | 1 + app/controllers/elemento_forms_controller.rb | 1 + app/controllers/elementos_controller.rb | 1 + app/controllers/formularios_controller.rb | 1 + app/controllers/home_controller.rb | 2 ++ app/controllers/resposta_elems_controller.rb | 1 + app/controllers/resposta_forms_controller.rb | 1 + app/controllers/sessions_controller.rb | 19 ++++++++++++++----- app/controllers/templates_controller.rb | 1 + app/controllers/turmas_controller.rb | 1 + app/controllers/usuarios_controller.rb | 2 ++ 19 files changed, 52 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3fb5c1270a..870f52ec1b 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -1,6 +1,8 @@ class AdminController < ApplicationController layout "gerenciamento" + before_action :require_login + before_action :require_admin before_action :set_admin def avaliacoes diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c3537563da..6e293ede18 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,4 +4,22 @@ class ApplicationController < ActionController::Base # Changes to the importmap will invalidate the etag for HTML responses stale_when_importmap_changes + + helper_method :current_user + + def current_user + @current_user ||= Usuario.find_by(id: session[:usuario_id]) + end + + def require_login + unless current_user + redirect_to root_path, alert: "Você precisa estar logado para acessar esta página." + end + end + + def require_admin + unless current_user.is_a?(Administrador) + redirect_to inicio_path, alert: "Acesso negado." + end + end end diff --git a/app/controllers/campo_forms_controller.rb b/app/controllers/campo_forms_controller.rb index de491c59e0..8dbd5a533c 100644 --- a/app/controllers/campo_forms_controller.rb +++ b/app/controllers/campo_forms_controller.rb @@ -1,4 +1,5 @@ class CampoFormsController < ApplicationController + before_action :require_login before_action :set_campo_form, only: %i[ show edit update destroy ] # GET /campo_forms or /campo_forms.json diff --git a/app/controllers/campos_controller.rb b/app/controllers/campos_controller.rb index cabefcb40d..b520443484 100644 --- a/app/controllers/campos_controller.rb +++ b/app/controllers/campos_controller.rb @@ -1,4 +1,5 @@ class CamposController < ApplicationController + before_action :require_login before_action :set_campo, only: %i[ show edit update destroy ] # GET /campos or /campos.json diff --git a/app/controllers/cursos_controller.rb b/app/controllers/cursos_controller.rb index afdf4d6e91..3d0d78d8e7 100644 --- a/app/controllers/cursos_controller.rb +++ b/app/controllers/cursos_controller.rb @@ -1,4 +1,5 @@ class CursosController < ApplicationController + before_action :require_login before_action :set_curso, only: %i[ show edit update destroy ] # GET /cursos or /cursos.json diff --git a/app/controllers/departamentos_controller.rb b/app/controllers/departamentos_controller.rb index 106c61bf2b..49fdfccfb6 100644 --- a/app/controllers/departamentos_controller.rb +++ b/app/controllers/departamentos_controller.rb @@ -1,4 +1,5 @@ class DepartamentosController < ApplicationController + before_action :require_login before_action :set_departamento, only: %i[ show edit update destroy ] # GET /departamentos or /departamentos.json diff --git a/app/controllers/discentes_controller.rb b/app/controllers/discentes_controller.rb index 08d886207d..2c7d21c0a5 100644 --- a/app/controllers/discentes_controller.rb +++ b/app/controllers/discentes_controller.rb @@ -1,4 +1,5 @@ class DiscentesController < ApplicationController + before_action :require_login before_action :set_discente, only: %i[ show edit update destroy ] # GET /discentes or /discentes.json diff --git a/app/controllers/disciplinas_controller.rb b/app/controllers/disciplinas_controller.rb index 5938a50d91..6ed261b5dd 100644 --- a/app/controllers/disciplinas_controller.rb +++ b/app/controllers/disciplinas_controller.rb @@ -1,4 +1,5 @@ class DisciplinasController < ApplicationController + before_action :require_login before_action :set_disciplina, only: %i[ show edit update destroy ] # GET /disciplinas or /disciplinas.json diff --git a/app/controllers/docentes_controller.rb b/app/controllers/docentes_controller.rb index 2fc30c57d8..4e29712586 100644 --- a/app/controllers/docentes_controller.rb +++ b/app/controllers/docentes_controller.rb @@ -1,4 +1,5 @@ class DocentesController < ApplicationController + before_action :require_login before_action :set_docente, only: %i[ show edit update destroy ] # GET /docentes or /docentes.json diff --git a/app/controllers/elemento_forms_controller.rb b/app/controllers/elemento_forms_controller.rb index 355d9573ff..1bf8b899e0 100644 --- a/app/controllers/elemento_forms_controller.rb +++ b/app/controllers/elemento_forms_controller.rb @@ -1,4 +1,5 @@ class ElementoFormsController < ApplicationController + before_action :require_login before_action :set_elemento_form, only: %i[ show edit update destroy ] # GET /elemento_forms or /elemento_forms.json diff --git a/app/controllers/elementos_controller.rb b/app/controllers/elementos_controller.rb index 4357f9c17a..1788ecfbeb 100644 --- a/app/controllers/elementos_controller.rb +++ b/app/controllers/elementos_controller.rb @@ -1,4 +1,5 @@ class ElementosController < ApplicationController + before_action :require_login before_action :set_elemento, only: %i[ show edit update destroy ] # GET /elementos or /elementos.json diff --git a/app/controllers/formularios_controller.rb b/app/controllers/formularios_controller.rb index d50b937cf0..07d51eadc3 100644 --- a/app/controllers/formularios_controller.rb +++ b/app/controllers/formularios_controller.rb @@ -1,4 +1,5 @@ class FormulariosController < ApplicationController + before_action :require_login before_action :set_formulario, only: %i[ show edit update destroy ] # GET /formularios or /formularios.json diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 95f29929ca..9b9ca87d45 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,4 +1,6 @@ class HomeController < ApplicationController + before_action :require_login + def index end end diff --git a/app/controllers/resposta_elems_controller.rb b/app/controllers/resposta_elems_controller.rb index ebb155db99..719623deb7 100644 --- a/app/controllers/resposta_elems_controller.rb +++ b/app/controllers/resposta_elems_controller.rb @@ -1,4 +1,5 @@ class RespostaElemsController < ApplicationController + before_action :require_login before_action :set_resposta_elem, only: %i[ show edit update destroy ] # GET /resposta_elems or /resposta_elems.json diff --git a/app/controllers/resposta_forms_controller.rb b/app/controllers/resposta_forms_controller.rb index 16b541a220..8403ecf8f9 100644 --- a/app/controllers/resposta_forms_controller.rb +++ b/app/controllers/resposta_forms_controller.rb @@ -1,4 +1,5 @@ class RespostaFormsController < ApplicationController + before_action :require_login before_action :set_resposta_form, only: %i[ show edit update destroy ] # GET /resposta_forms or /resposta_forms.json diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index f3972e0d95..b1bd44c6a9 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,5 +1,8 @@ class SessionsController < ApplicationController def new + if current_user + redirect_para_pagina_do_usuario(current_user) + end end def create @@ -34,15 +37,21 @@ def create end session[:usuario_id] = usuario.id - if usuario.is_a?(Administrador) - redirect_to admin_avaliacoes_path(usuario.id), notice: "Login realizado com sucesso." - else - redirect_to inicio_path, notice: "Login realizado com sucesso." - end + redirect_para_pagina_do_usuario(usuario) end def destroy reset_session redirect_to root_path end + + private + + def redirect_para_pagina_do_usuario(usuario) + if usuario.is_a?(Administrador) + redirect_to admin_avaliacoes_path(usuario.id) + else + redirect_to inicio_path + end + end end diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index b22654be3b..f2c9f06e87 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -1,5 +1,6 @@ class TemplatesController < ApplicationController layout "gerenciamento" + before_action :require_login before_action :set_admin before_action :set_template, only: %i[ show edit update destroy ] diff --git a/app/controllers/turmas_controller.rb b/app/controllers/turmas_controller.rb index 5ba8d974ef..78321a3d64 100644 --- a/app/controllers/turmas_controller.rb +++ b/app/controllers/turmas_controller.rb @@ -1,4 +1,5 @@ class TurmasController < ApplicationController + before_action :require_login before_action :set_turma, only: %i[ show edit update destroy ] # GET /turmas or /turmas.json diff --git a/app/controllers/usuarios_controller.rb b/app/controllers/usuarios_controller.rb index 997075c07a..04a2368590 100644 --- a/app/controllers/usuarios_controller.rb +++ b/app/controllers/usuarios_controller.rb @@ -1,4 +1,6 @@ class UsuariosController < ApplicationController + before_action :require_login + before_action :require_admin before_action :set_usuario, only: %i[ show edit update destroy ] # GET /usuarios or /usuarios.json From faac642663a808dc4f3431631e7adbcb65a16d9c Mon Sep 17 00:00:00 2001 From: neatzzy Date: Mon, 15 Jun 2026 16:47:54 -0300 Subject: [PATCH 34/55] =?UTF-8?q?:test=5Ftube:=20test:=20testes=20rspec=20?= =?UTF-8?q?para=20usu=C3=A1rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/usuarios/index.html.erb | 4 +- spec/models/usuario_spec.rb | 163 +++++++++++++++++++++++++++++- spec/requests/sessions_spec.rb | 125 +++++++++++++++++++++++ spec/requests/usuarios_spec.rb | 118 +++++++++++++++++++++ 4 files changed, 407 insertions(+), 3 deletions(-) create mode 100644 spec/requests/sessions_spec.rb create mode 100644 spec/requests/usuarios_spec.rb diff --git a/app/views/usuarios/index.html.erb b/app/views/usuarios/index.html.erb index 53b9428ddc..3715fefa03 100644 --- a/app/views/usuarios/index.html.erb +++ b/app/views/usuarios/index.html.erb @@ -6,9 +6,9 @@

<% @usuarios.each do |usuario| %> - <%= render usuario %> + <%= render partial: "usuario", object: usuario %>

- <%= link_to "Show this usuario", usuario %> + <%= link_to "Show this usuario", usuario_path(usuario) %>

<% end %>
diff --git a/spec/models/usuario_spec.rb b/spec/models/usuario_spec.rb index 12591f4841..8f1baa9b8b 100644 --- a/spec/models/usuario_spec.rb +++ b/spec/models/usuario_spec.rb @@ -1,5 +1,166 @@ require 'rails_helper' RSpec.describe Usuario, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + let(:curso) { Curso.find_or_create_by!(nome: "Engenharia de Software", codigo: "ESW", departamento: departamento) } + + let(:docente_valido) do + Docente.new( + nome: "Professor Teste", + matricula: "doc001", + email: "prof@unb.br", + formacao: "Doutorado", + senha: "Senha123", + senha_confirmation: "Senha123" + ) + end + + context "validações" do + it "é válido com todos os atributos obrigatórios" do + expect(docente_valido).to be_valid + end + + it "não é válido sem nome" do + docente_valido.nome = nil + expect(docente_valido).not_to be_valid + end + + it "não é válido sem matrícula" do + docente_valido.matricula = nil + expect(docente_valido).not_to be_valid + end + + it "não é válido sem email" do + docente_valido.email = nil + expect(docente_valido).not_to be_valid + end + + it "não é válido com matrícula duplicada" do + docente_valido.save! + outro = Docente.new( + nome: "Outro Prof", + matricula: "doc001", + email: "outro@unb.br", + formacao: "Mestrado", + senha: "Senha123", + senha_confirmation: "Senha123" + ) + expect(outro).not_to be_valid + end + + it "não é válido com email duplicado" do + docente_valido.save! + outro = Docente.new( + nome: "Outro Prof", + matricula: "doc002", + email: "prof@unb.br", + formacao: "Mestrado", + senha: "Senha123", + senha_confirmation: "Senha123" + ) + expect(outro).not_to be_valid + end + + it "não é válido com senha menor que 6 caracteres" do + docente_valido.senha = "abc" + docente_valido.senha_confirmation = "abc" + expect(docente_valido).not_to be_valid + end + + it "não é válido quando confirmação de senha não confere" do + docente_valido.senha_confirmation = "outra_senha" + expect(docente_valido).not_to be_valid + end + end + + context "#senha_definida?" do + it "retorna false quando senha_hash está em branco" do + usuario = Docente.new(nome: "X", matricula: "x1", email: "x@x.com", formacao: "Grad") + expect(usuario.senha_definida?).to be false + end + + it "retorna true após definir e salvar uma senha" do + docente_valido.save! + expect(docente_valido.senha_definida?).to be true + end + end + + context "#autenticar_senha" do + before { docente_valido.save! } + + it "retorna true com a senha correta" do + expect(docente_valido.autenticar_senha("Senha123")).to be true + end + + it "retorna false com a senha incorreta" do + expect(docente_valido.autenticar_senha("errada")).to be false + end + + it "retorna false quando senha_hash está em branco" do + usuario = Docente.new(nome: "Y", matricula: "y1", email: "y@y.com", formacao: "Grad") + expect(usuario.autenticar_senha("qualquer")).to be false + end + end + + context "#gerar_definicao_senha_token!" do + before { docente_valido.save! } + + it "preenche definicao_senha_token" do + docente_valido.gerar_definicao_senha_token! + expect(docente_valido.definicao_senha_token).to be_present + end + + it "preenche definicao_senha_sent_at" do + docente_valido.gerar_definicao_senha_token! + expect(docente_valido.definicao_senha_sent_at).to be_present + end + end + + context "#limpar_definicao_senha_token!" do + before do + docente_valido.save! + docente_valido.gerar_definicao_senha_token! + end + + it "apaga definicao_senha_token" do + docente_valido.limpar_definicao_senha_token! + expect(docente_valido.definicao_senha_token).to be_nil + end + + it "apaga definicao_senha_sent_at" do + docente_valido.limpar_definicao_senha_token! + expect(docente_valido.definicao_senha_sent_at).to be_nil + end + end + + context "#gerar_redefinicao_senha_token!" do + before { docente_valido.save! } + + it "preenche redefinicao_senha_token" do + docente_valido.gerar_redefinicao_senha_token! + expect(docente_valido.redefinicao_senha_token).to be_present + end + + it "preenche redefinicao_senha_sent_at" do + docente_valido.gerar_redefinicao_senha_token! + expect(docente_valido.redefinicao_senha_sent_at).to be_present + end + end + + context "#limpar_redefinicao_senha_token!" do + before do + docente_valido.save! + docente_valido.gerar_redefinicao_senha_token! + end + + it "apaga redefinicao_senha_token" do + docente_valido.limpar_redefinicao_senha_token! + expect(docente_valido.redefinicao_senha_token).to be_nil + end + + it "apaga redefinicao_senha_sent_at" do + docente_valido.limpar_redefinicao_senha_token! + expect(docente_valido.redefinicao_senha_sent_at).to be_nil + end + end end diff --git a/spec/requests/sessions_spec.rb b/spec/requests/sessions_spec.rb new file mode 100644 index 0000000000..feddd3dead --- /dev/null +++ b/spec/requests/sessions_spec.rb @@ -0,0 +1,125 @@ +require 'rails_helper' + +RSpec.describe "Sessions", type: :request do + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + + let!(:admin) do + Administrador.create!( + nome: "Admin Teste", + matricula: "adm001", + email: "admin@unb.br", + senha: "Senha123", + senha_confirmation: "Senha123", + departamento: departamento + ) + end + + let!(:docente) do + Docente.create!( + nome: "Prof Teste", + matricula: "doc001", + email: "prof@unb.br", + formacao: "Doutorado", + senha: "Senha123", + senha_confirmation: "Senha123" + ) + end + + describe "GET /" do + context "quando não está logado" do + it "exibe a tela de login" do + get root_path + expect(response).to have_http_status(:ok) + end + end + + context "quando já está logado como Administrador" do + before { post login_path, params: { login: admin.email, senha: "Senha123" } } + + it "redireciona para a página de avaliações do admin" do + get root_path + expect(response).to redirect_to(admin_avaliacoes_path(admin.id)) + end + end + + context "quando já está logado como usuário comum" do + before { post login_path, params: { login: docente.email, senha: "Senha123" } } + + it "redireciona para a página inicial" do + get root_path + expect(response).to redirect_to(inicio_path) + end + end + end + + describe "POST /login" do + context "com credenciais inválidas" do + it "redireciona para root com alerta quando login está em branco" do + post login_path, params: { login: "", senha: "Senha123" } + expect(response).to redirect_to(root_path) + follow_redirect! + expect(response.body).to include("informe seu email ou matrícula") + end + + it "redireciona para root com alerta quando senha está em branco" do + post login_path, params: { login: docente.email, senha: "" } + expect(response).to redirect_to(root_path) + follow_redirect! + expect(response.body).to include("informe a sua senha") + end + + it "redireciona para root com alerta quando usuário não existe" do + post login_path, params: { login: "naoexiste@unb.br", senha: "Senha123" } + expect(response).to redirect_to(root_path) + follow_redirect! + expect(response.body).to include("usuário não encontrado") + end + + it "redireciona para root com alerta quando senha está incorreta" do + post login_path, params: { login: docente.email, senha: "errada" } + expect(response).to redirect_to(root_path) + follow_redirect! + expect(response.body).to include("senha incorreta") + end + end + + context "com credenciais válidas de Administrador" do + it "redireciona para a página de avaliações do admin" do + post login_path, params: { login: admin.email, senha: "Senha123" } + expect(response).to redirect_to(admin_avaliacoes_path(admin.id)) + end + + it "aceita login pela matrícula" do + post login_path, params: { login: admin.matricula, senha: "Senha123" } + expect(response).to redirect_to(admin_avaliacoes_path(admin.id)) + end + end + + context "com credenciais válidas de usuário comum" do + it "redireciona para a página inicial" do + post login_path, params: { login: docente.email, senha: "Senha123" } + expect(response).to redirect_to(inicio_path) + end + + it "aceita login pela matrícula" do + post login_path, params: { login: docente.matricula, senha: "Senha123" } + expect(response).to redirect_to(inicio_path) + end + end + end + + describe "DELETE /logout" do + before { post login_path, params: { login: docente.email, senha: "Senha123" } } + + it "redireciona para a raiz" do + delete logout_path + expect(response).to redirect_to(root_path) + end + + it "encerra a sessão e exige novo login para rotas protegidas" do + delete logout_path + get inicio_path + expect(response).to redirect_to(root_path) + end + end +end diff --git a/spec/requests/usuarios_spec.rb b/spec/requests/usuarios_spec.rb new file mode 100644 index 0000000000..804d766ac8 --- /dev/null +++ b/spec/requests/usuarios_spec.rb @@ -0,0 +1,118 @@ +require 'rails_helper' + +RSpec.describe "Usuarios", type: :request do + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + + let!(:admin) do + Administrador.create!( + nome: "Admin Teste", + matricula: "adm001", + email: "admin@unb.br", + senha: "Senha123", + senha_confirmation: "Senha123", + departamento: departamento + ) + end + + let!(:docente) do + Docente.create!( + nome: "Prof Teste", + matricula: "doc001", + email: "prof@unb.br", + formacao: "Doutorado", + senha: "Senha123", + senha_confirmation: "Senha123" + ) + end + + def logar_como(usuario) + post login_path, params: { login: usuario.email, senha: "Senha123" } + end + + describe "GET /usuarios (require_login)" do + context "sem sessão ativa" do + it "redireciona para a tela de login com alerta" do + get usuarios_path + expect(response).to redirect_to(root_path) + follow_redirect! + expect(response.body).to include("precisa estar logado") + end + end + end + + describe "GET /usuarios (require_admin)" do + context "logado como usuário comum" do + before { logar_como(docente) } + + it "redireciona para a página inicial com alerta de acesso negado" do + get usuarios_path + expect(response).to redirect_to(inicio_path) + follow_redirect! + expect(response.body).to include("Acesso negado") + end + end + + context "logado como Administrador" do + before { logar_como(admin) } + + it "permite o acesso" do + get usuarios_path + expect(response).to have_http_status(:ok) + end + end + end + + describe "GET /usuarios/:id" do + context "sem sessão ativa" do + it "redireciona para a tela de login" do + get usuario_path(docente) + expect(response).to redirect_to(root_path) + end + end + + context "logado como usuário comum" do + before { logar_como(docente) } + + it "redireciona para a página inicial" do + get usuario_path(docente) + expect(response).to redirect_to(inicio_path) + end + end + + context "logado como Administrador" do + before { logar_como(admin) } + + it "permite o acesso" do + get usuario_path(docente) + expect(response).to have_http_status(:ok) + end + end + end + + describe "DELETE /usuarios/:id" do + context "sem sessão ativa" do + it "redireciona para a tela de login" do + delete usuario_path(docente) + expect(response).to redirect_to(root_path) + end + end + + context "logado como usuário comum" do + before { logar_como(docente) } + + it "redireciona para a página inicial" do + delete usuario_path(docente) + expect(response).to redirect_to(inicio_path) + end + end + + context "logado como Administrador" do + before { logar_como(admin) } + + it "remove o usuário e redireciona para a listagem" do + delete usuario_path(docente) + expect(response).to redirect_to(usuarios_path) + end + end + end +end From 1c2f653dca3abe49c49794251fe75fb19d4dafe9 Mon Sep 17 00:00:00 2001 From: neatzzy Date: Mon, 15 Jun 2026 17:03:11 -0300 Subject: [PATCH 35/55] acho q agora foi --- app/controllers/sessions_controller.rb | 2 +- spec/requests/sessions_spec.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b1bd44c6a9..b28853d734 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -51,7 +51,7 @@ def redirect_para_pagina_do_usuario(usuario) if usuario.is_a?(Administrador) redirect_to admin_avaliacoes_path(usuario.id) else - redirect_to inicio_path + redirect_to usuario_path(usuario.id) end end end diff --git a/spec/requests/sessions_spec.rb b/spec/requests/sessions_spec.rb index feddd3dead..8c1c98589e 100644 --- a/spec/requests/sessions_spec.rb +++ b/spec/requests/sessions_spec.rb @@ -45,9 +45,9 @@ context "quando já está logado como usuário comum" do before { post login_path, params: { login: docente.email, senha: "Senha123" } } - it "redireciona para a página inicial" do + it "redireciona para a página do usuário" do get root_path - expect(response).to redirect_to(inicio_path) + expect(response).to redirect_to(usuario_path(docente.id)) end end end @@ -96,14 +96,14 @@ end context "com credenciais válidas de usuário comum" do - it "redireciona para a página inicial" do + it "redireciona para a página do usuário" do post login_path, params: { login: docente.email, senha: "Senha123" } - expect(response).to redirect_to(inicio_path) + expect(response).to redirect_to(usuario_path(docente.id)) end it "aceita login pela matrícula" do post login_path, params: { login: docente.matricula, senha: "Senha123" } - expect(response).to redirect_to(inicio_path) + expect(response).to redirect_to(usuario_path(docente.id)) end end end From 4c31b58f98068b073420e1b885c471be65bdd208 Mon Sep 17 00:00:00 2001 From: Leo3107 Date: Mon, 15 Jun 2026 19:18:38 -0300 Subject: [PATCH 36/55] init-forms forms dev --- app/assets/stylesheets/application.css | 464 ++++++++++++++++++ app/controllers/admin/dashboard_controller.rb | 70 +++ app/controllers/admin/forms_controller.rb | 73 +++ app/controllers/admin/templates_controller.rb | 85 ++++ app/controllers/application_controller.rb | 33 +- app/controllers/dashboard_controller.rb | 6 + app/controllers/forms_controller.rb | 37 ++ app/controllers/home_controller.rb | 10 +- app/controllers/sessions_controller.rb | 9 +- app/models/camaar/workspace.rb | 218 ++++++++ app/models/workspace_state.rb | 5 + app/views/admin/avaliacoes.html.erb | 3 - app/views/admin/dashboard/avaliacoes.html.erb | 35 ++ .../admin/dashboard/gerenciamento.html.erb | 23 + app/views/admin/dashboard/index.html.erb | 34 ++ .../dashboard/sincronizar_sigaa.html.erb | 22 + app/views/admin/forms/index.html.erb | 34 ++ app/views/admin/forms/new.html.erb | 37 ++ app/views/admin/forms/results.html.erb | 50 ++ app/views/admin/gerenciamento.html.erb | 11 - app/views/admin/sincronizar_sigaa.html.erb | 22 - app/views/admin/templates/edit.html.erb | 41 ++ app/views/admin/templates/index.html.erb | 29 ++ app/views/admin/templates/new.html.erb | 41 ++ app/views/forms/index.html.erb | 34 ++ app/views/forms/show.html.erb | 48 ++ app/views/home/index.html.erb | 39 +- app/views/layouts/gerenciamento.html.erb | 56 +-- app/views/sessions/new.html.erb | 45 +- config/database.yml | 42 +- config/routes.rb | 41 +- .../20260615220605_create_workspace_states.rb | 8 + db/schema.rb | 8 +- db/seeds.rb | 99 ++-- 34 files changed, 1582 insertions(+), 230 deletions(-) create mode 100644 app/controllers/admin/dashboard_controller.rb create mode 100644 app/controllers/admin/forms_controller.rb create mode 100644 app/controllers/admin/templates_controller.rb create mode 100644 app/controllers/dashboard_controller.rb create mode 100644 app/controllers/forms_controller.rb create mode 100644 app/models/camaar/workspace.rb create mode 100644 app/models/workspace_state.rb delete mode 100644 app/views/admin/avaliacoes.html.erb create mode 100644 app/views/admin/dashboard/avaliacoes.html.erb create mode 100644 app/views/admin/dashboard/gerenciamento.html.erb create mode 100644 app/views/admin/dashboard/index.html.erb create mode 100644 app/views/admin/dashboard/sincronizar_sigaa.html.erb create mode 100644 app/views/admin/forms/index.html.erb create mode 100644 app/views/admin/forms/new.html.erb create mode 100644 app/views/admin/forms/results.html.erb delete mode 100644 app/views/admin/gerenciamento.html.erb delete mode 100644 app/views/admin/sincronizar_sigaa.html.erb create mode 100644 app/views/admin/templates/edit.html.erb create mode 100644 app/views/admin/templates/index.html.erb create mode 100644 app/views/admin/templates/new.html.erb create mode 100644 app/views/forms/index.html.erb create mode 100644 app/views/forms/show.html.erb create mode 100644 db/migrate/20260615220605_create_workspace_states.rb diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index fe93333c0f..fe24a847f3 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -8,3 +8,467 @@ * * Consider organizing styles into separate files for maintainability. */ + +:root { + --purple: #6d2d71; + --purple-dark: #542357; + --purple-soft: #efe2ef; + --green: #77d17b; + --green-dark: #61bf65; + --bg: #e4e4e4; + --panel: #ffffff; + --text: #1f1f1f; + --muted: #6f6f6f; + --border: #dadada; + --shadow: 0 20px 40px rgba(0, 0, 0, 0.12); +} + +* { + box-sizing: border-box; +} + +html, +body { + margin: 0; + min-height: 100%; + background: var(--bg); + color: var(--text); + font-family: Arial, Helvetica, sans-serif; +} + +a { + color: inherit; + text-decoration: none; +} + +button, +input, +select, +textarea { + font: inherit; +} + +.flash { + position: fixed; + top: 18px; + right: 18px; + z-index: 50; + max-width: 420px; +} + +.flash__item { + margin-bottom: 10px; + padding: 12px 16px; + border-radius: 12px; + background: var(--panel); + box-shadow: var(--shadow); + border-left: 4px solid var(--green-dark); +} + +.flash__item--alert { + border-left-color: #d75f5f; +} + +.login-container { + min-height: 100vh; + display: grid; + place-items: center; + padding: 40px 24px; +} + +.login-card, +.landing-card, +.admin-panel, +.user-panel, +.modal-card { + background: var(--panel); + border-radius: 4px; + box-shadow: var(--shadow); +} + +.login-card { + width: min(700px, 100%); + min-height: 380px; + display: grid; + grid-template-columns: 1.05fr 1fr; + overflow: hidden; + background: var(--panel); + border-radius: 4px; + box-shadow: var(--shadow); +} + +.login-form { + padding: 40px 32px; +} + +.login-form h1 { + margin: 0 0 18px; + font-size: 26px; + font-weight: 700; +} + +.login-banner { + background: var(--purple); + color: #fff; + display: grid; + place-items: center; + text-align: center; + padding: 40px; +} + +.login-banner h2 { + margin: 0; + font-size: 40px; + line-height: 1.05; +} + +.login-form h2, +.section-title { + margin: 0 0 18px; + font-size: 26px; + font-weight: 700; +} + +.field { + margin-bottom: 14px; +} + +.field label { + display: block; + font-size: 12px; + color: var(--muted); + margin-bottom: 6px; +} + +.field input, +.field select, +.field textarea { + width: 100%; + padding: 10px 12px; + border: 1px solid var(--border); + border-radius: 6px; + background: #fff; +} + +.field label { + display: block; + font-size: 12px; + color: var(--muted); + margin-bottom: 6px; +} + +.field input, +.field select, +.field textarea { + width: 100%; + padding: 10px 12px; + border: 1px solid var(--border); + border-radius: 6px; + background: #fff; +} + +.btn { + appearance: none; + border: 0; + border-radius: 4px; + padding: 10px 18px; + cursor: pointer; + font-weight: 700; + transition: + transform 120ms ease, + opacity 120ms ease; +} + +.btn:hover { + transform: translateY(-1px); +} + +.btn--primary { + background: var(--green); + color: #fff; +} + +.btn--secondary { + background: var(--purple); + color: #fff; +} + +.btn--ghost { + background: #f4f4f4; + color: var(--text); +} + +.btn--danger { + background: #dc6b6b; + color: #fff; +} + +.app-shell { + min-height: 100vh; + display: grid; + grid-template-columns: 220px 1fr; +} + +.sidebar { + background: var(--panel); + border-right: 1px solid var(--border); + padding-top: 8px; +} + +.sidebar__item { + display: block; + padding: 12px 16px; + text-align: center; + color: #444; +} + +.sidebar__item--active { + background: var(--purple); + color: #fff; +} + +.workspace { + min-width: 0; +} + +.topbar { + height: 60px; + padding: 0 18px; + background: #fff; + border-bottom: 1px solid var(--border); + display: flex; + align-items: center; + gap: 14px; +} + +.topbar__title { + font-size: 22px; + font-weight: 500; + margin-right: auto; +} + +.search-pill { + width: min(220px, 34vw); + height: 28px; + border: 1px solid #b8b8b8; + border-radius: 20px; + background: linear-gradient( + to right, + transparent 0%, + transparent 88%, + #efefef 88%, + #efefef 100% + ); +} + +.avatar { + width: 32px; + height: 32px; + border-radius: 50%; + background: var(--purple); + color: #fff; + display: grid; + place-items: center; + font-weight: 700; +} + +.workspace__body { + padding: 24px; +} + +.cards-grid, +.template-grid, +.form-grid, +.results-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); + gap: 16px; +} + +.card, +.template-card, +.form-card, +.result-card, +.action-card { + background: #fff; + border-radius: 4px; + padding: 12px 14px; + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); + min-height: 82px; +} + +.card__title, +.template-card__title, +.form-card__title, +.result-card__title { + font-size: 18px; + font-weight: 700; + line-height: 1.1; + margin-bottom: 2px; +} + +.card__meta, +.template-card__meta, +.form-card__meta, +.result-card__meta { + font-size: 12px; + color: var(--muted); +} + +.card__footer, +.template-card__footer, +.form-card__footer, +.result-card__footer { + margin-top: 10px; + display: flex; + gap: 8px; + align-items: center; + justify-content: space-between; +} + +.action-card { + display: grid; + place-items: center; + min-height: 96px; + color: var(--purple-dark); + font-size: 34px; + font-weight: 400; +} + +.dashboard-hero { + width: min(280px, 100%); + margin: 22px auto 0; + padding: 22px; + display: grid; + gap: 8px; +} + +.dashboard-actions { + display: grid; + gap: 8px; +} + +.dashboard-actions .btn { + width: 100%; +} + +.modal-page { + padding: 24px; + display: grid; + place-items: center; +} + +.modal-card { + width: min(730px, 100%); + padding: 20px 22px 18px; +} + +.modal-card--narrow { + width: min(420px, 100%); +} + +.question-block { + border-top: 1px solid var(--border); + padding-top: 18px; + margin-top: 18px; +} + +.question-block:first-of-type { + border-top: 0; + padding-top: 0; + margin-top: 0; +} + +.question-grid { + display: grid; + grid-template-columns: 1.3fr 1fr; + gap: 14px; +} + +.question-actions { + display: flex; + justify-content: center; + gap: 10px; + margin-top: 10px; +} + +.mini-actions { + display: flex; + gap: 8px; + justify-content: flex-end; +} + +.pill { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 5px 10px; + border-radius: 999px; + background: #f2f2f2; + font-size: 12px; +} + +.page-heading { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + margin-bottom: 18px; +} + +.page-heading h1 { + margin: 0; + font-size: 28px; +} + +.split-layout { + display: grid; + grid-template-columns: 280px 1fr; + gap: 20px; +} + +.summary-panel { + background: #fff; + padding: 20px; + border-radius: 4px; + box-shadow: var(--shadow); +} + +.form-question { + padding: 16px 0; + border-bottom: 1px solid #ececec; +} + +.form-question:last-child { + border-bottom: 0; +} + +.form-question__title { + margin: 0 0 10px; + font-size: 18px; + font-weight: 700; +} + +.radio-list { + display: grid; + gap: 8px; +} + +.radio-list label { + display: inline-flex; + align-items: center; + gap: 8px; +} + +.empty-state { + background: #fff; + border: 1px dashed #cfcfcf; + border-radius: 8px; + padding: 28px; + text-align: center; + color: var(--muted); +} + +.hidden { + display: none !important; +} diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb new file mode 100644 index 0000000000..bcbfea5851 --- /dev/null +++ b/app/controllers/admin/dashboard_controller.rb @@ -0,0 +1,70 @@ +module Admin + class DashboardController < ApplicationController + before_action :require_admin + layout 'gerenciamento' + + def index + @workspace = workspace + @forms = @workspace.forms + end + + def gerenciamento + end + + def sincronizar_sigaa + if request.get? + render :sincronizar_sigaa + elsif request.post? + processar_sincronizacao + end + end + + private + + def processar_sincronizacao + acao = params[:acao] + arquivo = params[:arquivo_sigaa] + + unless arquivo.present? + redirect_to admin_gerenciamento_path, alert: "Por favor, selecione um arquivo" + return + end + + temp_file = arquivo.path + resultado = case acao + when 'importar' + SigaaImporter.import_from_files(temp_file, temp_file) + when 'atualizar' + SigaaImporter.update_from_files(temp_file, temp_file) + else + "ação inválida" + end + + processar_resultado(resultado, acao) + end + + def processar_resultado(resultado, acao) + case resultado + when /alguns dados/i + if acao == 'importar' + redirect_to admin_gerenciamento_path, notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" + else + redirect_to admin_gerenciamento_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" + end + when /sucesso/i + if acao == 'importar' + redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." + else + redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." + end + when /já existem/i + redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" + when /já estão atualizados/i + redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" + else + nome_acao = acao == 'importar' ? 'importação' : 'atualização' + redirect_to admin_gerenciamento_path, alert: "erro informando que a #{nome_acao} falhou" + end + end + end +end \ No newline at end of file diff --git a/app/controllers/admin/forms_controller.rb b/app/controllers/admin/forms_controller.rb new file mode 100644 index 0000000000..ff705e3da3 --- /dev/null +++ b/app/controllers/admin/forms_controller.rb @@ -0,0 +1,73 @@ +require "securerandom" + +module Admin + class FormsController < ApplicationController + before_action :require_admin + layout 'gerenciamento' + + def index + @workspace = workspace + @forms = @workspace.forms + end + + def new + @workspace = workspace + @form = blank_form + @templates = @workspace.templates + end + + def create + @workspace = workspace + @templates = @workspace.templates + @form = form_payload + @workspace.create_form(@form) + flash[:notice] = "Formulário criado com sucesso" + redirect_to admin_forms_path + rescue ArgumentError => e + flash.now[:alert] = e.message + render :new, status: :unprocessable_entity + end + + def publish + form = workspace.find_form(params[:id]) + raise ActiveRecord::RecordNotFound, "Formulário não encontrado" unless form + + form["active"] = true + workspace.persist! + flash[:notice] = "Formulário enviado com sucesso" + redirect_to admin_forms_path + end + + def results + @workspace = workspace + @form = @workspace.find_form(params[:id]) + redirect_to admin_forms_path, alert: "Formulário não encontrado" unless @form + end + + private + + def blank_form + { + "title" => "", + "semester" => "2026.1", + "professor" => "Professor", + "template_id" => @workspace.templates.first&.dig("id"), + "audience" => "aluno", + "recipients" => [] + } + end + + def form_payload + payload = params.require(:form).permit(:title, :semester, :professor, :template_id, :audience, recipients: []) + + { + "title" => payload[:title].to_s.strip, + "semester" => payload[:semester].to_s.strip, + "professor" => payload[:professor].to_s.strip, + "template_id" => payload[:template_id].to_s, + "audience" => payload[:audience].to_s, + "recipients" => Array(payload[:recipients]).map(&:to_s) + } + end + end +end \ No newline at end of file diff --git a/app/controllers/admin/templates_controller.rb b/app/controllers/admin/templates_controller.rb new file mode 100644 index 0000000000..8153559011 --- /dev/null +++ b/app/controllers/admin/templates_controller.rb @@ -0,0 +1,85 @@ +require "securerandom" + +module Admin + class TemplatesController < ApplicationController + before_action :require_admin + layout 'gerenciamento' + + def index + @workspace = workspace + @templates = @workspace.templates + end + + def new + @workspace = workspace + @template = blank_template + end + + def create + @workspace = workspace + @template = template_payload + @template = @workspace.create_template(@template) + flash[:notice] = "Template criado com sucesso!" + redirect_to admin_templates_path + rescue ArgumentError => e + flash.now[:alert] = e.message + render :new, status: :unprocessable_entity + end + + def edit + @workspace = workspace + @template = @workspace.find_template(params[:id]) + redirect_to admin_templates_path, alert: "Template não encontrado" unless @template + end + + def update + @workspace = workspace + @template = @workspace.update_template(params[:id], template_payload) + flash[:notice] = "Template atualizado com sucesso!" + redirect_to admin_templates_path + rescue ArgumentError => e + flash.now[:alert] = e.message + @template = @workspace.find_template(params[:id]) || blank_template + render :edit, status: :unprocessable_entity + end + + def destroy + workspace.delete_template(params[:id]) + flash[:notice] = "Template deletado com sucesso!" + redirect_to admin_templates_path + end + + private + + def blank_template + { + "id" => nil, + "title" => "", + "semester" => "2026.1", + "questions" => [ + { "id" => SecureRandom.uuid, "title" => "Questão 1", "type" => "radio", "options" => ["Ótimo", "Bom", "Regular", "Ruim"] } + ] + } + end + + def template_payload + payload = params.require(:template).permit(:title, :semester, questions: {}) + questions = payload[:questions].to_h.values.map do |question| + options = question[:options].to_s.split(",").map(&:strip).reject(&:blank?) + + { + "id" => question[:id].presence || SecureRandom.uuid, + "title" => question[:title].to_s.strip, + "type" => question[:type].to_s, + "options" => options + } + end + + { + "title" => payload[:title].to_s.strip, + "semester" => payload[:semester].to_s.strip, + "questions" => questions + } + end + end +end \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c3537563da..6e562078bb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,32 @@ class ApplicationController < ActionController::Base - # Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. allow_browser versions: :modern - - # Changes to the importmap will invalidate the etag for HTML responses stale_when_importmap_changes -end + + helper_method :workspace, :current_user, :admin_signed_in? + + private + + def workspace + @workspace ||= Camaar::Workspace.new(session) + end + + def current_user + @current_user ||= Usuario.find_by(id: session[:usuario_id]) if session[:usuario_id] + end + + def admin_signed_in? + current_user&.is_a?(Administrador) + end + + def require_login + unless current_user + redirect_to root_path, alert: "Por favor, faça login primeiro" + end + end + + def require_admin + unless admin_signed_in? + redirect_to inicio_path, alert: "Acesso restrito a administradores" + end + end +end \ No newline at end of file diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb new file mode 100644 index 0000000000..b5c276a756 --- /dev/null +++ b/app/controllers/dashboard_controller.rb @@ -0,0 +1,6 @@ +class DashboardController < ApplicationController + def index + @workspace = workspace + @current_user = session[:current_user] + end +end diff --git a/app/controllers/forms_controller.rb b/app/controllers/forms_controller.rb new file mode 100644 index 0000000000..d431c9fce3 --- /dev/null +++ b/app/controllers/forms_controller.rb @@ -0,0 +1,37 @@ +require "securerandom" + +class FormsController < ApplicationController + def index + @workspace = workspace + @forms = @workspace.pending_forms + end + + def show + @workspace = workspace + @form = @workspace.find_form(params[:id]) + redirect_to forms_path, alert: "Formulário não encontrado" unless @form + end + + def create_response + @workspace = workspace + @form = @workspace.find_form(params[:id]) + raise ActiveRecord::RecordNotFound, "Formulário não encontrado" unless @form + + @workspace.record_response(@form["id"], response_payload) + flash[:notice] = "Avaliação enviada com sucesso" + redirect_to forms_path + rescue ArgumentError => e + flash.now[:alert] = e.message + render :show, status: :unprocessable_entity + end + + private + + def response_payload + payload = params.require(:response).permit(:comment, answers: {}) + { + "comment" => payload[:comment].to_s.strip, + "answers" => payload[:answers].to_h.transform_values { |value| value.to_s } + } + end +end \ No newline at end of file diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 95f29929ca..247d9e9aee 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,4 +1,12 @@ class HomeController < ApplicationController + before_action :require_login + def index + @workspace = workspace + if admin_signed_in? + redirect_to admin_avaliacoes_path + else + @forms = @workspace.forms.select { |f| f["active"] } + end end -end +end \ No newline at end of file diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index aafb6f4339..32378d9d5f 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -34,11 +34,16 @@ def create end session[:usuario_id] = usuario.id - redirect_to inicio_path, notice: "Login realizado com sucesso." + + if usuario.is_a?(Administrador) + redirect_to admin_avaliacoes_path, notice: "Login realizado com sucesso." + else + redirect_to inicio_path, notice: "Login realizado com sucesso." + end end def destroy reset_session redirect_to root_path end -end +end \ No newline at end of file diff --git a/app/models/camaar/workspace.rb b/app/models/camaar/workspace.rb new file mode 100644 index 0000000000..d05c3f74d7 --- /dev/null +++ b/app/models/camaar/workspace.rb @@ -0,0 +1,218 @@ +require "securerandom" + +module Camaar + class Workspace + DEFAULT_STATE = { + "templates" => [ + { + "id" => "template-1", + "title" => "Template 1", + "semester" => "semestre", + "questions" => [ + { + "id" => "template-1-q1", + "title" => "Questão 1", + "type" => "radio", + "options" => ["Ótimo", "Bom", "Regular", "Ruim"] + }, + { + "id" => "template-1-q2", + "title" => "Questão 2", + "type" => "text", + "options" => [] + } + ] + } + ], + "forms" => [ + { + "id" => "form-1", + "title" => "Avaliação de Turma 2026.1", + "semester" => "2026.1", + "professor" => "Professor", + "template_id" => "template-1", + "audience" => "aluno", + "active" => true, + "questions" => [ + { + "id" => "form-1-q1", + "title" => "Como você avalia o professor?", + "type" => "radio", + "options" => ["Ótimo", "Bom", "Regular", "Ruim"] + } + ], + "responses" => [] + }, + { + "id" => "form-2", + "title" => "Nome da matéria", + "semester" => "semestre", + "professor" => "Professor", + "template_id" => "template-1", + "audience" => "aluno", + "active" => true, + "questions" => [ + { + "id" => "form-2-q1", + "title" => "Como você avalia o ambiente da disciplina?", + "type" => "radio", + "options" => ["Ótimo", "Bom", "Regular", "Ruim"] + } + ], + "responses" => [] + } + ] + }.freeze + + def initialize(_session = nil) + @record = WorkspaceState.instance + @record.data ||= DEFAULT_STATE.deep_dup + @record.save! if @record.new_record? + end + + def state + @record.data + end + + def templates + state["templates"] + end + + def forms + state["forms"] + end + + def recipients + state["recipients"] + end + + def pending_forms + forms.select { |form| form["active"] && form["responses"].empty? } + end + + def find_template(id) + templates.find { |template| template["id"] == id.to_s } + end + + def find_form(id) + forms.find { |form| form["id"] == id.to_s } + end + + def create_template(payload) + title = payload["title"].to_s.strip + raise ArgumentError, "Título não pode ficar em branco!" if title.blank? + + questions = normalize_questions(payload["questions"]) + raise ArgumentError, "Template deve ter pelo menos um elemento!" if questions.empty? + + template = { + "id" => SecureRandom.uuid, + "title" => title, + "semester" => payload["semester"].presence || "semestre", + "questions" => questions + } + + templates.unshift(template) + persist! + template + end + + def update_template(id, payload) + template = find_template(id) + raise ArgumentError, "Template não encontrado" unless template + + title = payload["title"].to_s.strip + raise ArgumentError, "Título não pode ficar em branco!" if title.blank? + + questions = normalize_questions(payload["questions"]) + raise ArgumentError, "Template deve ter pelo menos um elemento!" if questions.empty? + + template["title"] = title + template["semester"] = payload["semester"].presence || template["semester"] + template["questions"] = questions + persist! + template + end + + def delete_template(id) + templates.reject! { |template| template["id"] == id.to_s } + persist! + end + + def create_form(payload) + title = payload["title"].to_s.strip + raise ArgumentError, "Título não pode ficar em branco!" if title.blank? + + template = find_template(payload["template_id"]) + raise ArgumentError, "Template não encontrado" unless template + + form = { + "id" => SecureRandom.uuid, + "title" => title, + "semester" => payload["semester"].presence || template["semester"], + "professor" => payload["professor"].presence || "Professor", + "template_id" => template["id"], + "audience" => payload["audience"].presence || "aluno", + "active" => true, + "questions" => template["questions"].map(&:deep_dup), + "recipients" => Array(payload["recipients"]).map(&:to_s).reject(&:blank?), + "responses" => [] + } + + forms.unshift(form) + persist! + form + end + + def record_response(form_id, payload) + form = find_form(form_id) + raise ArgumentError, "Formulário não encontrado" unless form + + answers = payload["answers"] || {} + missing_questions = form["questions"].select do |question| + answer = answers[question["id"]] + question["type"] == "text" ? answer.to_s.strip.blank? : answer.to_s.strip.blank? + end + + if missing_questions.any? + raise ArgumentError, "Por favor, responda todas as perguntas obrigatórias" + end + + form["responses"] << { + "id" => SecureRandom.uuid, + "comment" => payload["comment"].to_s.strip, + "answers" => answers, + "created_at" => Time.current.iso8601 + } + persist! + form + end + + def persist! + @record.update!(data: state) + end + + private + + def normalize_questions(raw_questions) + Array(raw_questions).filter_map do |question| + next if question.nil? + + title = question["title"].to_s.strip + type = question["type"].to_s + options = Array(question["options"]).flat_map { |option| option.to_s.split(",") }.map(&:strip).reject(&:blank?) + + next if title.blank? + next if type == "radio" && options.size < 2 + + { + "id" => question["id"].presence || SecureRandom.uuid, + "title" => title, + "type" => type.presence || "radio", + "options" => options, + "required" => true + } + end + end + end +end \ No newline at end of file diff --git a/app/models/workspace_state.rb b/app/models/workspace_state.rb new file mode 100644 index 0000000000..50566fd85c --- /dev/null +++ b/app/models/workspace_state.rb @@ -0,0 +1,5 @@ +class WorkspaceState < ApplicationRecord + def self.instance + first_or_create!(data: Camaar::Workspace::DEFAULT_STATE.deep_dup) + end +end \ No newline at end of file diff --git a/app/views/admin/avaliacoes.html.erb b/app/views/admin/avaliacoes.html.erb deleted file mode 100644 index fd3f3db2ab..0000000000 --- a/app/views/admin/avaliacoes.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
-

Teste

-
\ No newline at end of file diff --git a/app/views/admin/dashboard/avaliacoes.html.erb b/app/views/admin/dashboard/avaliacoes.html.erb new file mode 100644 index 0000000000..6d8619ebde --- /dev/null +++ b/app/views/admin/dashboard/avaliacoes.html.erb @@ -0,0 +1,35 @@ +
+

Avaliações do Sistema

+ <%= link_to "Criar Avaliação", new_admin_form_path, class: "btn btn--primary" %> +
+ +
+ <% @forms.each do |form| %> +
+
<%= form["title"] %>
+
+ <%= form["semester"] %> · + <%= form["professor"] %> +
+
<%= form["responses"].size %> respostas
+ +
+ <% end %> + + <% if @forms.empty? %> +
+

Nenhuma avaliação criada.

+ <%= link_to "Criar primeira avaliação", new_admin_form_path, class: "btn btn--primary" %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admin/dashboard/gerenciamento.html.erb b/app/views/admin/dashboard/gerenciamento.html.erb new file mode 100644 index 0000000000..6bb49a55d2 --- /dev/null +++ b/app/views/admin/dashboard/gerenciamento.html.erb @@ -0,0 +1,23 @@ +
+

Ações de Gerenciamento

+
+ +
+
+ <%= link_to admin_sincronizar_sigaa_path, style: "text-decoration: none; color: inherit; width: 100%; height: 100%; display: grid; place-items: center;" do %> +
+
Importar / Atualizar
+
Dados do SIGAA
+
+ <% end %> +
+ +
+ <%= link_to admin_templates_path, style: "text-decoration: none; color: inherit; width: 100%; height: 100%; display: grid; place-items: center;" do %> +
+
Editar Templates
+
Gerenciar templates
+
+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/admin/dashboard/index.html.erb b/app/views/admin/dashboard/index.html.erb new file mode 100644 index 0000000000..3c1f82989a --- /dev/null +++ b/app/views/admin/dashboard/index.html.erb @@ -0,0 +1,34 @@ +
+

Avaliações Criadas

+ <%= link_to "Criar Avaliação", new_admin_form_path, class: "btn btn--primary" %> +
+ +
+ <% @forms.each do |form| %> +
+
<%= form["title"] %>
+
+ <%= form["semester"] %> · + <%= form["professor"] %> +
+ +
+ <% end %> + + <% if @forms.empty? %> +
+

Nenhuma avaliação criada ainda.

+ <%= link_to "Criar primeira avaliação", new_admin_form_path, class: "btn btn--primary" %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admin/dashboard/sincronizar_sigaa.html.erb b/app/views/admin/dashboard/sincronizar_sigaa.html.erb new file mode 100644 index 0000000000..f63d00e135 --- /dev/null +++ b/app/views/admin/dashboard/sincronizar_sigaa.html.erb @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/app/views/admin/forms/index.html.erb b/app/views/admin/forms/index.html.erb new file mode 100644 index 0000000000..9b11c62d3b --- /dev/null +++ b/app/views/admin/forms/index.html.erb @@ -0,0 +1,34 @@ +
+

Formulários de Avaliação

+ <%= link_to "Criar Formulário", new_admin_form_path, class: "btn btn--primary" %> +
+ +
+ <% @forms.each do |form| %> +
+
<%= form["title"] %>
+
+ <%= form["semester"] %> · + <%= form["professor"] %> +
+ +
+ <% end %> + + <% if @forms.empty? %> +
+

Nenhum formulário de avaliação criado.

+ <%= link_to "Criar primeiro formulário", new_admin_form_path, class: "btn btn--primary" %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admin/forms/new.html.erb b/app/views/admin/forms/new.html.erb new file mode 100644 index 0000000000..f544272fa4 --- /dev/null +++ b/app/views/admin/forms/new.html.erb @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/app/views/admin/forms/results.html.erb b/app/views/admin/forms/results.html.erb new file mode 100644 index 0000000000..9bde39eedc --- /dev/null +++ b/app/views/admin/forms/results.html.erb @@ -0,0 +1,50 @@ +
+

Resultados - <%= @form["title"] %>

+ <%= link_to "Voltar", admin_forms_path, class: "btn btn--ghost" %> +
+ +
+
+

Resumo

+

Total de respostas: <%= @form["responses"].size %>

+

Semestre: <%= @form["semester"] %>

+

Professor: <%= @form["professor"] %>

+
+ +
+ <% @form["questions"].each do |question| %> +
+

<%= question["title"] %>

+ <% if question["type"] == "radio" %> +
+ <% counts = Hash.new(0) %> + <% @form["responses"].each do |response| %> + <% counts[response["answers"][question["id"]]] += 1 %> + <% end %> + <% question["options"].each do |option| %> +
+ <%= option %>: <%= counts[option] %> votos +
+ <% end %> +
+ <% elsif question["type"] == "text" %> +
+ <% @form["responses"].each do |response| %> + <% if response["answers"][question["id"]].present? %> +
+
<%= response["answers"][question["id"]] %>
+
+ <% end %> + <% end %> +
+ <% end %> +
+ <% end %> + + <% if @form["responses"].empty? %> +
+

Nenhuma resposta recebida ainda.

+
+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/admin/gerenciamento.html.erb b/app/views/admin/gerenciamento.html.erb deleted file mode 100644 index f277202f0e..0000000000 --- a/app/views/admin/gerenciamento.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -
- -

- Ações de Gerenciamento -

- - <%= link_to "Importar / Atualizar dados do SIGAA", admin_sincronizar_sigaa_path, class: "btn-figma" %> - - <%= link_to "Editar Template", admin_templates_path, class: "btn-figma" %> - -
diff --git a/app/views/admin/sincronizar_sigaa.html.erb b/app/views/admin/sincronizar_sigaa.html.erb deleted file mode 100644 index 2b092b27da..0000000000 --- a/app/views/admin/sincronizar_sigaa.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -
-

- Sincronizar dados do SIGAA -

- - <%= form_with local: true, url: admin_sincronizar_sigaa_path, method: :post, multipart: true do |f| %> -
- <%= f.label :acao, "Tipo de sincronização:", style: "display: block; margin-bottom: 10px;" %> - <%= f.select :acao, [["Importar dados", "importar"], ["Atualizar dados", "atualizar"]], {}, class: "form-control" %> -
- -
- <%= f.label :arquivo_sigaa, "Selecione o arquivo JSON:", style: "display: block; margin-bottom: 10px;" %> - <%= f.file_field :arquivo_sigaa, accept: "application/json", required: true %> -
- -
- <%= f.submit "Sincronizar", class: "btn-figma" %> - <%= link_to "Cancelar", admin_gerenciamento_path, class: "btn-figma" %> -
- <% end %> -
diff --git a/app/views/admin/templates/edit.html.erb b/app/views/admin/templates/edit.html.erb new file mode 100644 index 0000000000..2f86e4702b --- /dev/null +++ b/app/views/admin/templates/edit.html.erb @@ -0,0 +1,41 @@ + \ No newline at end of file diff --git a/app/views/admin/templates/index.html.erb b/app/views/admin/templates/index.html.erb new file mode 100644 index 0000000000..bc985b17b2 --- /dev/null +++ b/app/views/admin/templates/index.html.erb @@ -0,0 +1,29 @@ +
+

Templates de Avaliação

+ <%= link_to "Criar Template", new_admin_template_path, class: "btn btn--primary" %> +
+ +
+ <% @templates.each do |template| %> +
+
<%= template["title"] %>
+
<%= template["semester"] %>
+
<%= template["questions"].size %> perguntas
+ +
+ <% end %> + + <% if @templates.empty? %> +
+

Nenhum template criado ainda.

+ <%= link_to "Criar primeiro template", new_admin_template_path, class: "btn btn--primary" %> +
+ <% end %> + + <%= link_to new_admin_template_path, class: "action-card" do %> + + + <% end %> +
\ No newline at end of file diff --git a/app/views/admin/templates/new.html.erb b/app/views/admin/templates/new.html.erb new file mode 100644 index 0000000000..fff854c4ef --- /dev/null +++ b/app/views/admin/templates/new.html.erb @@ -0,0 +1,41 @@ + \ No newline at end of file diff --git a/app/views/forms/index.html.erb b/app/views/forms/index.html.erb new file mode 100644 index 0000000000..2c87305c82 --- /dev/null +++ b/app/views/forms/index.html.erb @@ -0,0 +1,34 @@ +
+ + +
+
+

Avaliações Pendentes

+
U
+ <%= button_to "Sair", logout_path, method: :delete, class: "btn btn--ghost" %> +
+ +
+ <% if @forms.empty? %> +
+

Nenhuma avaliação pendente no momento.

+
+ <% else %> +
+ <% @forms.each do |form| %> + <%= link_to form_path(form["id"]), class: "card" do %> +
<%= form["title"] %>
+
<%= form["semester"] %>
+
<%= form["professor"] %>
+ + <% end %> + <% end %> +
+ <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/forms/show.html.erb b/app/views/forms/show.html.erb new file mode 100644 index 0000000000..48f130d636 --- /dev/null +++ b/app/views/forms/show.html.erb @@ -0,0 +1,48 @@ +
+ + +
+
+ +

Avaliação - <%= @form["title"] %> - <%= @form["semester"] %>

+
+
U
+ <%= button_to "Logout", logout_path, method: :delete, class: "btn btn--ghost" %> +
+ +
+ +
+
+
\ No newline at end of file diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 605d440da6..51af7b55ad 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1 +1,38 @@ -

Página inicial

+
+ + +
+
+

Avaliações

+
+
U
+ <%= button_to "Logout", logout_path, method: :delete, class: "btn btn--ghost" %> +
+ +
+ <% if @forms.present? %> +
+ <% @forms.each do |form| %> + <%= link_to form_path(form["id"]), class: "card" do %> +
<%= form["title"] %>
+
<%= form["semester"] %>
+
<%= form["professor"] %>
+ + <% end %> + <% end %> +
+ <% else %> +
+

Nenhuma avaliação disponível no momento.

+
+ <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/layouts/gerenciamento.html.erb b/app/views/layouts/gerenciamento.html.erb index e9c6234870..9b02dbd0b5 100644 --- a/app/views/layouts/gerenciamento.html.erb +++ b/app/views/layouts/gerenciamento.html.erb @@ -7,49 +7,35 @@ <%= csp_meta_tag %> <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> - <%= stylesheet_link_tag "gerenciamento", "data-turbo-track": "reload" %> -
- -
-
-

Visão Geral

-
-
- -
- -
+
+ -
U
+
+
+

Admin CAMAAR

+
+
A
+ <%= link_to "Voltar ao Início", inicio_path, class: "btn btn--ghost" %> + <%= button_to "Logout", logout_path, method: :delete, class: "btn btn--danger" %>
-
-
- - - -
- <% flash.each do |type, message| %> -
- <%= message %> +
+ <% flash.each do |type, message| %> +
+
+ <%= message %> +
- <% end %> + <% end %> <%= yield %> -
- +
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 8f93b2236a..d967f02b26 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,30 +1,31 @@ -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/app/views/admin/templates/new.html.erb b/app/views/admin/templates/new.html.erb index fff854c4ef..2a033281a4 100644 --- a/app/views/admin/templates/new.html.erb +++ b/app/views/admin/templates/new.html.erb @@ -18,24 +18,67 @@ <% @template["questions"].each_with_index do |question, index| %>
- <%= label_tag "template[questions][#{index}][title]", "Pergunta #{index + 1}" %> - <%= text_field_tag "template[questions][#{index}][title]", question["title"], placeholder: "Digite a pergunta" %> + <%= label_tag "template_questions_#{index}_title", "Pergunta #{index + 1}" %> + <%= text_field_tag "template[questions][#{index}][title]", question["title"], placeholder: "Digite a pergunta", id: "template_questions_#{index}_title" %>
- <%= label_tag "template[questions][#{index}][type]", "Tipo" %> - <%= select_tag "template[questions][#{index}][type]", options_for_select([["Múltipla escolha", "radio"], ["Texto", "text"]], question["type"]) %> + <%= label_tag "template_questions_#{index}_type", "Tipo" %> + <%= select_tag "template[questions][#{index}][type]", options_for_select([["Múltipla escolha", "radio"], ["Texto", "text"]], question["type"]), id: "template_questions_#{index}_type", class: "question-type-select" %>
-
- <%= label_tag "template[questions][#{index}][options]", "Opções (separadas por vírgula)" %> - <%= text_field_tag "template[questions][#{index}][options]", question["options"].join(", "), placeholder: "Ótimo, Bom, Regular, Ruim" %> +
+ <%= label_tag "template_questions_#{index}_options", "Opções (separadas por vírgula)" %> + <%= text_field_tag "template[questions][#{index}][options]", question["options"].join(", "), placeholder: "Ótimo, Bom, Regular, Ruim", id: "template_questions_#{index}_options" %>
<%= hidden_field_tag "template[questions][#{index}][id]", question["id"] %>
<% end %>
- <%= submit_tag "Criar Template", class: "btn btn--primary" %> - <%= link_to "Cancelar", admin_templates_path, class: "btn btn--ghost" %> + + +
+ <%= submit_tag "Criar Template", class: "btn btn--primary" %> + <%= link_to "Cancelar", admin_templates_path, class: "btn btn--ghost" %> +
<% end %> - \ No newline at end of file + + + \ No newline at end of file From d9c83ed8050e882e3cc2c53355ea0a0916a9d4b2 Mon Sep 17 00:00:00 2001 From: Liferoijrm Date: Mon, 15 Jun 2026 20:39:37 -0300 Subject: [PATCH 38/55] =?UTF-8?q?:sparkles:feat:=20download=20de=20csv=20p?= =?UTF-8?q?ara=20resultados=20de=20formul=C3=A1rio=20e=20step=20definition?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 + Gemfile.lock | 3 + app/controllers/admin_controller.rb | 29 ++- app/views/admin/exportar_csv.csv.erb | 24 +++ app/views/admin/resultados.html.erb | 6 +- app/views/layouts/gerenciamento.html.erb | 2 +- config/routes.rb | 2 + features/gerar_relatorio_csv.feature | 27 +-- .../step_definitions/exportar_csv_steps.rb | 204 ++++++++++++++++++ 9 files changed, 277 insertions(+), 22 deletions(-) create mode 100644 app/views/admin/exportar_csv.csv.erb create mode 100644 features/step_definitions/exportar_csv_steps.rb diff --git a/Gemfile b/Gemfile index 892d972fbd..1bf3a65bed 100644 --- a/Gemfile +++ b/Gemfile @@ -31,6 +31,8 @@ gem "solid_cable" # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false +gem 'csv' + # Deploy this application anywhere as a Docker container [https://kamal-deploy.org] gem "kamal", require: false diff --git a/Gemfile.lock b/Gemfile.lock index c6a237f391..bf875f5b58 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -103,6 +103,7 @@ GEM concurrent-ruby (1.3.6) connection_pool (3.0.2) crass (1.0.6) + csv (3.3.5) cucumber (10.2.0) base64 (~> 0.2) builder (~> 3.2) @@ -454,6 +455,7 @@ DEPENDENCIES brakeman bundler-audit capybara + csv cucumber-rails database_cleaner debug @@ -505,6 +507,7 @@ CHECKSUMS concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d + csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f cucumber (10.2.0) sha256=fdedbd31ecf40858b60f04853f2aa15c44f5c30bbac29c6a227fa1e7005a8158 cucumber-ci-environment (11.0.0) sha256=0df79a9e1d0b015b3d9def680f989200d96fef206f4d19ccf86a338c4f71d1e2 cucumber-core (16.2.0) sha256=592b58a95cf42feef8e5a349f68e363784ba3b6568ffbcf6776e38e136cf970b diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 1ba7fb72f9..58da3a6aa1 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -4,6 +4,9 @@ class AdminController < ApplicationController def avaliacoes end + def gerenciamento + end + def resultados @admin = Administrador.find_by(id: session[:usuario_id]) @@ -14,7 +17,31 @@ def resultados end end - def gerenciamento + def exportar_csv + @formulario = Formulario.find_by(id: params[:id]) + + if @formulario + # O .includes carrega o usuário e também os resposta_elems junto com seus respectivo elemento_form + @respostas = RespostaForm.where(formulario_id: @formulario.id).includes(:usuario, resposta_elems: :elemento_form) + + if @formulario.resposta_forms.empty? + redirect_to admin_resultados_path,alert: "Falha na exportação: Este formulário ainda não possui respostas registradas." + return + end + + respond_to do |format| + format.csv do + num_turma = @formulario.turma&.numero_da_turma&.parameterize(separator: '_') || "sem_turma" + nome_materia = @formulario.turma&.disciplina&.nome&.parameterize(separator: '_') || "sem_materia" + nome_arquivo = "formulario_#{@formulario.id}_turma_#{num_turma}_#{nome_materia}.csv" + + # Força o download + response.headers['Content-Disposition'] = "attachment; filename=\"#{nome_arquivo}\"" + end + end + else + redirect_to admin_resultados_path, alert: "Formulário não encontrado" + end end def importar_sigaa diff --git a/app/views/admin/exportar_csv.csv.erb b/app/views/admin/exportar_csv.csv.erb new file mode 100644 index 0000000000..fae955b369 --- /dev/null +++ b/app/views/admin/exportar_csv.csv.erb @@ -0,0 +1,24 @@ +<% + colunas_dinamicas = ElementoForm.where(formulario_id: @formulario.id) + .order(:ordem) + .pluck(:enunciado) + + cabecalho = ["Usuário da Resposta", "Data de Submissão"] + colunas_dinamicas +-%> +<%= raw CSV.generate_line(cabecalho) -%> +<% @respostas.each do |resposta| -%> +<% + respostas_do_usuario = resposta.resposta_elems.index_by { |re| re.elemento_form.enunciado } + + linha = [ + resposta.usuario&.nome || "Anônimo", + resposta.created_at.strftime("%d/%m/%Y %H:%M") + ] + + colunas_dinamicas.each do |enunciado| + resposta_do_campo = respostas_do_usuario[enunciado] + linha << resposta_do_campo&.texto_resposta + end +-%> +<%= raw CSV.generate_line(linha) -%> +<% end -%> \ No newline at end of file diff --git a/app/views/admin/resultados.html.erb b/app/views/admin/resultados.html.erb index 1cbae455bc..47ad89b4de 100644 --- a/app/views/admin/resultados.html.erb +++ b/app/views/admin/resultados.html.erb @@ -11,10 +11,10 @@ <%= formulario.turma.disciplina.nome %>

- <%= formulario.turma.semestre %> + Turma <%= formulario.turma.numero_da_turma %>

- <%= formulario.turma.horario %> + <%= formulario.turma.semestre %> - <%= formulario.turma.horario %>

@@ -24,7 +24,7 @@ <%= formulario.turma.docentes.first&.nome || "Professor(a) não alocado(a)" %>

- <%= link_to "Baixar Resultado", "#", style: "display: block; text-align: center; background-color: #612F65; color: white; text-decoration: none; padding: 10px 16px; border-radius: 4px; font-weight: bold; font-size: 0.9rem;" %> + <%= link_to "Baixar Resultado", baixar_csv_path(id: formulario.id, format: :csv), style: "display: block; text-align: center; background-color: #612F65; color: white; text-decoration: none; padding: 10px 16px; border-radius: 4px; font-weight: bold; font-size: 0.9rem;" %> diff --git a/app/views/layouts/gerenciamento.html.erb b/app/views/layouts/gerenciamento.html.erb index e9c6234870..263aa4f4a0 100644 --- a/app/views/layouts/gerenciamento.html.erb +++ b/app/views/layouts/gerenciamento.html.erb @@ -36,7 +36,7 @@ Avaliações - + Gerenciamento diff --git a/config/routes.rb b/config/routes.rb index a25b15fa2c..5008d6ee11 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,7 +42,9 @@ post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa post "admin/atualizar_sigaa", to: "admin#atualizar_sigaa", as: :atualizar_sigaa + get "/admin/resultados", to: "admin#resultados", as: :admin_resultados + get "/admin/resultados/:id/download.csv", to: "admin#exportar_csv", as: :baixar_csv get "up" => "rails/health#show", as: :rails_health_check # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) diff --git a/features/gerar_relatorio_csv.feature b/features/gerar_relatorio_csv.feature index f9d6d66440..1178162060 100644 --- a/features/gerar_relatorio_csv.feature +++ b/features/gerar_relatorio_csv.feature @@ -7,27 +7,20 @@ Funcionalidade: Download de resultados de formulário em CSV A fim de avaliar o desempenho das turmas Contexto: - Dado que estou autenticado no sistema com o perfil de "Administrador" - E existe a "Turma A" que possui o formulário "Avaliação Semestral" associado a ela + Dado que estou na página de Resultados + E vejo os formulários enviados para todas as turmas do meu departamento + E existe a "Turma A" de "Estruturas de Dados" que possui um formulário associado a ela E este formulário já possui respostas enviadas pelos alunos Cenário: Baixar resultados do formulário com sucesso (happy path) - Dado que estou na página de detalhes do formulário "Avaliação Semestral" da "Turma A" - Quando eu clico em "Baixar Resultados (CSV)" - Então o download do arquivo "resultados_avaliacao_semestral.csv" é iniciado - E vejo a mensagem "Arquivo exportado com sucesso." - E o arquivo deve conter as colunas correspondentes aos elementos do formulário e suas respectivas respostas + Quando eu sigo "Baixar Resultado" + Então o download do arquivo "formulario da Turma A de Estruturas de Dados" é iniciado + E o arquivo deve conter as colunas Usuário da Resposta, Data de Submissão e elementos do formulário + E o arquivo deve conter como linhas as respostas de cada usuário Cenário: Tentar baixar CSV de um formulário que não possui respostas (sad path) - Dado que a "Turma A" possui outro formulário chamado "Questionário Opcional" + Dado que a "Turma A" possui outro formulário E este formulário não recebeu nenhuma resposta até o momento - E estou na página de detalhes do formulário "Questionário Opcional" - Quando eu clico em "Baixar Resultados (CSV)" + Quando eu sigo "Baixar Resultado" Então vejo a mensagem de erro "Falha na exportação: Este formulário ainda não possui respostas registradas." - E nenhum download de arquivo é iniciado - - Cenário: Instabilidade no servidor interrompe a geração do CSV (sad path) - Dado que estou na página de detalhes do formulário "Avaliação Semestral" da "Turma A" - E o servidor de arquivos encontra-se indisponível no momento - Quando eu clico em "Baixar Resultados (CSV)" - Então vejo a mensagem de erro "Falha no sistema: O servidor demorou muito para responder. Tente novamente em instantes." \ No newline at end of file + E nenhum download de arquivo é iniciado \ No newline at end of file diff --git a/features/step_definitions/exportar_csv_steps.rb b/features/step_definitions/exportar_csv_steps.rb new file mode 100644 index 0000000000..4687e68e13 --- /dev/null +++ b/features/step_definitions/exportar_csv_steps.rb @@ -0,0 +1,204 @@ +# encoding: UTF-8 + +require 'csv' + +Dado("que estou na página de Resultados") do + @departamento = Departamento.create!( + codigo: "DEP01", + nome: "Departamento de Computação" + ) + + @admin = Administrador.create!( + matricula: "ADM001", + nome: "Admin Teste", + email: "admin@teste.com", + departamento: @departamento + ) + + # Reutiliza o step de login já existente nos steps de autenticação + step 'que meu usuário está cadastrado com o email "admin@teste.com" e senha "senha123"' + step 'eu tento realizar o login com o email "admin@teste.com" e a senha "senha123"' + + visit admin_resultados_path +end + +Dado("vejo os formulários enviados para todas as turmas do meu departamento") do + expect(page).to have_current_path(admin_resultados_path) +end + +Dado("existe a {string} de {string} que possui um formulário associado a ela") do |nome_turma, nome_disciplina| + @disciplina = Disciplina.create!( + codigo: "ED001", + nome: nome_disciplina, + departamento: @departamento + ) + + @turma = Turma.create!( + numero_da_turma: nome_turma, + semestre: "2024.1", + horario: "SEG 08:00-10:00", + disciplina: @disciplina + ) + + @formulario = Formulario.create!(turma: @turma) + + @elemento1 = ElementoForm.create!( + ordem: 1, + enunciado: "Como você avalia o professor?", + formulario: @formulario + ) + + @elemento2 = ElementoForm.create!( + ordem: 2, + enunciado: "Como você avalia a disciplina?", + formulario: @formulario + ) +end + +Dado("este formulário já possui respostas enviadas pelos alunos") do + @curso_aluno = Curso.create!( + codigo: "CC01", + nome: "Ciência da Computação", + departamento: @departamento + ) + + @aluno = Discente.create!( + matricula: "ALU001", + nome: "Aluno Teste", + email: "aluno@teste.com", + curso: @curso_aluno, + departamento: @departamento + ) + + @resposta = RespostaForm.create!( + formulario: @formulario, + usuario: @aluno, + data_submissao: Date.today + ) + + @template = Template.new(nome: "Template Padrão") + elemento_base = @template.elementos.build(ordem: 1, enunciado: "Avaliação") + elemento_base.campos.build(ordem: 1, enunciado: "Muito bom", tipo_elemento: "Múltipla Escolha") + elemento_base.campos.build(ordem: 2, enunciado: "Excelente", tipo_elemento: "Múltipla Escolha") + @template.save! + + [@elemento1, @elemento2].each do |ef| + elemento_base.campos.each do |campo_base| + CampoForm.find_or_create_by!(enunciado: campo_base.enunciado, elemento_form: ef) do |cf| + cf.ordem = campo_base.ordem + end + end + end + + { + @elemento1 => "Muito bom", + @elemento2 => "Excelente" + }.each do |ef, texto| + cf = ef.campo_forms.find_by!(enunciado: texto) + + RespostaElem.create!( + texto_resposta: texto, + resposta_form: @resposta, + elemento_form: ef, + campo_form: cf + ) + end + + visit admin_resultados_path +end + + +# Happy Path + +Quando("eu sigo {string}") do |link| + formulario_alvo = defined?(@formulario_vazio) ? @formulario_vazio : @formulario + find(:link, link, href: /#{formulario_alvo.id}/).click +end + +Então("o download do arquivo {string} é iniciado") do |_nome_ignorado| + num_turma = @formulario.turma.numero_da_turma.parameterize(separator: '_') + nome_materia = @formulario.turma.disciplina.nome.parameterize(separator: '_') + nome_esperado = "formulario_#{@formulario.id}_turma_#{num_turma}_#{nome_materia}" + + content_disposition = page.response_headers["Content-Disposition"] + + expect(content_disposition).to be_present, + "Esperava um header Content-Disposition indicando download, mas não havia nenhum." + + expect(content_disposition).to include("attachment"), + "Esperava 'attachment' no Content-Disposition, mas foi: #{content_disposition}" + + expect(content_disposition).to include(nome_esperado), + "Esperava '#{nome_esperado}' no nome do arquivo, " \ + "mas o header foi: #{content_disposition}" +end + +Então("o arquivo deve conter as colunas Usuário da Resposta, Data de Submissão e elementos do formulário") do + csv_content = CSV.parse(page.body) + cabecalho = csv_content.first + + expect(cabecalho).to include("Usuário da Resposta"), + "Esperava a coluna 'Usuário da Resposta' no cabeçalho, mas foi: #{cabecalho.inspect}" + + expect(cabecalho).to include("Data de Submissão"), + "Esperava a coluna 'Data de Submissão' no cabeçalho, mas foi: #{cabecalho.inspect}" + + ElementoForm.where(formulario_id: @formulario.id).order(:ordem).each do |elem| + expect(cabecalho).to include(elem.enunciado), + "Esperava a coluna '#{elem.enunciado}' no cabeçalho, mas foi: #{cabecalho.inspect}" + end +end + +Então("o arquivo deve conter como linhas as respostas de cada usuário") do + csv_content = CSV.parse(page.body) + + linhas_de_dados = csv_content[1..] + + expect(linhas_de_dados).not_to be_empty, + "Esperava pelo menos uma linha de dados no CSV, mas o arquivo só possui o cabeçalho." + + nomes_nas_linhas = linhas_de_dados.map(&:first) + expect(nomes_nas_linhas).to include(@aluno.nome), + "Esperava encontrar '#{@aluno.nome}' nas linhas de dados, mas encontrei: #{nomes_nas_linhas.inspect}" + + RespostaElem.where(resposta_form_id: @resposta.id).each do |re| + conteudo_csv = linhas_de_dados.flatten + expect(conteudo_csv).to include(re.texto_resposta), + "Esperava encontrar a resposta '#{re.texto_resposta}' no CSV." + end +end + +# Sad Path + +Dado("que a {string} possui outro formulário") do |nome_turma| + @turma_sad = Turma.find_by(numero_da_turma: nome_turma) || @turma + + @formulario_vazio = Formulario.create!(turma: @turma_sad) + + ElementoForm.create!( + ordem: 1, + enunciado: "Pergunta sem respostas", + formulario: @formulario_vazio + ) +end + +Dado("este formulário não recebeu nenhuma resposta até o momento") do + expect( + RespostaForm.where(formulario_id: @formulario_vazio.id).count + ).to eq(0), "Esperava 0 respostas para o formulário vazio, mas havia algumas." + + visit admin_resultados_path +end + +Então("vejo a mensagem de erro {string}") do |mensagem_esperada| + expect(page).to have_content(mensagem_esperada), + "Esperava ver '#{mensagem_esperada}' na página, mas não encontrei." +end + +Então("nenhum download de arquivo é iniciado") do + content_disposition = page.response_headers["Content-Disposition"] + + expect(content_disposition).to be_nil.or( + satisfy { |cd| !cd.to_s.include?("attachment") } + ), "Não esperava um header de download 'attachment', mas encontrei: #{content_disposition}" +end From 11744bde95eb7f9ddbaf1614421df7e0139b27ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Tue, 16 Jun 2026 10:48:40 -0300 Subject: [PATCH 39/55] :wrench: fix/fixes do lint --- Gemfile.lock | 8 ++++++++ app/controllers/admin/dashboard_controller.rb | 18 +++++++++--------- app/controllers/admin/forms_controller.rb | 4 ++-- app/controllers/admin/templates_controller.rb | 6 +++--- app/controllers/application_controller.rb | 2 +- app/controllers/forms_controller.rb | 2 +- app/controllers/home_controller.rb | 2 +- app/controllers/sessions_controller.rb | 2 +- app/models/camaar/workspace.rb | 8 ++++---- app/models/workspace_state.rb | 2 +- config/routes.rb | 6 +++--- .../20260615220605_create_workspace_states.rb | 2 +- db/seeds.rb | 2 +- 13 files changed, 36 insertions(+), 28 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7b3f9a603e..0cb75e9899 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -157,6 +157,7 @@ GEM ffi (1.17.4-aarch64-linux-musl) ffi (1.17.4-arm-linux-gnu) ffi (1.17.4-arm-linux-musl) + ffi (1.17.4-arm64-darwin) ffi (1.17.4-x64-mingw-ucrt) ffi (1.17.4-x86_64-linux-gnu) ffi (1.17.4-x86_64-linux-musl) @@ -243,6 +244,8 @@ GEM racc (~> 1.4) nokogiri (1.19.3-arm-linux-musl) racc (~> 1.4) + nokogiri (1.19.3-arm64-darwin) + racc (~> 1.4) nokogiri (1.19.3-x64-mingw-ucrt) racc (~> 1.4) nokogiri (1.19.3-x86_64-linux-gnu) @@ -411,6 +414,7 @@ GEM thor (1.5.0) thruster (0.1.21) thruster (0.1.21-aarch64-linux) + thruster (0.1.21-arm64-darwin) thruster (0.1.21-x86_64-linux) timeout (0.6.1) tsort (0.2.0) @@ -446,6 +450,7 @@ PLATFORMS aarch64-linux-musl arm-linux-gnu arm-linux-musl + arm64-darwin-25 x64-mingw-ucrt x86_64-linux x86_64-linux-gnu @@ -535,6 +540,7 @@ CHECKSUMS ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39 ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564 ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95 + ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b ffi (1.17.4-x64-mingw-ucrt) sha256=f6ff9618cfccc494138bddade27aa06c74c6c7bc367a1ea1103d80c2fcb9ed35 ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e @@ -574,6 +580,7 @@ CHECKSUMS nokogiri (1.19.3-aarch64-linux-musl) sha256=8392dfdcd21be7a94dbbe9ccc138dea01b97b24cb2dc02a114ca98bfb1d9a0b7 nokogiri (1.19.3-arm-linux-gnu) sha256=3919d5ffc334ad778a4a9eb88fda7dcb8b1fb58c8a52ac640c6dcd2f038e774f nokogiri (1.19.3-arm-linux-musl) sha256=9ce1cb6346bb9c67b1550eb537aa183ead91e4b6eadb2f36ade02d8dd2a79fb6 + nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42 nokogiri (1.19.3-x64-mingw-ucrt) sha256=8bb7132cad356c879a1286eaabcb5e68326cb2490317984280fbc62f456d506a nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976 nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f @@ -629,6 +636,7 @@ CHECKSUMS thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 thruster (0.1.21) sha256=dc67928f36e5894844579a95e45637a5091db7a7ea05468ee8c2c6eb0a3f77cf thruster (0.1.21-aarch64-linux) sha256=f5aff78fb7a6431ed3d6ab4bde03a89c461e9a73981dbc97d6990d85c3db235c + thruster (0.1.21-arm64-darwin) sha256=bd8db9f57fae2cbb3fe08ebab49cb47fe49608122dac23daf0ce709adfb9bfc8 thruster (0.1.21-x86_64-linux) sha256=6e2fbcf826540a72d3710ae4db072c2333287ac2ee57e7e52f35bc10900d74a7 timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index bcbfea5851..d6c731faa7 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -1,7 +1,7 @@ module Admin class DashboardController < ApplicationController before_action :require_admin - layout 'gerenciamento' + layout "gerenciamento" def index @workspace = workspace @@ -32,13 +32,13 @@ def processar_sincronizacao temp_file = arquivo.path resultado = case acao - when 'importar' + when "importar" SigaaImporter.import_from_files(temp_file, temp_file) - when 'atualizar' + when "atualizar" SigaaImporter.update_from_files(temp_file, temp_file) - else + else "ação inválida" - end + end processar_resultado(resultado, acao) end @@ -46,13 +46,13 @@ def processar_sincronizacao def processar_resultado(resultado, acao) case resultado when /alguns dados/i - if acao == 'importar' + if acao == "importar" redirect_to admin_gerenciamento_path, notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" else redirect_to admin_gerenciamento_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" end when /sucesso/i - if acao == 'importar' + if acao == "importar" redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." else redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." @@ -62,9 +62,9 @@ def processar_resultado(resultado, acao) when /já estão atualizados/i redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" else - nome_acao = acao == 'importar' ? 'importação' : 'atualização' + nome_acao = acao == "importar" ? "importação" : "atualização" redirect_to admin_gerenciamento_path, alert: "erro informando que a #{nome_acao} falhou" end end end -end \ No newline at end of file +end diff --git a/app/controllers/admin/forms_controller.rb b/app/controllers/admin/forms_controller.rb index ff705e3da3..7a7d5d3cb3 100644 --- a/app/controllers/admin/forms_controller.rb +++ b/app/controllers/admin/forms_controller.rb @@ -3,7 +3,7 @@ module Admin class FormsController < ApplicationController before_action :require_admin - layout 'gerenciamento' + layout "gerenciamento" def index @workspace = workspace @@ -70,4 +70,4 @@ def form_payload } end end -end \ No newline at end of file +end diff --git a/app/controllers/admin/templates_controller.rb b/app/controllers/admin/templates_controller.rb index 8153559011..599c5cdc23 100644 --- a/app/controllers/admin/templates_controller.rb +++ b/app/controllers/admin/templates_controller.rb @@ -3,7 +3,7 @@ module Admin class TemplatesController < ApplicationController before_action :require_admin - layout 'gerenciamento' + layout "gerenciamento" def index @workspace = workspace @@ -57,7 +57,7 @@ def blank_template "title" => "", "semester" => "2026.1", "questions" => [ - { "id" => SecureRandom.uuid, "title" => "Questão 1", "type" => "radio", "options" => ["Ótimo", "Bom", "Regular", "Ruim"] } + { "id" => SecureRandom.uuid, "title" => "Questão 1", "type" => "radio", "options" => [ "Ótimo", "Bom", "Regular", "Ruim" ] } ] } end @@ -82,4 +82,4 @@ def template_payload } end end -end \ No newline at end of file +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6e562078bb..4f3ffc5dc8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -29,4 +29,4 @@ def require_admin redirect_to inicio_path, alert: "Acesso restrito a administradores" end end -end \ No newline at end of file +end diff --git a/app/controllers/forms_controller.rb b/app/controllers/forms_controller.rb index d431c9fce3..0ef45b1e59 100644 --- a/app/controllers/forms_controller.rb +++ b/app/controllers/forms_controller.rb @@ -34,4 +34,4 @@ def response_payload "answers" => payload[:answers].to_h.transform_values { |value| value.to_s } } end -end \ No newline at end of file +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 247d9e9aee..93633edc50 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -9,4 +9,4 @@ def index @forms = @workspace.forms.select { |f| f["active"] } end end -end \ No newline at end of file +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 32378d9d5f..83c9f03c80 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -46,4 +46,4 @@ def destroy reset_session redirect_to root_path end -end \ No newline at end of file +end diff --git a/app/models/camaar/workspace.rb b/app/models/camaar/workspace.rb index 030ed9d491..99f25bab89 100644 --- a/app/models/camaar/workspace.rb +++ b/app/models/camaar/workspace.rb @@ -13,7 +13,7 @@ class Workspace "id" => "template-1-q1", "title" => "Questão 1", "type" => "radio", - "options" => ["Ótimo", "Bom", "Regular", "Ruim"] + "options" => [ "Ótimo", "Bom", "Regular", "Ruim" ] }, { "id" => "template-1-q2", @@ -38,7 +38,7 @@ class Workspace "id" => "form-1-q1", "title" => "Como você avalia o professor?", "type" => "radio", - "options" => ["Ótimo", "Bom", "Regular", "Ruim"] + "options" => [ "Ótimo", "Bom", "Regular", "Ruim" ] } ], "responses" => [] @@ -56,7 +56,7 @@ class Workspace "id" => "form-2-q1", "title" => "Como você avalia o ambiente da disciplina?", "type" => "radio", - "options" => ["Ótimo", "Bom", "Regular", "Ruim"] + "options" => [ "Ótimo", "Bom", "Regular", "Ruim" ] } ], "responses" => [] @@ -216,4 +216,4 @@ def normalize_questions(raw_questions) end end end -end \ No newline at end of file +end diff --git a/app/models/workspace_state.rb b/app/models/workspace_state.rb index 50566fd85c..d4a9270879 100644 --- a/app/models/workspace_state.rb +++ b/app/models/workspace_state.rb @@ -2,4 +2,4 @@ class WorkspaceState < ApplicationRecord def self.instance first_or_create!(data: Camaar::Workspace::DEFAULT_STATE.deep_dup) end -end \ No newline at end of file +end diff --git a/config/routes.rb b/config/routes.rb index 159c7dbcfb..db8c94d063 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -29,7 +29,7 @@ resources :departamentos # User forms (responder avaliações) - resources :forms, only: [:index, :show] do + resources :forms, only: [ :index, :show ] do member do post :create_response end @@ -45,7 +45,7 @@ get "avaliacoes", to: "dashboard#index" get "gerenciamento", to: "dashboard#gerenciamento" - resources :forms, only: [:index, :new, :create] do + resources :forms, only: [ :index, :new, :create ] do member do post :publish get :results @@ -57,4 +57,4 @@ get "sincronizar_sigaa", to: "dashboard#sincronizar_sigaa", as: :sincronizar_sigaa post "sincronizar_sigaa", to: "dashboard#sincronizar_sigaa" end -end \ No newline at end of file +end diff --git a/db/migrate/20260615220605_create_workspace_states.rb b/db/migrate/20260615220605_create_workspace_states.rb index 263cb3ff4b..c9a45ad28d 100644 --- a/db/migrate/20260615220605_create_workspace_states.rb +++ b/db/migrate/20260615220605_create_workspace_states.rb @@ -5,4 +5,4 @@ def change t.timestamps end end -end \ No newline at end of file +end diff --git a/db/seeds.rb b/db/seeds.rb index 26d7080d97..41a38a0283 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -62,4 +62,4 @@ puts "Usuários criados:" puts " discente@teste.com / teste123 (Discente)" puts " docente@teste.com / teste123 (Docente)" -puts " admin@teste.com / teste123 (Admin)" \ No newline at end of file +puts " admin@teste.com / teste123 (Admin)" From 01e5319e3128bf42e26f997dcce6599cef6b3b03 Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Tue, 16 Jun 2026 13:02:21 -0300 Subject: [PATCH 40/55] teste --- config/database.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/database.yml b/config/database.yml index a857bdc858..63ad6ca8d5 100644 --- a/config/database.yml +++ b/config/database.yml @@ -13,8 +13,8 @@ default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - username: root - password: root + username: camaar + password: senha_do_camaar socket: /var/run/mysqld/mysqld.sock development: From a65b1be9190b6609a1d69894bd7e52f58b176b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Tue, 16 Jun 2026 13:30:54 -0300 Subject: [PATCH 41/55] arrumacao dos crias --- Gemfile.lock | 8 ++++++++ app/controllers/sessions_controller.rb | 4 ++-- config/database.yml | 6 +++--- features/step_definitions/cadastro_steps.rb | 2 ++ .../step_definitions/criar_formulario_template_steps.rb | 8 -------- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7b3f9a603e..10ff60073b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -157,6 +157,7 @@ GEM ffi (1.17.4-aarch64-linux-musl) ffi (1.17.4-arm-linux-gnu) ffi (1.17.4-arm-linux-musl) + ffi (1.17.4-arm64-darwin) ffi (1.17.4-x64-mingw-ucrt) ffi (1.17.4-x86_64-linux-gnu) ffi (1.17.4-x86_64-linux-musl) @@ -243,6 +244,8 @@ GEM racc (~> 1.4) nokogiri (1.19.3-arm-linux-musl) racc (~> 1.4) + nokogiri (1.19.3-arm64-darwin) + racc (~> 1.4) nokogiri (1.19.3-x64-mingw-ucrt) racc (~> 1.4) nokogiri (1.19.3-x86_64-linux-gnu) @@ -411,6 +414,7 @@ GEM thor (1.5.0) thruster (0.1.21) thruster (0.1.21-aarch64-linux) + thruster (0.1.21-arm64-darwin) thruster (0.1.21-x86_64-linux) timeout (0.6.1) tsort (0.2.0) @@ -446,6 +450,7 @@ PLATFORMS aarch64-linux-musl arm-linux-gnu arm-linux-musl + arm64-darwin-25 x64-mingw-ucrt x86_64-linux x86_64-linux-gnu @@ -535,6 +540,7 @@ CHECKSUMS ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39 ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564 ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95 + ffi (1.17.4-arm64-darwin) ffi (1.17.4-x64-mingw-ucrt) sha256=f6ff9618cfccc494138bddade27aa06c74c6c7bc367a1ea1103d80c2fcb9ed35 ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e @@ -574,6 +580,7 @@ CHECKSUMS nokogiri (1.19.3-aarch64-linux-musl) sha256=8392dfdcd21be7a94dbbe9ccc138dea01b97b24cb2dc02a114ca98bfb1d9a0b7 nokogiri (1.19.3-arm-linux-gnu) sha256=3919d5ffc334ad778a4a9eb88fda7dcb8b1fb58c8a52ac640c6dcd2f038e774f nokogiri (1.19.3-arm-linux-musl) sha256=9ce1cb6346bb9c67b1550eb537aa183ead91e4b6eadb2f36ade02d8dd2a79fb6 + nokogiri (1.19.3-arm64-darwin) nokogiri (1.19.3-x64-mingw-ucrt) sha256=8bb7132cad356c879a1286eaabcb5e68326cb2490317984280fbc62f456d506a nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976 nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f @@ -629,6 +636,7 @@ CHECKSUMS thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 thruster (0.1.21) sha256=dc67928f36e5894844579a95e45637a5091db7a7ea05468ee8c2c6eb0a3f77cf thruster (0.1.21-aarch64-linux) sha256=f5aff78fb7a6431ed3d6ab4bde03a89c461e9a73981dbc97d6990d85c3db235c + thruster (0.1.21-arm64-darwin) thruster (0.1.21-x86_64-linux) sha256=6e2fbcf826540a72d3710ae4db072c2333287ac2ee57e7e52f35bc10900d74a7 timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index b28853d734..eab5513bc4 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -49,9 +49,9 @@ def destroy def redirect_para_pagina_do_usuario(usuario) if usuario.is_a?(Administrador) - redirect_to admin_avaliacoes_path(usuario.id) + redirect_to admin_avaliacoes_path(usuario.id), notice: "Login realizado com sucesso." else - redirect_to usuario_path(usuario.id) + redirect_to inicio_path, notice: "Login realizado com sucesso." end end end diff --git a/config/database.yml b/config/database.yml index 63ad6ca8d5..5de2017194 100644 --- a/config/database.yml +++ b/config/database.yml @@ -13,9 +13,9 @@ default: &default adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - username: camaar - password: senha_do_camaar - socket: /var/run/mysqld/mysqld.sock + username: root + password: + host: 127.0.0.1 development: <<: *default diff --git a/features/step_definitions/cadastro_steps.rb b/features/step_definitions/cadastro_steps.rb index 69416073bc..26995f2078 100644 --- a/features/step_definitions/cadastro_steps.rb +++ b/features/step_definitions/cadastro_steps.rb @@ -8,6 +8,8 @@ departamento: departamento ) + allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) + allow_any_instance_of(AdminController).to receive(:set_admin) do |controller| controller.instance_variable_set(:@admin, Administrador.find(controller.params[:admin_id])) end diff --git a/features/step_definitions/criar_formulario_template_steps.rb b/features/step_definitions/criar_formulario_template_steps.rb index d6fadcdfae..2f3062c3ea 100644 --- a/features/step_definitions/criar_formulario_template_steps.rb +++ b/features/step_definitions/criar_formulario_template_steps.rb @@ -99,14 +99,6 @@ # TODO: Garantir que nenhuma turma está selecionada end -Quando('eu clico em {string}') do |nome_botao| - click_button nome_botao -end - -Então('eu devo ver a mensagem {string}') do |mensagem| - expect(page).to have_content(mensagem) -end - Então('o formulário deve conter as perguntas do template {string}') do |nome_template| # TODO: Verificar se o formulário foi criado com os elementos copiados do template # template = Template.find_by!(nome: nome_template) From cce17c3e23dfa428fcd86a809eeed1e975ae4afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Tue, 16 Jun 2026 15:19:17 -0300 Subject: [PATCH 42/55] fixing dos crias 2.0 --- Gemfile | 2 +- Gemfile.lock | 14 +++--- app/controllers/admin_controller.rb | 20 +++----- app/views/admin/gerenciamento.html.erb | 2 +- app/views/admin/resultados.html.erb | 2 +- config/routes.rb | 5 +- db/seeds.rb | 48 +++++++++---------- .../step_definitions/exportar_csv_steps.rb | 40 ++++++++-------- 8 files changed, 62 insertions(+), 71 deletions(-) diff --git a/Gemfile b/Gemfile index e7d3112a4a..a105698d72 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ gem "solid_cable" # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false -gem 'csv' +gem "csv" # Deploy this application anywhere as a Docker container [https://kamal-deploy.org] gem "kamal", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 96629d622f..deb32c804a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -339,7 +339,7 @@ GEM rspec-mocks (>= 3.13.0, < 5.0.0) rspec-support (>= 3.13.0, < 5.0.0) rspec-support (3.13.7) - rubocop (1.87.0) + rubocop (1.88.0) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -373,7 +373,7 @@ GEM logger rubyzip (3.4.0) securerandom (0.4.1) - selenium-webdriver (4.44.0) + selenium-webdriver (4.45.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) @@ -543,7 +543,7 @@ CHECKSUMS ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39 ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564 ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95 - ffi (1.17.4-arm64-darwin) + ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b ffi (1.17.4-x64-mingw-ucrt) sha256=f6ff9618cfccc494138bddade27aa06c74c6c7bc367a1ea1103d80c2fcb9ed35 ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e @@ -583,7 +583,7 @@ CHECKSUMS nokogiri (1.19.3-aarch64-linux-musl) sha256=8392dfdcd21be7a94dbbe9ccc138dea01b97b24cb2dc02a114ca98bfb1d9a0b7 nokogiri (1.19.3-arm-linux-gnu) sha256=3919d5ffc334ad778a4a9eb88fda7dcb8b1fb58c8a52ac640c6dcd2f038e774f nokogiri (1.19.3-arm-linux-musl) sha256=9ce1cb6346bb9c67b1550eb537aa183ead91e4b6eadb2f36ade02d8dd2a79fb6 - nokogiri (1.19.3-arm64-darwin) + nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42 nokogiri (1.19.3-x64-mingw-ucrt) sha256=8bb7132cad356c879a1286eaabcb5e68326cb2490317984280fbc62f456d506a nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976 nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f @@ -618,7 +618,7 @@ CHECKSUMS rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47 rspec-rails (8.0.4) sha256=06235692fc0892683d3d34977e081db867434b3a24ae0dd0c6f3516bad4e22df rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c - rubocop (1.87.0) sha256=b9d9ddf55116a513f8ef2c7ae660662d8b49301f118d3f0df61865b33a5c188d + rubocop (1.88.0) sha256=e420ddf1662d0ef34bc8a2910ac4b396a7ddda0b51a708264405241734b08e0b rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035 rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834 rubocop-rails (2.35.4) sha256=3aeaa325439c89950e8327565682ea794065d08e2ecbbfe95032bfa295a35df5 @@ -627,7 +627,7 @@ CHECKSUMS ruby-vips (2.3.0) sha256=e685ec02c13969912debbd98019e50492e12989282da5f37d05f5471442f5374 rubyzip (3.4.0) sha256=6de39bc9eba302b635a476d16c9e16b0872ad24517c2f98f2b3a7ea23caff57b securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1 - selenium-webdriver (4.44.0) sha256=6f1df072529af369589c46f0e01132952aabb250cfd683c274d74dc1eb5d8477 + selenium-webdriver (4.45.0) sha256=ecac65a4df86ac6f7d707e6dcbacaa9c08b6cf2b966babecfb9653c5aa13e2d1 solid_cable (4.0.0) sha256=8379680ef6bf36e195eb876a6306ea290f87d5fa10bc4a757bc2a918f83229b5 solid_cache (1.0.10) sha256=bc05a2fb3ac78a6f43cbb5946679cf9db67dd30d22939ededc385cb93e120d41 solid_queue (1.4.0) sha256=e6a18d196f0b27cb6e3c77c5b31258b05fb634f8ed64fb1866ed164047216c2a @@ -639,7 +639,7 @@ CHECKSUMS thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 thruster (0.1.21) sha256=dc67928f36e5894844579a95e45637a5091db7a7ea05468ee8c2c6eb0a3f77cf thruster (0.1.21-aarch64-linux) sha256=f5aff78fb7a6431ed3d6ab4bde03a89c461e9a73981dbc97d6990d85c3db235c - thruster (0.1.21-arm64-darwin) + thruster (0.1.21-arm64-darwin) sha256=bd8db9f57fae2cbb3fe08ebab49cb47fe49608122dac23daf0ce709adfb9bfc8 thruster (0.1.21-x86_64-linux) sha256=6e2fbcf826540a72d3710ae4db072c2333287ac2ee57e7e52f35bc10900d74a7 timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 7891f807c6..00a8fefe3e 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -12,13 +12,7 @@ def gerenciamento end def resultados - @admin = Administrador.find_by(id: session[:usuario_id]) - - if @admin - @formularios = Formulario.joins(turma: :disciplina).where(disciplinas: { departamento_id: @admin.departamento_id }).includes(turma: :disciplina) - else - redirect_to root_path, alert: "Acesso não autorizado." - end + @formularios = Formulario.joins(turma: :disciplina).where(disciplinas: { departamento_id: @admin.departamento_id }).includes(turma: :disciplina) end def exportar_csv @@ -27,24 +21,24 @@ def exportar_csv if @formulario # O .includes carrega o usuário e também os resposta_elems junto com seus respectivo elemento_form @respostas = RespostaForm.where(formulario_id: @formulario.id).includes(:usuario, resposta_elems: :elemento_form) - + if @formulario.resposta_forms.empty? - redirect_to admin_resultados_path,alert: "Falha na exportação: Este formulário ainda não possui respostas registradas." + redirect_to admin_resultados_path(@admin), alert: "Falha na exportação: Este formulário ainda não possui respostas registradas." return end respond_to do |format| format.csv do - num_turma = @formulario.turma&.numero_da_turma&.parameterize(separator: '_') || "sem_turma" - nome_materia = @formulario.turma&.disciplina&.nome&.parameterize(separator: '_') || "sem_materia" + num_turma = @formulario.turma&.numero_da_turma&.parameterize(separator: "_") || "sem_turma" + nome_materia = @formulario.turma&.disciplina&.nome&.parameterize(separator: "_") || "sem_materia" nome_arquivo = "formulario_#{@formulario.id}_turma_#{num_turma}_#{nome_materia}.csv" # Força o download - response.headers['Content-Disposition'] = "attachment; filename=\"#{nome_arquivo}\"" + response.headers["Content-Disposition"] = "attachment; filename=\"#{nome_arquivo}\"" end end else - redirect_to admin_resultados_path, alert: "Formulário não encontrado" + redirect_to admin_resultados_path(@admin), alert: "Formulário não encontrado" end end def sincronizar_sigaa diff --git a/app/views/admin/gerenciamento.html.erb b/app/views/admin/gerenciamento.html.erb index bec91ece07..442158e716 100644 --- a/app/views/admin/gerenciamento.html.erb +++ b/app/views/admin/gerenciamento.html.erb @@ -6,6 +6,6 @@ <%= link_to "Importar / Atualizar dados do SIGAA", admin_sincronizar_sigaa_path(@admin), class: "btn-figma" %> <%= link_to "Editar Template", admin_templates_path(@admin), class: "btn-figma" %> - <%= button_to "Resultados", admin_resultados_path, method: :get, class: "btn-figma" %> + <%= button_to "Resultados", admin_resultados_path(@admin), method: :get, class: "btn-figma" %> diff --git a/app/views/admin/resultados.html.erb b/app/views/admin/resultados.html.erb index 47ad89b4de..5120a9f593 100644 --- a/app/views/admin/resultados.html.erb +++ b/app/views/admin/resultados.html.erb @@ -24,7 +24,7 @@ <%= formulario.turma.docentes.first&.nome || "Professor(a) não alocado(a)" %>

- <%= link_to "Baixar Resultado", baixar_csv_path(id: formulario.id, format: :csv), style: "display: block; text-align: center; background-color: #612F65; color: white; text-decoration: none; padding: 10px 16px; border-radius: 4px; font-weight: bold; font-size: 0.9rem;" %> + <%= link_to "Baixar Resultado", admin_baixar_csv_path(@admin, id: formulario.id, format: :csv), style: "display: block; text-align: center; background-color: #612F65; color: white; text-decoration: none; padding: 10px 16px; border-radius: 4px; font-weight: bold; font-size: 0.9rem;" %> diff --git a/config/routes.rb b/config/routes.rb index 4655abc2a3..2a329f9533 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,14 +38,13 @@ resources :templates get "sincronizar_sigaa", to: "admin#sincronizar_sigaa", as: :sincronizar_sigaa post "sincronizar_sigaa", to: "admin#sincronizar_sigaa" + get "resultados", to: "admin#resultados", as: :resultados + get "resultados/:id/download.csv", to: "admin#exportar_csv", as: :baixar_csv end post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa post "admin/atualizar_sigaa", to: "admin#atualizar_sigaa", as: :atualizar_sigaa - get "/admin/resultados", to: "admin#resultados", as: :admin_resultados - get "/admin/resultados/:id/download.csv", to: "admin#exportar_csv", as: :baixar_csv - get "up" => "rails/health#show", as: :rails_health_check # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest diff --git a/db/seeds.rb b/db/seeds.rb index 5bb5057f34..0d9e3e34e9 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -99,17 +99,13 @@ end docente = Docente.find_or_initialize_by(email: "gusfring.a@gmail.com") docente.nome ||= "GUS" -docente.matricula ||= "241000004" +docente.matricula ||= "241000067" docente.senha = "teste123" docente.senha_confirmation = "teste123" docente.departamento = dept_cic docente.formacao = "doutorado" docente.save! -# Vinculando Usuários às Turmas -discente.turmas << turma_a unless discente.turmas.include?(turma_a) -docente.turmas << turma_a unless docente.turmas.include?(turma_a) - # ========================================== # VINCULANDO USUÁRIOS ÀS TURMAS # ========================================== @@ -121,17 +117,17 @@ # Distribuindo alunos nas turmas para gerar variação de dados # Turma ED A: Alunos 1, 2 e 3 -[alunos[0], alunos[1], alunos[2]].each do |aluno| +[ alunos[0], alunos[1], alunos[2] ].each do |aluno| aluno.turmas << turma_ed_a unless aluno.turmas.include?(turma_ed_a) end # Turma ED B: Alunos 3, 4 e 5 -[alunos[2], alunos[3], alunos[4]].each do |aluno| +[ alunos[2], alunos[3], alunos[4] ].each do |aluno| aluno.turmas << turma_ed_b unless aluno.turmas.include?(turma_ed_b) end # Turma ISC A: Alunos 1, 4 e 5 -[alunos[0], alunos[4], alunos[3]].each do |aluno| +[ alunos[0], alunos[4], alunos[3] ].each do |aluno| aluno.turmas << turma_isc_a unless aluno.turmas.include?(turma_isc_a) end @@ -142,11 +138,13 @@ template = Template.find_or_initialize_by(nome: "Avaliação de Disciplina Padrão") if template.new_record? + template.administrador = admin + # --------------------------------------------------------- # Elemento 1: Múltipla Escolha (1 a 5) # --------------------------------------------------------- elemento_nota = template.elementos.build(enunciado: "Avalie a didática do professor", ordem: 1) - + (1..5).each do |valor| elemento_nota.campos.build(enunciado: valor.to_s, ordem: valor, tipo_elemento: "Múltipla Escolha") end @@ -155,8 +153,8 @@ # Elemento 2: Múltipla Escolha (Dificuldade) # --------------------------------------------------------- elemento_opcoes = template.elementos.build(enunciado: "Como você avalia a dificuldade das listas de exercícios?", ordem: 2) - - ["Muito Fácil", "Adequada", "Muito Difícil"].each_with_index do |opcao, index| + + [ "Muito Fácil", "Adequada", "Muito Difícil" ].each_with_index do |opcao, index| elemento_opcoes.campos.build(enunciado: opcao, ordem: index + 1, tipo_elemento: "Múltipla Escolha") end @@ -164,7 +162,7 @@ # Elemento 3: Texto Livre # --------------------------------------------------------- elemento_texto = template.elementos.build(enunciado: "Deixe um comentário ou sugestão sobre a disciplina", ordem: 3) - + elemento_texto.campos.build(enunciado: nil, ordem: 1, tipo_elemento: "Texto") # Salva o bloco inteiro (Template + Elementos + Campos) de uma vez, satisfazendo a validação @@ -190,7 +188,7 @@ def configurar_formulario_e_respostas(turma, template_base, dados_alunos) CampoForm.find_or_create_by!(enunciado: campo_base.enunciado, elemento_form: ef) do |c| c.ordem = campo_base.ordem # A linha abaixo foi removida pois CampoForm não possui a coluna tipo_elemento - # c.tipo_elemento = campo_base.tipo_elemento + # c.tipo_elemento = campo_base.tipo_elemento end end end @@ -223,34 +221,34 @@ def configurar_formulario_e_respostas(turma, template_base, dados_alunos) # Configurando dados para Estrutura de Dados - Turma A configurar_formulario_e_respostas( - turma_ed_a, + turma_ed_a, template, [ - { aluno: alunos[0], respostas: ["5", "Adequada", "Ótima didática, recomendo!"] }, - { aluno: alunos[1], respostas: ["4", "Muito Difícil", "As listas poderiam ter mais exemplos práticos."] }, - { aluno: alunos[2], respostas: ["5", "Adequada", "Sem reclamações, matéria excelente."] } + { aluno: alunos[0], respostas: [ "5", "Adequada", "Ótima didática, recomendo!" ] }, + { aluno: alunos[1], respostas: [ "4", "Muito Difícil", "As listas poderiam ter mais exemplos práticos." ] }, + { aluno: alunos[2], respostas: [ "5", "Adequada", "Sem reclamações, matéria excelente." ] } ] ) # Configurando dados para Estrutura de Dados - Turma B configurar_formulario_e_respostas( - turma_ed_b, + turma_ed_b, template, [ - { aluno: alunos[2], respostas: ["3", "Muito Difícil", "O ritmo das aulas está muito acelerado."] }, - { aluno: alunos[3], respostas: ["4", "Adequada", "Gostei da metodologia."] }, - { aluno: alunos[4], respostas: ["2", "Muito Difícil", "Preciso de mais monitoria para acompanhar."] } + { aluno: alunos[2], respostas: [ "3", "Muito Difícil", "O ritmo das aulas está muito acelerado." ] }, + { aluno: alunos[3], respostas: [ "4", "Adequada", "Gostei da metodologia." ] }, + { aluno: alunos[4], respostas: [ "2", "Muito Difícil", "Preciso de mais monitoria para acompanhar." ] } ] ) # Configurando dados para Introdução aos Sistemas de Computação - Turma A configurar_formulario_e_respostas( - turma_isc_a, + turma_isc_a, template, [ - { aluno: alunos[0], respostas: ["5", "Muito Fácil", "Projetos práticos são muito divertidos!"] }, - { aluno: alunos[4], respostas: ["5", "Adequada", "O professor tira todas as dúvidas e os projetos ajudam muito."] }, - { aluno: alunos[3], respostas: ["4", "Adequada", "Gostaria de mais exercícios de fixação antes das provas."] } + { aluno: alunos[0], respostas: [ "5", "Muito Fácil", "Projetos práticos são muito divertidos!" ] }, + { aluno: alunos[4], respostas: [ "5", "Adequada", "O professor tira todas as dúvidas e os projetos ajudam muito." ] }, + { aluno: alunos[3], respostas: [ "4", "Adequada", "Gostaria de mais exercícios de fixação antes das provas." ] } ] ) diff --git a/features/step_definitions/exportar_csv_steps.rb b/features/step_definitions/exportar_csv_steps.rb index 4687e68e13..6574601495 100644 --- a/features/step_definitions/exportar_csv_steps.rb +++ b/features/step_definitions/exportar_csv_steps.rb @@ -7,23 +7,23 @@ codigo: "DEP01", nome: "Departamento de Computação" ) - + @admin = Administrador.create!( matricula: "ADM001", nome: "Admin Teste", email: "admin@teste.com", departamento: @departamento ) - + # Reutiliza o step de login já existente nos steps de autenticação step 'que meu usuário está cadastrado com o email "admin@teste.com" e senha "senha123"' step 'eu tento realizar o login com o email "admin@teste.com" e a senha "senha123"' - - visit admin_resultados_path + + visit admin_resultados_path(@admin) end Dado("vejo os formulários enviados para todas as turmas do meu departamento") do - expect(page).to have_current_path(admin_resultados_path) + expect(page).to have_current_path(admin_resultados_path(@admin)) end Dado("existe a {string} de {string} que possui um formulário associado a ela") do |nome_turma, nome_disciplina| @@ -61,7 +61,7 @@ nome: "Ciência da Computação", departamento: @departamento ) - + @aluno = Discente.create!( matricula: "ALU001", nome: "Aluno Teste", @@ -69,33 +69,33 @@ curso: @curso_aluno, departamento: @departamento ) - + @resposta = RespostaForm.create!( formulario: @formulario, usuario: @aluno, data_submissao: Date.today ) - @template = Template.new(nome: "Template Padrão") + @template = Template.new(nome: "Template Padrão", administrador: @admin) elemento_base = @template.elementos.build(ordem: 1, enunciado: "Avaliação") elemento_base.campos.build(ordem: 1, enunciado: "Muito bom", tipo_elemento: "Múltipla Escolha") elemento_base.campos.build(ordem: 2, enunciado: "Excelente", tipo_elemento: "Múltipla Escolha") @template.save! - [@elemento1, @elemento2].each do |ef| + [ @elemento1, @elemento2 ].each do |ef| elemento_base.campos.each do |campo_base| CampoForm.find_or_create_by!(enunciado: campo_base.enunciado, elemento_form: ef) do |cf| cf.ordem = campo_base.ordem end end end - + { @elemento1 => "Muito bom", @elemento2 => "Excelente" }.each do |ef, texto| cf = ef.campo_forms.find_by!(enunciado: texto) - + RespostaElem.create!( texto_resposta: texto, resposta_form: @resposta, @@ -103,8 +103,8 @@ campo_form: cf ) end - - visit admin_resultados_path + + visit admin_resultados_path(@admin) end @@ -119,15 +119,15 @@ num_turma = @formulario.turma.numero_da_turma.parameterize(separator: '_') nome_materia = @formulario.turma.disciplina.nome.parameterize(separator: '_') nome_esperado = "formulario_#{@formulario.id}_turma_#{num_turma}_#{nome_materia}" - + content_disposition = page.response_headers["Content-Disposition"] - + expect(content_disposition).to be_present, "Esperava um header Content-Disposition indicando download, mas não havia nenhum." - + expect(content_disposition).to include("attachment"), "Esperava 'attachment' no Content-Disposition, mas foi: #{content_disposition}" - + expect(content_disposition).to include(nome_esperado), "Esperava '#{nome_esperado}' no nome do arquivo, " \ "mas o header foi: #{content_disposition}" @@ -172,9 +172,9 @@ Dado("que a {string} possui outro formulário") do |nome_turma| @turma_sad = Turma.find_by(numero_da_turma: nome_turma) || @turma - + @formulario_vazio = Formulario.create!(turma: @turma_sad) - + ElementoForm.create!( ordem: 1, enunciado: "Pergunta sem respostas", @@ -187,7 +187,7 @@ RespostaForm.where(formulario_id: @formulario_vazio.id).count ).to eq(0), "Esperava 0 respostas para o formulário vazio, mas havia algumas." - visit admin_resultados_path + visit admin_resultados_path(@admin) end Então("vejo a mensagem de erro {string}") do |mensagem_esperada| From d349ee8d4f3bbf34c44e5bbb939a6d4339f79f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Tue, 16 Jun 2026 16:01:12 -0300 Subject: [PATCH 43/55] hotfix dos crias 3: o retorno --- app/controllers/admin_controller.rb | 12 +++--- app/services/sigaa_importer.rb | 39 +++++++++++++++---- app/views/admin/sincronizar_sigaa.html.erb | 9 ++++- .../atualizar_dados_sigaa_steps.rb | 8 ++-- features/step_definitions/cadastro_steps.rb | 19 ++++++++- .../criar_formulario_template_steps.rb | 14 +++++++ .../importar_dados_sigaa_steps.rb | 8 ++-- spec/requests/sessions_spec.rb | 6 +-- 8 files changed, 87 insertions(+), 28 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 00a8fefe3e..ba71dd271f 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -61,19 +61,19 @@ def set_admin def processar_sincronizacao acao = params[:acao] - arquivo = params[:arquivo_sigaa] + arquivo_classes = params[:arquivo_classes] + arquivo_membros = params[:arquivo_membros] - unless arquivo.present? - redirect_to admin_gerenciamento_path, alert: "Por favor, selecione um arquivo" + unless arquivo_classes.present? && arquivo_membros.present? + redirect_to admin_gerenciamento_path, alert: "Por favor, selecione os dois arquivos JSON" return end - temp_file = arquivo.path resultado = case acao when "importar" - SigaaImporter.import_from_files(temp_file, temp_file) + SigaaImporter.import_from_files(arquivo_classes.path, arquivo_membros.path) when "atualizar" - SigaaImporter.update_from_files(temp_file, temp_file) + SigaaImporter.update_from_files(arquivo_classes.path, arquivo_membros.path) else "ação inválida" end diff --git a/app/services/sigaa_importer.rb b/app/services/sigaa_importer.rb index 65d5991dbd..9c6e73a1d9 100644 --- a/app/services/sigaa_importer.rb +++ b/app/services/sigaa_importer.rb @@ -39,7 +39,13 @@ def self.import_from_files(classes_path, members_path) # docente if m["docente"].is_a?(Hash) - dep = m["docente"]["departamento"].present? ? Departamento.find_or_create_by(nome: m["docente"]["departamento"]) : dep_padrao + dep_nome = m["docente"]["departamento"] + dep = if dep_nome.present? + dep_cod = dep_nome.parameterize(separator: "_").upcase.first(20) + Departamento.find_or_create_by(codigo: dep_cod) { |d| d.nome = dep_nome } + else + dep_padrao + end docente = Docente.find_or_create_by(email: m["docente"]["email"]) do |dct| dct.nome = m["docente"]["nome"] dct.matricula = m["docente"]["matricula"] || m["docente"]["usuario"] @@ -57,7 +63,13 @@ def self.import_from_files(classes_path, members_path) # discentes Array(m["dicente"]).each do |aluno| next unless aluno.is_a?(Hash) - curso = Curso.find_or_create_by(nome: aluno["curso"]) { |c| c.departamento = dep_padrao } if aluno["curso"] + curso = if aluno["curso"].present? + curso_cod = aluno["curso"].parameterize(separator: "_").upcase.first(30) + Curso.find_or_create_by(codigo: curso_cod) do |c| + c.nome = aluno["curso"] + c.departamento = dep_padrao + end + end discente = Discente.find_or_create_by(matricula: aluno["matricula"]) do |d| d.nome = aluno["nome"] d.email = aluno["email"] @@ -108,18 +120,29 @@ def self.update_from_files(classes_path, members_path) next unless turma if m["docente"].is_a?(Hash) - dep = Departamento.find_or_create_by(nome: m["docente"]["departamento"]) if m["docente"]["departamento"] + dep_nome = m["docente"]["departamento"] + dep = if dep_nome.present? + dep_cod = dep_nome.parameterize(separator: "_").upcase.first(20) + Departamento.find_or_create_by(codigo: dep_cod) { |d| d.nome = dep_nome } + end docente = Docente.find_by(email: m["docente"]["email"]) - docente.update(nome: m["docente"]["nome"], departamento: dep) if docente - docente.turmas << turma if docente && !docente.turmas.exists?(turma.id) + if docente + docente.update(nome: m["docente"]["nome"], departamento: dep || docente.departamento) + docente.turmas << turma unless docente.turmas.exists?(turma.id) + end end Array(m["dicente"]).each do |aluno| next unless aluno.is_a?(Hash) - curso = Curso.find_by(nome: aluno["curso"]) if aluno["curso"] + curso = if aluno["curso"].present? + curso_cod = aluno["curso"].parameterize(separator: "_").upcase.first(30) + Curso.find_by(codigo: curso_cod) || Curso.find_by(nome: aluno["curso"]) + end discente = Discente.find_by(matricula: aluno["matricula"]) - discente.update(nome: aluno["nome"], email: aluno["email"], curso: curso) if discente - discente.turmas << turma if discente && !discente.turmas.exists?(turma.id) + if discente + discente.update(nome: aluno["nome"], email: aluno["email"], curso: curso || discente.curso) + discente.turmas << turma unless discente.turmas.exists?(turma.id) + end end end end diff --git a/app/views/admin/sincronizar_sigaa.html.erb b/app/views/admin/sincronizar_sigaa.html.erb index 2b092b27da..2208979606 100644 --- a/app/views/admin/sincronizar_sigaa.html.erb +++ b/app/views/admin/sincronizar_sigaa.html.erb @@ -10,8 +10,13 @@
- <%= f.label :arquivo_sigaa, "Selecione o arquivo JSON:", style: "display: block; margin-bottom: 10px;" %> - <%= f.file_field :arquivo_sigaa, accept: "application/json", required: true %> + <%= f.label :arquivo_classes, "Arquivo de turmas (classes.json):", style: "display: block; margin-bottom: 10px;" %> + <%= f.file_field :arquivo_classes, accept: "application/json", required: true %> +
+ +
+ <%= f.label :arquivo_membros, "Arquivo de membros (class_members.json):", style: "display: block; margin-bottom: 10px;" %> + <%= f.file_field :arquivo_membros, accept: "application/json", required: true %>
diff --git a/features/step_definitions/atualizar_dados_sigaa_steps.rb b/features/step_definitions/atualizar_dados_sigaa_steps.rb index d0cd1d5a9d..19ede668f2 100644 --- a/features/step_definitions/atualizar_dados_sigaa_steps.rb +++ b/features/step_definitions/atualizar_dados_sigaa_steps.rb @@ -3,28 +3,28 @@ Dado('que os dados do SIGAA foram atualizados com sucesso') do allow(SigaaImporter).to receive(:update_from_files).and_return("atualização realizada com sucesso") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_classes: arquivo, arquivo_membros: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que eu tentei atualizar os dados do SIGAA mas ocorreu um erro') do allow(SigaaImporter).to receive(:update_from_files).and_return("falha") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_classes: arquivo, arquivo_membros: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que os dados do SIGAA já estão atualizados na base de dados do sistema') do allow(SigaaImporter).to receive(:update_from_files).and_return("os dados do SIGAA já estão atualizados e não serão atualizados novamente") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_classes: arquivo, arquivo_membros: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que alguns dados do SIGAA já estão atualizados na base de dados do sistema') do allow(SigaaImporter).to receive(:update_from_files).and_return("alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_classes: arquivo, arquivo_membros: arquivo }) visit admin_gerenciamento_path(@admin) end diff --git a/features/step_definitions/cadastro_steps.rb b/features/step_definitions/cadastro_steps.rb index 26995f2078..f227280a07 100644 --- a/features/step_definitions/cadastro_steps.rb +++ b/features/step_definitions/cadastro_steps.rb @@ -22,7 +22,24 @@ end Dado('que eu importei os dados do SIGAA com sucesso') do - # implementar a partir da feature de importar dados + dep = Departamento.find_or_create_by!(codigo: "NAO_ESP") { |d| d.nome = "Não especificado" } + curso = Curso.find_or_create_by!(codigo: "TST") do |c| + c.nome = "Curso Teste" + c.departamento = dep + end + Discente.find_or_create_by!(matricula: "USR001") do |u| + u.nome = "Usuário Teste" + u.email = "usuario@teste.com" + u.curso = curso + end +end + +Então('o e-mail de usuário {string} está cadastrado no sistema com senha indefinida') do |email| + usuario = Usuario.find_by(email: email) + expect(usuario).to be_present, + "Esperava encontrar um usuário com email '#{email}', mas não encontrei." + expect(usuario.senha_hash).to be_blank, + "Esperava que o usuário '#{email}' não tivesse senha definida, mas tinha." end Então('um email de definição de senha é enviado para o email {string}') do |email| diff --git a/features/step_definitions/criar_formulario_template_steps.rb b/features/step_definitions/criar_formulario_template_steps.rb index 2f3062c3ea..f5362a7b8a 100644 --- a/features/step_definitions/criar_formulario_template_steps.rb +++ b/features/step_definitions/criar_formulario_template_steps.rb @@ -95,6 +95,20 @@ # end end +Quando('eu seleciono as turmas {string} e {string}') do |turma1, turma2| + # TODO: Implementar seleção de múltiplas turmas + # [turma1, turma2].each do |turma_info| + # partes = turma_info.split(' - ') + # codigo = partes[0] + # nome_disciplina = partes[1] + # numero_turma = partes[2] + # + # disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # check "turma_ids_#{turma.id}" + # end +end + Quando('eu não seleciono nenhuma turma') do # TODO: Garantir que nenhuma turma está selecionada end diff --git a/features/step_definitions/importar_dados_sigaa_steps.rb b/features/step_definitions/importar_dados_sigaa_steps.rb index f2fa158a39..5c5d86b942 100644 --- a/features/step_definitions/importar_dados_sigaa_steps.rb +++ b/features/step_definitions/importar_dados_sigaa_steps.rb @@ -6,28 +6,28 @@ Dado('que os dados do SIGAA foram importados com sucesso') do allow(SigaaImporter).to receive(:import_from_files).and_return("importação realizada com sucesso") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_classes: arquivo, arquivo_membros: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que eu tentei importar os dados do SIGAA mas ocorreu um erro') do allow(SigaaImporter).to receive(:import_from_files).and_return("a importação falhou") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_classes: arquivo, arquivo_membros: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que os dados do SIGAA já existem na base de dados do sistema') do allow(SigaaImporter).to receive(:import_from_files).and_return("os dados já existem e não foram duplicados") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_classes: arquivo, arquivo_membros: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que alguns dados do SIGAA já existem na base de dados do sistema') do allow(SigaaImporter).to receive(:import_from_files).and_return("alguns dados já foram importados e não serão importados novamente") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_classes: arquivo, arquivo_membros: arquivo }) visit admin_gerenciamento_path(@admin) end diff --git a/spec/requests/sessions_spec.rb b/spec/requests/sessions_spec.rb index 8c1c98589e..c6d66e91b8 100644 --- a/spec/requests/sessions_spec.rb +++ b/spec/requests/sessions_spec.rb @@ -47,7 +47,7 @@ it "redireciona para a página do usuário" do get root_path - expect(response).to redirect_to(usuario_path(docente.id)) + expect(response).to redirect_to(inicio_path) end end end @@ -98,12 +98,12 @@ context "com credenciais válidas de usuário comum" do it "redireciona para a página do usuário" do post login_path, params: { login: docente.email, senha: "Senha123" } - expect(response).to redirect_to(usuario_path(docente.id)) + expect(response).to redirect_to(inicio_path) end it "aceita login pela matrícula" do post login_path, params: { login: docente.matricula, senha: "Senha123" } - expect(response).to redirect_to(usuario_path(docente.id)) + expect(response).to redirect_to(inicio_path) end end end From 12d743e86118536cc811ff082f5dbdc7df008cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Tue, 16 Jun 2026 17:39:08 -0300 Subject: [PATCH 44/55] migration --- db/schema.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index fb72ec4a1b..951f2871be 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_06_15_105458) do +ActiveRecord::Schema[8.1].define(version: 2026_06_16_201400) do create_table "campo_forms", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.datetime "created_at", null: false t.bigint "elemento_form_id", null: false @@ -73,6 +73,7 @@ t.string "enunciado" t.bigint "formulario_id", null: false t.integer "ordem" + t.string "tipo" t.datetime "updated_at", null: false t.index ["formulario_id"], name: "index_elemento_forms_on_formulario_id" end @@ -88,7 +89,8 @@ create_table "formularios", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.datetime "created_at", null: false - t.bigint "turma_id", null: false + t.string "titulo" + t.bigint "turma_id" t.datetime "updated_at", null: false t.index ["turma_id"], name: "index_formularios_on_turma_id" end From 7471623420d9238aab2817f91791cb0c86b0d234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Tue, 16 Jun 2026 17:51:48 -0300 Subject: [PATCH 45/55] feature/criar formulario --- app/controllers/admin_controller.rb | 52 ++++ app/models/formulario.rb | 2 +- app/views/admin/enviar_formularios.html.erb | 57 +++++ app/views/admin/gerenciamento.html.erb | 3 +- config/routes.rb | 2 + ..._to_formularios_and_make_turma_optional.rb | 6 + ...260616201400_add_tipo_to_elemento_forms.rb | 5 + .../criar_formulario_template_steps.rb | 229 ++++++++---------- 8 files changed, 232 insertions(+), 124 deletions(-) create mode 100644 app/views/admin/enviar_formularios.html.erb create mode 100644 db/migrate/20260616193744_add_titulo_to_formularios_and_make_turma_optional.rb create mode 100644 db/migrate/20260616201400_add_tipo_to_elemento_forms.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index ba71dd271f..95a0d7e368 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -11,6 +11,58 @@ def avaliacoes def gerenciamento end + def enviar_formularios + if request.get? + @templates = Template.where(usuario_id: @admin.id) + @turmas = Turma.joins(:disciplina).includes(:disciplina).order("disciplinas.nome, turmas.semestre") + elsif request.post? + template_id = params[:template_id] + turma_ids = params[:turma_ids] + + if template_id.blank? + flash[:alert] = "Selecione um template para criar o formulário" + redirect_to admin_enviar_formularios_path(@admin) and return + end + + if turma_ids.blank? + flash[:alert] = "Selecione pelo menos uma turma" + redirect_to admin_enviar_formularios_path(@admin) and return + end + + template = Template.includes(elementos: :campos).find(template_id) + turmas = Turma.where(id: turma_ids) + + turmas.each do |turma| + formulario = Formulario.create!( + turma: turma, + titulo: "#{turma.disciplina.nome} - #{turma.semestre}" + ) + + template.elementos.each_with_index do |elemento, _i| + tipo = elemento.campos.first&.tipo_elemento || "Texto" + ef = formulario.elemento_forms.create!( + enunciado: elemento.enunciado, + ordem: elemento.ordem, + tipo: tipo + ) + + next if tipo == "Texto" + + elemento.campos.each do |campo| + ef.campo_forms.create!( + enunciado: campo.enunciado, + ordem: campo.ordem + ) + end + end + end + + msg = turma_ids.size == 1 ? "Formulário criado com sucesso" : "Formulários criados com sucesso" + flash[:notice] = msg + redirect_to admin_gerenciamento_path(@admin) + end + end + def resultados @formularios = Formulario.joins(turma: :disciplina).where(disciplinas: { departamento_id: @admin.departamento_id }).includes(turma: :disciplina) end diff --git a/app/models/formulario.rb b/app/models/formulario.rb index 87565cbd88..c801a630f4 100644 --- a/app/models/formulario.rb +++ b/app/models/formulario.rb @@ -1,5 +1,5 @@ class Formulario < ApplicationRecord - belongs_to :turma + belongs_to :turma, optional: true has_many :elemento_forms, dependent: :destroy has_many :resposta_forms, dependent: :destroy end diff --git a/app/views/admin/enviar_formularios.html.erb b/app/views/admin/enviar_formularios.html.erb new file mode 100644 index 0000000000..28842e4758 --- /dev/null +++ b/app/views/admin/enviar_formularios.html.erb @@ -0,0 +1,57 @@ + diff --git a/app/views/admin/gerenciamento.html.erb b/app/views/admin/gerenciamento.html.erb index 442158e716..d107dde90a 100644 --- a/app/views/admin/gerenciamento.html.erb +++ b/app/views/admin/gerenciamento.html.erb @@ -5,7 +5,8 @@ <%= link_to "Importar / Atualizar dados do SIGAA", admin_sincronizar_sigaa_path(@admin), class: "btn-figma" %> - <%= link_to "Editar Template", admin_templates_path(@admin), class: "btn-figma" %> + <%= link_to "Editar Templates", admin_templates_path(@admin), class: "btn-figma" %> + <%= link_to "Enviar Formulários", admin_enviar_formularios_path(@admin), class: "btn-figma" %> <%= button_to "Resultados", admin_resultados_path(@admin), method: :get, class: "btn-figma" %>
diff --git a/config/routes.rb b/config/routes.rb index 2a329f9533..bb00054adc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,6 +38,8 @@ resources :templates get "sincronizar_sigaa", to: "admin#sincronizar_sigaa", as: :sincronizar_sigaa post "sincronizar_sigaa", to: "admin#sincronizar_sigaa" + get "enviar_formularios", to: "admin#enviar_formularios", as: :enviar_formularios + post "enviar_formularios", to: "admin#enviar_formularios" get "resultados", to: "admin#resultados", as: :resultados get "resultados/:id/download.csv", to: "admin#exportar_csv", as: :baixar_csv end diff --git a/db/migrate/20260616193744_add_titulo_to_formularios_and_make_turma_optional.rb b/db/migrate/20260616193744_add_titulo_to_formularios_and_make_turma_optional.rb new file mode 100644 index 0000000000..f7a355427b --- /dev/null +++ b/db/migrate/20260616193744_add_titulo_to_formularios_and_make_turma_optional.rb @@ -0,0 +1,6 @@ +class AddTituloToFormulariosAndMakeTurmaOptional < ActiveRecord::Migration[8.1] + def change + add_column :formularios, :titulo, :string unless column_exists?(:formularios, :titulo) + change_column_null :formularios, :turma_id, true + end +end diff --git a/db/migrate/20260616201400_add_tipo_to_elemento_forms.rb b/db/migrate/20260616201400_add_tipo_to_elemento_forms.rb new file mode 100644 index 0000000000..fbdf527578 --- /dev/null +++ b/db/migrate/20260616201400_add_tipo_to_elemento_forms.rb @@ -0,0 +1,5 @@ +class AddTipoToElementoForms < ActiveRecord::Migration[8.1] + def change + add_column :elemento_forms, :tipo, :string unless column_exists?(:elemento_forms, :tipo) + end +end diff --git a/features/step_definitions/criar_formulario_template_steps.rb b/features/step_definitions/criar_formulario_template_steps.rb index f5362a7b8a..deea017693 100644 --- a/features/step_definitions/criar_formulario_template_steps.rb +++ b/features/step_definitions/criar_formulario_template_steps.rb @@ -3,167 +3,152 @@ # Step definitions for: Criar formulário baseado em template Dado('que eu estou logado como administrador') do - # TODO: Implementar autenticação como administrador - # administrador = Administrador.create!( - # nome: "Admin", - # email: "admin@ufpe.br", - # matricula: "admin123", - # departamento: Departamento.first - # ) - # administrador.enviar_email_definicao_senha! - # visit login_path - # fill_in 'login', with: administrador.email - # fill_in 'senha', with: 'senha_temporaria' - # click_button 'Entrar' + depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') + + @admin = Administrador.find_or_create_by!(email: 'admin@unb.br') do |u| + u.senha_hash = '123456' + u.nome = 'Admin' + u.matricula = '123456789' + u.departamento = depto + end + + allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) + + allow_any_instance_of(AdminController).to receive(:set_admin) do |controller| + controller.instance_variable_set(:@admin, @admin) + end end Dado('que existe um template chamado {string} com as seguintes perguntas:') do |nome_template, table| - # table is a Cucumber::MultilineArgument::DataTable - # | Pergunta | Tipo | Opções | - # | Como você avalia o professor? | Múltipla Escolha | Ótimo, Bom, Regular, Ruim | - # | Qual seu nível de satisfação? | Escala | 1, 2, 3, 4, 5 | - # | Deixe seu comentário | Texto | | - # - # TODO: Implementar criação de template com elementos e campos - # @template = Template.create!(nome: nome_template) - # - # table.hashes.each do |row| - # elemento = @template.elementos.create!(enunciado: row['Pergunta'], ordem: @template.elementos.count + 1) - # - # case row['Tipo'] - # when 'Múltipla Escolha', 'Escala' - # row['Opções'].split(', ').each_with_index do |opcao, index| - # elemento.campos.create!(tipo_elemento: row['Tipo'], enunciado: opcao, ordem: index + 1) - # end - # when 'Texto' - # elemento.campos.create!(tipo_elemento: 'Texto', enunciado: '', ordem: 1) - # end - # end + @admin ||= Administrador.first + + @template = Template.new(nome: nome_template, administrador: @admin) + + table.hashes.each_with_index do |row, index| + elemento = @template.elementos.build(enunciado: row['Pergunta'], ordem: index + 1) + + tipo = row['Tipo'] + opcoes_str = row['Opções'] || '' + + if tipo == 'Texto' || opcoes_str.blank? + elemento.campos.build(tipo_elemento: 'Texto', ordem: 1) + else + opcoes = opcoes_str.split(',').map(&:strip) + opcoes.each_with_index do |opcao, opt_idx| + elemento.campos.build(tipo_elemento: tipo, enunciado: opcao, ordem: opt_idx + 1) + end + end + end + + @template.save! end Dado('que existem as seguintes turmas no semestre {string}:') do |semestre, table| - # table is a Cucumber::MultilineArgument::DataTable - # | Código | Disciplina | Turma | - # | TEC001 | Matemática | A | - # | TEC002 | Português | B | - # | TEC003 | História | A | - # - # TODO: Implementar criação de turmas - # table.hashes.each do |row| - # departamento = Departamento.find_or_create_by!(nome: 'Departamento Padrão', codigo: 'DEP01') - # disciplina = Disciplina.find_or_create_by!( - # codigo: row['Código'], - # nome: row['Disciplina'], - # departamento: departamento - # ) - # Turma.find_or_create_by!( - # disciplina: disciplina, - # numero_da_turma: row['Turma'], - # semestre: semestre, - # horario: 'Seg 08:00-10:00' - # ) - # end - # @turmas_disponiveis = Turma.where(semestre: semestre) + depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') + + table.hashes.each do |row| + disciplina = Disciplina.find_or_create_by!(codigo: row['Código']) do |d| + d.nome = row['Disciplina'] + d.departamento = depto + end + + Turma.find_or_create_by!( + disciplina: disciplina, + numero_da_turma: row['Turma'], + semestre: semestre + ) do |t| + t.horario = 'Seg 08:00-10:00' + end + end + + @turmas_disponiveis = Turma.where(semestre: semestre) end Quando('eu acesso a página de criação de formulário a partir de template') do - # TODO: Implementar rota para criação de formulário a partir de template - # visit new_formulario_from_template_path + visit admin_enviar_formularios_path(@admin) end Quando('eu seleciono o template {string}') do |nome_template| - # TODO: Implementar seleção de template na interface - # select nome_template, from: 'template_id' + select nome_template, from: 'template_id' end Quando('eu não seleciono nenhum template') do - # TODO: Garantir que nenhum template está selecionado + # Garante que o campo de template permanece em branco + select 'Template', from: 'template_id' end -Quando('eu seleciono as turmas {string}') do |turmas_texto| - # TODO: Implementar seleção de turmas - # Exemplo de turmas_texto: "TEC001 - Matemática - A" - # turmas_texto.split(' e ').each do |turma_info| - # partes = turma_info.split(' - ') - # codigo = partes[0] - # nome_disciplina = partes[1] - # numero_turma = partes[2] - # - # disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) - # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) - # check "turma_ids_#{turma.id}" - # end +Quando('eu seleciono as turmas {string}') do |turma_info| + partes = turma_info.split(' - ') + codigo = partes[0] + nome_disciplina = partes[1] + numero_turma = partes[2] + + disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) + turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + check "turma_ids_#{turma.id}" end -Quando('eu seleciono as turmas {string} e {string}') do |turma1, turma2| - # TODO: Implementar seleção de múltiplas turmas - # [turma1, turma2].each do |turma_info| - # partes = turma_info.split(' - ') - # codigo = partes[0] - # nome_disciplina = partes[1] - # numero_turma = partes[2] - # - # disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) - # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) - # check "turma_ids_#{turma.id}" - # end +Quando('eu seleciono as turmas {string} e {string}') do |turma1_info, turma2_info| + [turma1_info, turma2_info].each do |turma_info| + partes = turma_info.split(' - ') + codigo = partes[0] + nome_disciplina = partes[1] + numero_turma = partes[2] + + disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) + turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + check "turma_ids_#{turma.id}" + end end Quando('eu não seleciono nenhuma turma') do - # TODO: Garantir que nenhuma turma está selecionada + # Nenhum checkbox marcado — ação implícita end Então('o formulário deve conter as perguntas do template {string}') do |nome_template| - # TODO: Verificar se o formulário foi criado com os elementos copiados do template - # template = Template.find_by!(nome: nome_template) - # formulario = Formulario.last - # expect(formulario.elemento_forms.count).to eq(template.elementos.count) - # formulario.elemento_forms.each_with_index do |ef, i| - # expect(ef.enunciado).to eq(template.elementos[i].enunciado) - # end + template = Template.find_by!(nome: nome_template) + formulario = Formulario.last + expect(formulario.elemento_forms.count).to eq(template.elementos.count) + formulario.elemento_forms.order(:ordem).each_with_index do |ef, i| + expect(ef.enunciado).to eq(template.elementos.order(:ordem)[i].enunciado) + end end Então('o formulário deve estar associado à turma {string}') do |nome_turma_info| - # TODO: Verificar associação com a turma correta - # partes = nome_turma_info.split(' - ') - # nome_disciplina = partes[0] - # numero_turma = partes[1] - # disciplina = Disciplina.find_by!(nome: nome_disciplina) - # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) - # expect(Formulario.last.turma).to eq(turma) -end + partes = nome_turma_info.split(' - ') + nome_disciplina = partes[0] + numero_turma = partes[1] -Então('eu devo ver a mensagem {string}') do |mensagem| - expect(page).to have_content(mensagem) + disciplina = Disciplina.find_by!(nome: nome_disciplina) + turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + expect(Formulario.last.turma).to eq(turma) end Então('deve existir um formulário para a turma {string}') do |nome_turma_info| - # TODO: Verificar existência do formulário para a turma - # partes = nome_turma_info.split(' - ') - # nome_disciplina = partes[0] - # numero_turma = partes[1] - # disciplina = Disciplina.find_by!(nome: nome_disciplina) - # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) - # expect(Formulario.exists?(turma: turma)).to be true + partes = nome_turma_info.split(' - ') + nome_disciplina = partes[0] + numero_turma = partes[1] + + disciplina = Disciplina.find_by!(nome: nome_disciplina) + turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + expect(Formulario.exists?(turma: turma)).to be true end Então('cada formulário deve conter as perguntas do template {string}') do |nome_template| - # template = Template.find_by!(nome: nome_template) - # Formulario.all.each do |formulario| - # expect(formulario.elemento_forms.count).to eq(template.elementos.count) - # end + template = Template.find_by!(nome: nome_template) + Formulario.all.each do |formulario| + expect(formulario.elemento_forms.count).to eq(template.elementos.count) + end end Então('eu devo ver a lista de templates disponíveis') do - # TODO: Verificar se os templates são exibidos - # Template.all.each do |template| - # expect(page).to have_content(template.nome) - # end + Template.all.each do |template| + expect(page).to have_content(template.nome) + end end Então('eu devo ver a lista de turmas do semestre {string} disponíveis') do |semestre| - # TODO: Verificar se as turmas do semestre são exibidas - # Turma.where(semestre: semestre).each do |turma| - # expect(page).to have_content(turma.disciplina.nome) - # end + Turma.where(semestre: semestre).each do |turma| + expect(page).to have_content(turma.disciplina.nome) + end end From 37fdc1c133d598ae5badd9f46851d8c901d40633 Mon Sep 17 00:00:00 2001 From: gusfring41 Date: Tue, 16 Jun 2026 20:13:20 -0300 Subject: [PATCH 46/55] feat: rspec tests --- spec/models/campo_form_spec.rb | 5 -- spec/models/campo_spec.rb | 5 -- spec/models/curso_spec.rb | 5 -- spec/models/departamento_spec.rb | 5 -- spec/models/disciplina_spec.rb | 5 -- spec/models/elemento_form_spec.rb | 5 -- spec/models/elemento_spec.rb | 5 -- spec/models/formulario_spec.rb | 28 ++++++++++- spec/models/resposta_elem_spec.rb | 5 -- spec/models/resposta_form_spec.rb | 5 -- spec/models/turma_spec.rb | 5 -- spec/requests/formulario_spec.rb | 55 +++++++++++++++++++++ spec/requests/importacao_sigaa_spec.rb | 36 ++++++++++++++ spec/requests/senhas_spec.rb | 66 ++++++++++++++++++++++++++ spec/requests/templates_spec.rb | 65 +++++++++++++++++++++++++ 15 files changed, 248 insertions(+), 52 deletions(-) delete mode 100644 spec/models/campo_form_spec.rb delete mode 100644 spec/models/campo_spec.rb delete mode 100644 spec/models/curso_spec.rb delete mode 100644 spec/models/departamento_spec.rb delete mode 100644 spec/models/disciplina_spec.rb delete mode 100644 spec/models/elemento_form_spec.rb delete mode 100644 spec/models/elemento_spec.rb delete mode 100644 spec/models/resposta_elem_spec.rb delete mode 100644 spec/models/resposta_form_spec.rb delete mode 100644 spec/models/turma_spec.rb create mode 100644 spec/requests/formulario_spec.rb create mode 100644 spec/requests/importacao_sigaa_spec.rb create mode 100644 spec/requests/senhas_spec.rb create mode 100644 spec/requests/templates_spec.rb diff --git a/spec/models/campo_form_spec.rb b/spec/models/campo_form_spec.rb deleted file mode 100644 index 05d3574c3d..0000000000 --- a/spec/models/campo_form_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe CampoForm, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/campo_spec.rb b/spec/models/campo_spec.rb deleted file mode 100644 index 6618006be8..0000000000 --- a/spec/models/campo_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Campo, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/curso_spec.rb b/spec/models/curso_spec.rb deleted file mode 100644 index 4e29152a4a..0000000000 --- a/spec/models/curso_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Curso, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/departamento_spec.rb b/spec/models/departamento_spec.rb deleted file mode 100644 index 0a0d313f9c..0000000000 --- a/spec/models/departamento_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Departamento, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/disciplina_spec.rb b/spec/models/disciplina_spec.rb deleted file mode 100644 index 17de7443da..0000000000 --- a/spec/models/disciplina_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Disciplina, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/elemento_form_spec.rb b/spec/models/elemento_form_spec.rb deleted file mode 100644 index 2a8ad23d78..0000000000 --- a/spec/models/elemento_form_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe ElementoForm, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/elemento_spec.rb b/spec/models/elemento_spec.rb deleted file mode 100644 index fd36adff7a..0000000000 --- a/spec/models/elemento_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Elemento, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/formulario_spec.rb b/spec/models/formulario_spec.rb index 2318f88769..7ff3ac9799 100644 --- a/spec/models/formulario_spec.rb +++ b/spec/models/formulario_spec.rb @@ -1,5 +1,29 @@ require 'rails_helper' RSpec.describe Formulario, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + let(:disciplina) { Disciplina.find_or_create_by!(nome: "Engenharia de Software", codigo: "CIC0097", departamento: departamento) } + let(:turma) { Turma.find_or_create_by!(numero_da_turma: "TA", disciplina: disciplina, semestre: "2026.1") } + + context "validações de criação e relacionamentos" do + it "é válido quando associado a uma turma" do + formulario = Formulario.new(turma: turma) + expect(formulario).to be_valid + end + + it "não é válido sem estar vinculado a uma turma" do + formulario = Formulario.new(turma: nil) + expect(formulario).not_to be_valid + end + + it "possui relacionamento com elemento_forms" do + formulario = Formulario.new(turma: turma) + expect(formulario).to respond_to(:elemento_forms) + end + + it "possui relacionamento com resposta_forms" do + formulario = Formulario.new(turma: turma) + expect(formulario).to respond_to(:resposta_forms) + end + end +end \ No newline at end of file diff --git a/spec/models/resposta_elem_spec.rb b/spec/models/resposta_elem_spec.rb deleted file mode 100644 index f466723e9d..0000000000 --- a/spec/models/resposta_elem_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe RespostaElem, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/resposta_form_spec.rb b/spec/models/resposta_form_spec.rb deleted file mode 100644 index 16bb6683d4..0000000000 --- a/spec/models/resposta_form_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe RespostaForm, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/turma_spec.rb b/spec/models/turma_spec.rb deleted file mode 100644 index b7629b1e16..0000000000 --- a/spec/models/turma_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Turma, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/requests/formulario_spec.rb b/spec/requests/formulario_spec.rb new file mode 100644 index 0000000000..48c4ce7045 --- /dev/null +++ b/spec/requests/formulario_spec.rb @@ -0,0 +1,55 @@ +require 'rails_helper' + +RSpec.describe "Formularios", type: :request do + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + let(:disciplina) { Disciplina.find_or_create_by!(nome: "Engenharia de Software", codigo: "CIC0097", departamento: departamento) } + let(:turma) { Turma.find_or_create_by!(numero_da_turma: "TA", disciplina: disciplina, semestre: "2026.1") } + + let(:curso) { Curso.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC", departamento: departamento) } + + let(:admin) do + Administrador.create!( + nome: "Admin", matricula: "123", email: "admin@unb.br", + senha: "Senha123", senha_confirmation: "Senha123", departamento: departamento + ) + end + + let(:discente) do + Discente.create!( + nome: "Aluno Teste", matricula: "241000", email: "aluno@unb.br", + curso: curso, # 2. Recebendo a variável em vez da string! + senha: "Senha123", senha_confirmation: "Senha123" + ) + end + + describe "Feature 10: Criar formulário (Admin)" do + before { post login_path, params: { login: admin.email, senha: "Senha123" } } + + it "cria um formulário vinculando à turma" do + expect { + post formularios_path, params: { + formulario: { + turma_id: turma.id + } + } + }.to change(Formulario, :count).by(1) + + expect(response).to be_redirect + end + end + + describe "Feature 11: Visualizar formulários (Participante)" do + let!(:formulario) do + Formulario.create!(turma: turma) + end + + before do + post login_path, params: { login: discente.email, senha: "Senha123" } + end + + it "lista os formulários disponíveis para o aluno" do + get formularios_path + expect(response).to have_http_status(:ok) + end + end +end \ No newline at end of file diff --git a/spec/requests/importacao_sigaa_spec.rb b/spec/requests/importacao_sigaa_spec.rb new file mode 100644 index 0000000000..801e751a76 --- /dev/null +++ b/spec/requests/importacao_sigaa_spec.rb @@ -0,0 +1,36 @@ +require 'rails_helper' + +RSpec.describe "Importação SIGAA", type: :request do + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + let(:admin) do + Administrador.create!( + nome: "Admin", + matricula: "123", + email: "admin@unb.br", + senha: "Senha123", + senha_confirmation: "Senha123", + departamento: departamento + ) + end + + before do + post login_path, params: { login: admin.email, senha: "Senha123" } + end + + describe "POST /admin/:admin_id/sincronizar_sigaa" do + it "importa usuários do JSON com sucesso" do + # Vamos usar o seu class_members.json para simular os dois uploads que o controller exige + json_file = fixture_file_upload(Rails.root.join('class_members.json'), 'application/json') + + # Batendo na rota correta passando o admin_id e os 3 parâmetros que o processar_sincronizacao espera + post admin_sincronizar_sigaa_path(admin_id: admin.id), params: { + acao: "importar", + arquivo_classes: json_file, + arquivo_membros: json_file + } + + # O controller redireciona para a página de gerenciamento do admin, não importa o resultado + expect(response).to redirect_to(admin_gerenciamento_path(admin)) + end + end +end \ No newline at end of file diff --git a/spec/requests/senhas_spec.rb b/spec/requests/senhas_spec.rb new file mode 100644 index 0000000000..29fd178e05 --- /dev/null +++ b/spec/requests/senhas_spec.rb @@ -0,0 +1,66 @@ +require 'rails_helper' + +RSpec.describe "Gerenciamento de Senhas", type: :request do + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + let(:usuario_sem_senha) do + Docente.create!( + nome: "Novo Professor", + matricula: "doc002", + email: "novo@unb.br", + formacao: "Mestrado", + senha_hash: nil, + definicao_senha_token: "token_definicao_123" + ) + end + + let(:usuario_esquecido) do + Docente.create!( + nome: "Professor Esquecido", + matricula: "doc003", + email: "esquecido@unb.br", + formacao: "Doutorado", + senha: "SenhaAntiga123", + senha_confirmation: "SenhaAntiga123", + redefinicao_senha_token: "token_redefinicao_456" + ) + end + + describe "Feature 3: Cadastrar senha (Primeiro Acesso)" do + it "GET /definir_senha/:token acessa a tela de cadastro" do + get edit_definicao_senha_path(token: usuario_sem_senha.definicao_senha_token) + expect(response).to have_http_status(:ok) + end + + it "PATCH /definir_senha/:token define a senha e redireciona para login" do + patch definicao_senha_path(token: usuario_sem_senha.definicao_senha_token), params: { + senha: "NovaSenhaSegura123", + senha_confirmation: "NovaSenhaSegura123" + } + + usuario_sem_senha.reload + expect(usuario_sem_senha.senha_definida?).to be true + + expect(response).to redirect_to(root_path) + end + end + + describe "Feature 4: Redefinir senha" do + it "POST /redefinir_senha solicita a troca e envia email" do + post redefinir_senha_path, params: { email: usuario_esquecido.email } + usuario_esquecido.reload + + expect(usuario_esquecido.redefinicao_senha_token).not_to be_nil + + expect(response).to redirect_to(root_path) + end + + it "PATCH /redefinir_senha/:token salva a nova senha e redireciona" do + patch redefinicao_senha_path(token: usuario_esquecido.redefinicao_senha_token), params: { + senha: "SenhaTotalmenteNova1", + senha_confirmation: "SenhaTotalmenteNova1" + } + + expect(response).to redirect_to(root_path) + end + end +end \ No newline at end of file diff --git a/spec/requests/templates_spec.rb b/spec/requests/templates_spec.rb new file mode 100644 index 0000000000..b9f678b730 --- /dev/null +++ b/spec/requests/templates_spec.rb @@ -0,0 +1,65 @@ +require 'rails_helper' + +RSpec.describe "Templates", type: :request do + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + let(:admin) do + Administrador.create!( + nome: "Admin", + matricula: "123", + email: "admin@unb.br", + senha: "Senha123", + senha_confirmation: "Senha123", + departamento: departamento + ) + end + let!(:template_existente) do + template = Template.new(nome: "Template Base", administrador: admin) + template.elementos.build(enunciado: "Questão 1", ordem: 1) + template.save! + template + end + + before do + post login_path, params: { login: admin.email, senha: "Senha123" } + end + + describe "GET /templates" do + it "Feature 6: Visualiza a lista de templates" do + get admin_templates_path(admin_id: admin.id) + expect(response).to have_http_status(:ok) + end + end + + describe "POST /templates" do + it "Feature 5: Cria um template com sucesso" do + expect { + post admin_templates_path(admin_id: admin.id), params: { + template: { + nome: "Avaliação Nova", + administrador_id: admin.id, + elementos_attributes: [ { enunciado: "Questão 1", ordem: 1 } ] + } + } + }.to change(Template, :count).by(1) + expect(response).to be_redirect + end + end + + describe "PATCH /templates/:id" do + it "Feature 7: Edita um template existente" do + patch admin_template_path(admin_id: admin.id, id: template_existente.id), params: { + template: { nome: "Nome Atualizado" } + } + template_existente.reload + expect(template_existente.nome).to eq("Nome Atualizado") + end + end + + describe "DELETE /templates/:id" do + it "Feature 7: Deleta um template" do + expect { + delete admin_template_path(admin_id: admin.id, id: template_existente.id) + }.to change(Template, :count).by(-1) + end + end +end \ No newline at end of file From 0ed95bea27e8d9aee0288f36248606eff586e094 Mon Sep 17 00:00:00 2001 From: Liferoijrm Date: Tue, 16 Jun 2026 23:55:43 -0300 Subject: [PATCH 47/55] =?UTF-8?q?feat/redirecionamento=20de=20usu=C3=A1rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/sessions_controller.rb | 2 +- app/controllers/usuarios_controller.rb | 5 ++++- app/views/usuarios/avaliacoes.html.erb | 3 +++ config/routes.rb | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 app/views/usuarios/avaliacoes.html.erb diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index eab5513bc4..07fec64853 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -51,7 +51,7 @@ def redirect_para_pagina_do_usuario(usuario) if usuario.is_a?(Administrador) redirect_to admin_avaliacoes_path(usuario.id), notice: "Login realizado com sucesso." else - redirect_to inicio_path, notice: "Login realizado com sucesso." + redirect_to usuarios_avaliacoes_path(usuario.id), notice: "Login realizado com sucesso." end end end diff --git a/app/controllers/usuarios_controller.rb b/app/controllers/usuarios_controller.rb index 04a2368590..fe662b624c 100644 --- a/app/controllers/usuarios_controller.rb +++ b/app/controllers/usuarios_controller.rb @@ -1,8 +1,11 @@ class UsuariosController < ApplicationController before_action :require_login - before_action :require_admin + before_action :require_admin, except: [:avaliacoes] before_action :set_usuario, only: %i[ show edit update destroy ] + def avaliacoes + end + # GET /usuarios or /usuarios.json def index @usuarios = Usuario.all diff --git a/app/views/usuarios/avaliacoes.html.erb b/app/views/usuarios/avaliacoes.html.erb new file mode 100644 index 0000000000..fd3f3db2ab --- /dev/null +++ b/app/views/usuarios/avaliacoes.html.erb @@ -0,0 +1,3 @@ +
+

Teste

+
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bb00054adc..ddd90fbfc7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,6 +44,10 @@ get "resultados/:id/download.csv", to: "admin#exportar_csv", as: :baixar_csv end + scope "/usuarios/:usuario_id", as: "usuarios" do + get "avaliacoes", to: "usuarios#avaliacoes", as: :avaliacoes + end + post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa post "admin/atualizar_sigaa", to: "admin#atualizar_sigaa", as: :atualizar_sigaa From df18505c42d25c298d5e93db0ddbf15a68167396 Mon Sep 17 00:00:00 2001 From: Liferoijrm Date: Wed, 17 Jun 2026 00:21:36 -0300 Subject: [PATCH 48/55] =?UTF-8?q?feat/p=C3=A1gina=20de=20avaliacoes=20usu?= =?UTF-8?q?=C3=A1rio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/usuarios_controller.rb | 14 +++++ app/views/usuarios/avaliacoes.html.erb | 74 +++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/app/controllers/usuarios_controller.rb b/app/controllers/usuarios_controller.rb index fe662b624c..3f28952689 100644 --- a/app/controllers/usuarios_controller.rb +++ b/app/controllers/usuarios_controller.rb @@ -4,6 +4,20 @@ class UsuariosController < ApplicationController before_action :set_usuario, only: %i[ show edit update destroy ] def avaliacoes + @usuario = Usuario.find(params[:usuario_id]) + + if @usuario.is_a?(Docente) + @turmas = @usuario.turmas + elsif @usuario.is_a?(Discente) + @turmas = @usuario.turmas + else + @turmas = Turma.none + end + + @avaliacoes = Formulario + .joins(:turma) + .where(turma: @turmas) + .includes(turma: { disciplina: :departamento, docentes: [] }) end # GET /usuarios or /usuarios.json diff --git a/app/views/usuarios/avaliacoes.html.erb b/app/views/usuarios/avaliacoes.html.erb index fd3f3db2ab..3f5ce291e4 100644 --- a/app/views/usuarios/avaliacoes.html.erb +++ b/app/views/usuarios/avaliacoes.html.erb @@ -1,3 +1,73 @@ -
-

Teste

+<%# app/views/usuarios/avaliacoes.html.erb %> + +
+ + <%# ── Header ── %> +
+ +
+

Avaliações

+
+ +
+
+ +
+ +
+
+ U +
+ +
+
+ +
+ + <%# ── Conteúdo ── %> +
+ + <% if @avaliacoes.present? %> +
+ + <% @avaliacoes.each do |formulario| %> + <% turma = formulario.turma %> + <% disciplina = turma.disciplina %> + <% professor = turma.docentes.first %> + + <%= link_to formulario_path(formulario), + style: "width: 278px; background: #FFFFFF; border-radius: 8px; padding: 24px; display: flex; flex-direction: column; justify-content: space-between; min-height: 130px; text-decoration: none; color: inherit; box-sizing: border-box;" do %> + +
+

+ <%= disciplina.nome %> +

+

+ <%= turma.semestre %><%= " — #{turma.horario}" if turma.horario.present? %> +

+
+ +
+

+ <%= professor&.nome || "Professor(a) não alocado(a)" %> +

+
+ + <% end %> + <% end %> + +
+ <% else %> +
+

Nenhuma avaliação disponível para você no momento.

+
+ <% end %> + +
+
\ No newline at end of file From 4c566e0d0dea734b8d550b5684744065c42bc155 Mon Sep 17 00:00:00 2001 From: leitaonerd Date: Tue, 16 Jun 2026 20:52:06 -0300 Subject: [PATCH 49/55] fix/login steps arrumei a rota --- features/step_definitions/login_steps.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index 7cdcae1677..f82ef852aa 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -67,5 +67,5 @@ end Então('sou direcionado para a página inicial') do - expect(page).to have_current_path(inicio_path) + expect(page).to have_current_path(/\/(admin\/\d+|usuarios\/\d+)\/avaliacoes/) end From 1bc6ae342b4a08caf69f87b8b9833c458ba0eb56 Mon Sep 17 00:00:00 2001 From: neatzzy Date: Tue, 16 Jun 2026 21:01:49 -0300 Subject: [PATCH 50/55] :sparkles: feat: RESPONDER O FORMULARIO FUNCIONA --- app/controllers/usuarios_controller.rb | 57 +++++++++- app/views/usuarios/avaliacoes.html.erb | 2 +- .../usuarios/responder_formulario.html.erb | 105 ++++++++++++++++++ config/database.yml | 2 +- config/routes.rb | 2 + db/seeds.rb | 21 +++- .../criar_formulario_template_steps.rb | 2 +- 7 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 app/views/usuarios/responder_formulario.html.erb diff --git a/app/controllers/usuarios_controller.rb b/app/controllers/usuarios_controller.rb index 3f28952689..14e8d24070 100644 --- a/app/controllers/usuarios_controller.rb +++ b/app/controllers/usuarios_controller.rb @@ -1,6 +1,6 @@ class UsuariosController < ApplicationController before_action :require_login - before_action :require_admin, except: [:avaliacoes] + before_action :require_admin, except: [ :avaliacoes, :responder_formulario, :submeter_resposta ] before_action :set_usuario, only: %i[ show edit update destroy ] def avaliacoes @@ -20,6 +20,61 @@ def avaliacoes .includes(turma: { disciplina: :departamento, docentes: [] }) end + def responder_formulario + @usuario = Usuario.find(params[:usuario_id]) + @formulario = Formulario.includes(elemento_forms: :campo_forms).find(params[:formulario_id]) + + if RespostaForm.exists?(formulario: @formulario, usuario: current_user) + redirect_to usuarios_avaliacoes_path(@usuario), notice: "Você já respondeu este formulário." + end + end + + def submeter_resposta + @usuario = Usuario.find(params[:usuario_id]) + @formulario = Formulario.includes(elemento_forms: :campo_forms).find(params[:formulario_id]) + + if RespostaForm.exists?(formulario: @formulario, usuario: current_user) + redirect_to usuarios_avaliacoes_path(@usuario), alert: "Você já respondeu este formulário." and return + end + + resposta_form = RespostaForm.new( + formulario: @formulario, + usuario: current_user, + data_submissao: Date.today + ) + + ActiveRecord::Base.transaction do + resposta_form.save! + + @formulario.elemento_forms.order(:ordem).each do |ef| + resposta_val = params.dig(:respostas, ef.id.to_s) + next if resposta_val.blank? + + if ef.tipo == "Texto" + resposta_form.resposta_elems.create!( + elemento_form: ef, + texto_resposta: resposta_val + ) + else + campo = ef.campo_forms.find_by(id: resposta_val) + next unless campo + + resposta_form.resposta_elems.create!( + elemento_form: ef, + campo_form: campo, + texto_resposta: campo.enunciado + ) + end + end + end + + redirect_to usuarios_avaliacoes_path(@usuario), notice: "Respostas enviadas com sucesso!" + rescue ActiveRecord::RecordInvalid => e + @formulario = Formulario.includes(elemento_forms: :campo_forms).find(params[:formulario_id]) + flash.now[:alert] = "Erro ao salvar respostas: #{e.message}" + render :responder_formulario, status: :unprocessable_content + end + # GET /usuarios or /usuarios.json def index @usuarios = Usuario.all diff --git a/app/views/usuarios/avaliacoes.html.erb b/app/views/usuarios/avaliacoes.html.erb index 3f5ce291e4..9884d7e7df 100644 --- a/app/views/usuarios/avaliacoes.html.erb +++ b/app/views/usuarios/avaliacoes.html.erb @@ -40,7 +40,7 @@ <% disciplina = turma.disciplina %> <% professor = turma.docentes.first %> - <%= link_to formulario_path(formulario), + <%= link_to usuarios_responder_formulario_path(@usuario, formulario), style: "width: 278px; background: #FFFFFF; border-radius: 8px; padding: 24px; display: flex; flex-direction: column; justify-content: space-between; min-height: 130px; text-decoration: none; color: inherit; box-sizing: border-box;" do %>
diff --git a/app/views/usuarios/responder_formulario.html.erb b/app/views/usuarios/responder_formulario.html.erb new file mode 100644 index 0000000000..87504c7444 --- /dev/null +++ b/app/views/usuarios/responder_formulario.html.erb @@ -0,0 +1,105 @@ +<%# app/views/usuarios/responder_formulario.html.erb %> + +<% + titulo_header = if @formulario.titulo.present? + "Avaliação - #{@formulario.titulo}" + elsif @formulario.turma + partes = [@formulario.turma.disciplina&.nome, @formulario.turma.semestre].compact + partes.any? ? "Avaliação - #{partes.join(' - ')}" : "Avaliação" + else + "Avaliação" + end +%> + +
+ + <%# ── Header ── %> +
+ +
+ <%= link_to usuarios_avaliacoes_path(@usuario), + style: "display: flex; align-items: center; color: #000000; text-decoration: none; font-size: 22px; line-height: 1;" do %> + ☰ + <% end %> +

+ <%= titulo_header %> +

+
+ +
+ U +
+ +
+ + <%# ── Conteúdo ── %> +
+ + <% if flash[:alert] %> +
+ <%= flash[:alert] %> +
+ <% end %> + + <%= form_with url: usuarios_submeter_resposta_path(@usuario, @formulario), + method: :post, + id: "formulario-resposta", + style: "display: flex; flex-direction: column; gap: 16px;" do |f| %> + + <% if @formulario.elemento_forms.empty? %> +
+

Este formulário não possui perguntas.

+
+ <% end %> + + <% @formulario.elemento_forms.order(:ordem).each do |ef| %> +
+ +

+ <%= ef.enunciado %> +

+ + <% if ef.tipo == "Texto" %> + + + <% else %> +
+ <% ef.campo_forms.order(:ordem).each do |campo| %> + + <% end %> +
+ <% end %> + +
+ <% end %> + + <% end %> + +
+ + <% if @formulario.elemento_forms.any? %> + + <% end %> + +
diff --git a/config/database.yml b/config/database.yml index 5de2017194..6ad5ddcb9d 100644 --- a/config/database.yml +++ b/config/database.yml @@ -14,7 +14,7 @@ default: &default encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root - password: + password: root host: 127.0.0.1 development: diff --git a/config/routes.rb b/config/routes.rb index ddd90fbfc7..39de81fc5e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,6 +46,8 @@ scope "/usuarios/:usuario_id", as: "usuarios" do get "avaliacoes", to: "usuarios#avaliacoes", as: :avaliacoes + get "formularios/:formulario_id/responder", to: "usuarios#responder_formulario", as: :responder_formulario + post "formularios/:formulario_id/responder", to: "usuarios#submeter_resposta", as: :submeter_resposta end post "admin/importar_sigaa", to: "admin#importar_sigaa", as: :importar_sigaa diff --git a/db/seeds.rb b/db/seeds.rb index 0d9e3e34e9..9b33b22940 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -69,6 +69,15 @@ docente_2.formacao = "doutorado" docente_2.save! +docente_3 = Docente.find_or_initialize_by(email: "docente3@teste.com") +docente_3.nome ||= "Zequinha Banana" +docente_3.matricula ||= "241000069" +docente_3.senha = "teste123" +docente_3.senha_confirmation = "teste123" +docente_3.departamento = dept_cic +docente_3.formacao = "doutorado" +docente_3.save! + # Admin admin = Administrador.find_or_initialize_by(email: "admin@teste.com") admin.nome ||= "Admin Teste" @@ -114,6 +123,7 @@ docente_1.turmas << turma_ed_a unless docente_1.turmas.include?(turma_ed_a) docente_1.turmas << turma_ed_b unless docente_1.turmas.include?(turma_ed_b) docente_2.turmas << turma_isc_a unless docente_2.turmas.include?(turma_isc_a) +docente_3.turmas << turma_ed_a unless docente_3.turmas.include?(turma_ed_a) # Distribuindo alunos nas turmas para gerar variação de dados # Turma ED A: Alunos 1, 2 e 3 @@ -179,16 +189,21 @@ def configurar_formulario_e_respostas(turma, template_base, dados_alunos) # 1. Clona todos os elementos e TODOS os seus respectivos campos para o formulário template_base.elementos.order(:ordem).each do |elemento_base| + tipo_do_elemento = elemento_base.campos.first&.tipo_elemento || "Múltipla Escolha" + ef = ElementoForm.find_or_create_by!(enunciado: elemento_base.enunciado, formulario: formulario) do |e| e.ordem = elemento_base.ordem + e.tipo = tipo_do_elemento end - # Cria TODOS os campos (opções) atrelados a este elemento + ef.update!(tipo: tipo_do_elemento) if ef.tipo.nil? + + next if tipo_do_elemento == "Texto" + + # Cria os campos (opções) apenas para elementos de múltipla escolha elemento_base.campos.order(:ordem).each do |campo_base| CampoForm.find_or_create_by!(enunciado: campo_base.enunciado, elemento_form: ef) do |c| c.ordem = campo_base.ordem - # A linha abaixo foi removida pois CampoForm não possui a coluna tipo_elemento - # c.tipo_elemento = campo_base.tipo_elemento end end end diff --git a/features/step_definitions/criar_formulario_template_steps.rb b/features/step_definitions/criar_formulario_template_steps.rb index deea017693..0b17e38d9e 100644 --- a/features/step_definitions/criar_formulario_template_steps.rb +++ b/features/step_definitions/criar_formulario_template_steps.rb @@ -89,7 +89,7 @@ end Quando('eu seleciono as turmas {string} e {string}') do |turma1_info, turma2_info| - [turma1_info, turma2_info].each do |turma_info| + [ turma1_info, turma2_info ].each do |turma_info| partes = turma_info.split(' - ') codigo = partes[0] nome_disciplina = partes[1] From 3c4e3aab178e98f36f2e10bb4838ab9eacccca44 Mon Sep 17 00:00:00 2001 From: leitaonerd Date: Tue, 16 Jun 2026 22:02:13 -0300 Subject: [PATCH 51/55] fix/formulario tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5 erros no cucumber Failing Scenarios: cucumber features/redefinicao_senha.feature:12 # Cenário: Solicitar redefinição de senha com sucesso (happy path) cucumber features/redefinicao_senha.feature:39 # Cenário: Solicitar redefinição para email não cadastrado (sad path) cucumber features/redefinicao_senha.feature:46 # Cenário: Solicitar redefinição sem informar email (sad path) cucumber features/responder_formulario.feature:13 # Cenário: Resposta completa ao formulário com sucesso (Happy Path) cucumber features/responder_formulario.feature:22 # Cenário: Tentativa de envio com perguntas obrigatórias em branco (Sad Path) --- features/criar_formulario.feature | 25 ++-- features/responder_formulario.feature | 23 ++-- .../criar_formulario_steps.rb | 102 ++++++++++++---- .../criar_formulario_template_steps.rb | 4 + .../responder_formulario_steps.rb | 112 ++++++++++++++---- 5 files changed, 201 insertions(+), 65 deletions(-) diff --git a/features/criar_formulario.feature b/features/criar_formulario.feature index 7ebcad2ffd..3beb886b65 100644 --- a/features/criar_formulario.feature +++ b/features/criar_formulario.feature @@ -10,14 +10,21 @@ Funcionalidade: Criar formulário de avaliação E eu estou na página de criação de formulários Cenário: Criação de formulário com sucesso (Happy Path) - Quando eu preencho o título com "Avaliação de Turma 2026.1" - E eu adiciono uma pergunta do tipo "Múltipla Escolha" com o texto "Como você avalia o professor?" - E eu clico em "Salvar Formulário" + Quando eu escolho um template para o formulário + E escolho uma turma para enviar o formulário + E envio o formulário Então eu devo ver a mensagem "Formulário criado com sucesso" - E eu devo ver o formulário "Avaliação de Turma 2026.1" na lista de formulários + E o formulário deve estar disponível para os alunos da turma selecionada + + Cenário: Tentativa de criação sem template (Sad Path) + Quando eu não escolho um template para o formulário + E escolho uma turma para enviar o formulário + E envio o formulário + Então eu devo ver a mensagem "Selecione um template para criar o formulário" + + Cenário: Tentativa de criação sem turma (Sad Path) + Quando eu não escolho uma turma para enviar o formulário + E escolho um template para o formulário + E envio o formulário + Então eu devo ver a mensagem "Selecione pelo menos uma turma" - Cenário: Tentativa de criação sem título (Sad Path) - Quando eu deixo o título em branco - E eu adiciono uma pergunta do tipo "Texto" com o texto "Quais suas sugestões?" - E eu clico em "Salvar Formulário" - Então eu devo ver a mensagem "Título não pode ficar em branco" diff --git a/features/responder_formulario.feature b/features/responder_formulario.feature index 1b15384111..5a4e6ef00b 100644 --- a/features/responder_formulario.feature +++ b/features/responder_formulario.feature @@ -1,25 +1,26 @@ # language: pt Funcionalidade: Visualizar e responder formulário de avaliação - Como um aluno + Como um discente Quero poder visualizar e responder a um formulário de avaliação Para dar feedback sobre a turma ou disciplina Contexto: - Dado que eu estou logado como aluno - E existe um formulário ativo chamado "Avaliação de Turma 2026.1" + Dado que eu estou logado como discente + E existe um formulário ativo para minha turma E eu estou na página de formulários disponíveis Cenário: Resposta completa ao formulário com sucesso (Happy Path) - Quando eu clico para responder o formulário "Avaliação de Turma 2026.1" + Quando eu clico para responder o formulário Então eu devo visualizar os detalhes e perguntas pertinentes a ele - Quando eu respondo a pergunta "Como você avalia o professor?" com a opção "Ótimo" - E eu clico no botão "Enviar Avaliação" - Então eu devo ver a mensagem "Avaliação enviada com sucesso" - E o formulário "Avaliação de Turma 2026.1" não deve mais aparecer na minha lista de pendentes + Quando eu respondo todos os campos do formulário + E eu envio o fomulário + Então eu devo ver a mensagem "Respostas enviadas com sucesso!" + E a resposta deve ser registrada no sistema + E eu não devo mais ser capaz de responder ao mesmo formulário Cenário: Tentativa de envio com perguntas obrigatórias em branco (Sad Path) - Quando eu clico para responder o formulário "Avaliação de Turma 2026.1" - E eu deixo a pergunta obrigatória "Como você avalia o professor?" em branco - E eu clico no botão "Enviar Avaliação" + Quando eu clico para responder o formulário + E eu deixo uma pergunta obrigatória em branco + E eu envio o formulário Então eu devo ver a mensagem "Por favor, responda todas as perguntas obrigatórias" diff --git a/features/step_definitions/criar_formulario_steps.rb b/features/step_definitions/criar_formulario_steps.rb index 4df517218c..35e4bb831a 100644 --- a/features/step_definitions/criar_formulario_steps.rb +++ b/features/step_definitions/criar_formulario_steps.rb @@ -1,39 +1,99 @@ +# frozen_string_literal: true + Dado('que eu estou logado como professor') do - # Implementar quando definir models e autenticação - # visit '/login' - # fill_in 'Email', with: 'professor@ufpe.br' - # fill_in 'Senha', with: 'senha123' - # click_button 'Entrar' + departamento = Departamento.find_or_create_by!(nome: 'Departamento de Teste', codigo: 'TST') + + @admin = Administrador.find_or_create_by!(email: 'professor@teste.com') do |a| + a.nome = 'Professor Teste' + a.matricula = 'prof001' + a.senha = 'Senha123' + a.senha_confirmation = 'Senha123' + a.departamento = departamento + end + + allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) + allow_any_instance_of(AdminController).to receive(:set_admin) do |controller| + controller.instance_variable_set(:@admin, @admin) + end end Dado('eu estou na página de criação de formulários') do - visit '/forms/new' + departamento = Departamento.find_or_create_by!(nome: 'Departamento de Teste', codigo: 'TST') + + disciplina = Disciplina.find_or_create_by!(codigo: 'CIC0001') do |d| + d.nome = 'Engenharia de Software' + d.departamento = departamento + end + + @turma = Turma.find_or_create_by!( + disciplina: disciplina, + numero_da_turma: '01', + semestre: '2026.1' + ) do |t| + t.horario = '235M12' + end + + @template = Template.find_or_create_by!(nome: 'Avaliação Padrão', usuario_id: @admin.id) do |t| + elemento = t.elementos.build(enunciado: 'Como você avalia o professor?', ordem: 1) + elemento.campos.build( + tipo_elemento: 'Múltipla Escolha', + enunciado: 'Ótimo', + ordem: 1 + ) + elemento.campos.build( + tipo_elemento: 'Múltipla Escolha', + enunciado: 'Bom', + ordem: 2 + ) + elemento.campos.build( + tipo_elemento: 'Múltipla Escolha', + enunciado: 'Regular', + ordem: 3 + ) + elemento.campos.build( + tipo_elemento: 'Múltipla Escolha', + enunciado: 'Ruim', + ordem: 4 + ) + end + + visit admin_enviar_formularios_path(@admin) end -Quando('eu preencho o título com {string}') do |titulo| - fill_in 'Título do Formulário', with: titulo +Quando('eu escolho um template para o formulário') do + select @template.nome, from: 'template_id' end -Quando('eu deixo o título em branco') do - fill_in 'Título do Formulário', with: '' +Quando('escolho um template para o formulário') do + select @template.nome, from: 'template_id' end -Quando('eu adiciono uma pergunta do tipo {string} com o texto {string}') do |tipo, texto| - # Ajustar a interação com os botões/selects dinâmicos na tela quando desenvolvidos - select tipo, from: 'Tipo de Pergunta' - fill_in 'Texto da Pergunta', with: texto - click_button 'Adicionar Pergunta' +Quando('escolho uma turma para enviar o formulário') do + check "turma_ids_#{@turma.id}" end -Quando('eu clico em {string}') do |nome_botao| - visit root_path unless page.has_button?(nome_botao) - click_button nome_botao +Quando('envio o formulário') do + click_button 'Criar Formulário' +end + +Quando('eu não escolho um template para o formulário') do + # deliberately do nothing - leave template select at default blank option +end + +Quando('eu não escolho uma turma para enviar o formulário') do + # deliberately do nothing - leave no turma checkboxes checked end Então('eu devo ver a mensagem {string}') do |mensagem| expect(page).to have_content(mensagem) end -Então('eu devo ver o formulário {string} na lista de formulários') do |nome_formulario| - expect(page).to have_content(nome_formulario) -end +Então('o formulário deve estar disponível para os alunos da turma selecionada') do + formulario = Formulario.find_by(turma: @turma) + expect(formulario).to be_present + expect(formulario.titulo).to eq("#{@turma.disciplina.nome} - #{@turma.semestre}") + + elemento_forms_count = formulario.elemento_forms.count + template_elementos_count = @template.elementos.count + expect(elemento_forms_count).to eq(template_elementos_count) +end \ No newline at end of file diff --git a/features/step_definitions/criar_formulario_template_steps.rb b/features/step_definitions/criar_formulario_template_steps.rb index 0b17e38d9e..1d272a0e30 100644 --- a/features/step_definitions/criar_formulario_template_steps.rb +++ b/features/step_definitions/criar_formulario_template_steps.rb @@ -101,6 +101,10 @@ end end +Quando('eu clico em {string}') do |botao| + click_button botao +end + Quando('eu não seleciono nenhuma turma') do # Nenhum checkbox marcado — ação implícita end diff --git a/features/step_definitions/responder_formulario_steps.rb b/features/step_definitions/responder_formulario_steps.rb index eebcbd09dd..684ac12e59 100644 --- a/features/step_definitions/responder_formulario_steps.rb +++ b/features/step_definitions/responder_formulario_steps.rb @@ -1,43 +1,107 @@ -Dado('que eu estou logado como aluno') do - # Implementar quando definir models e autenticação - # visit '/login' - # fill_in 'Email', with: 'aluno@ufpe.br' - # fill_in 'Senha', with: 'senha123' - # click_button 'Entrar' +Dado('que eu estou logado como discente') do + depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') + curso = Curso.find_or_create_by!(codigo: 'TST') do |c| + c.nome = 'Curso Teste' + c.departamento = depto + end + + @discente = Discente.find_or_create_by!(matricula: '2024001') do |u| + u.nome = 'Discente Teste' + u.email = 'discente@teste.com' + u.senha = 'Senha123' + u.senha_confirmation = 'Senha123' + u.curso = curso + end + + allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@discente) end -Dado('existe um formulário ativo chamado {string}') do |nome_formulario| - # Implementar a criação desse registro (Form/Evaluation) no banco usando Factory/ActiveRecord +Dado('existe um formulário ativo para minha turma') do + depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') + disciplina = Disciplina.find_or_create_by!(codigo: 'CIC0001') do |d| + d.nome = 'Engenharia de Software' + d.departamento = depto + end + + turma = Turma.find_or_create_by!( + disciplina: disciplina, + numero_da_turma: '01', + semestre: '2026.1' + ) do |t| + t.horario = '235M12' + end + + @discente.turmas << turma unless @discente.turmas.include?(turma) + + @formulario = Formulario.find_or_create_by!(turma: turma) do |f| + f.titulo = 'Avaliação de Turma 2026.1' + end + + elemento = @formulario.elemento_forms.find_or_create_by!(ordem: 1) do |ef| + ef.enunciado = 'Como você avalia o professor?' + ef.tipo = 'Múltipla Escolha' + end + + elemento.campo_forms.find_or_create_by!(ordem: 1) { |c| c.enunciado = 'Ótimo' } + elemento.campo_forms.find_or_create_by!(ordem: 2) { |c| c.enunciado = 'Bom' } + elemento.campo_forms.find_or_create_by!(ordem: 3) { |c| c.enunciado = 'Regular' } + elemento.campo_forms.find_or_create_by!(ordem: 4) { |c| c.enunciado = 'Ruim' } + + elemento2 = @formulario.elemento_forms.find_or_create_by!(ordem: 2) do |ef| + ef.enunciado = 'Comente sobre a didática' + ef.tipo = 'Texto' + end + + elemento2.campo_forms.find_or_create_by!(ordem: 1) end Dado('eu estou na página de formulários disponíveis') do - visit '/forms/pending' + visit usuarios_avaliacoes_path(@discente) end -Quando('eu clico para responder o formulário {string}') do |nome_formulario| - # Ajustar seletor dependendo da interface, por exemplo, achar o escopo do texto ou tr - click_link "Responder" +Quando('eu clico para responder o formulário') do + click_link @formulario.turma.disciplina.nome end Então('eu devo visualizar os detalhes e perguntas pertinentes a ele') do - # Assumindo que a classe .form-question existirá na view - expect(page).to have_selector('.form-question') + @formulario.elemento_forms.each do |ef| + expect(page).to have_content(ef.enunciado) + end +end + +Quando('eu respondo todos os campos do formulário') do + @formulario.elemento_forms.order(:ordem).each do |ef| + if ef.tipo == 'Texto' + fill_in "respostas[#{ef.id}]", with: 'Uma resposta qualquer' + else + primeiro_campo = ef.campo_forms.order(:ordem).first + choose "respostas[#{ef.id}]_#{primeiro_campo.id}" + end + end end -Quando('eu respondo a pergunta {string} com a opção {string}') do |pergunta, opcao| - # Ajustar conformidade de input visual (radio, select, text) - choose opcao +Quando('eu envio o fomulário') do + click_button type: 'submit' end -Quando('eu deixo a pergunta obrigatória {string} em branco') do |pergunta| - # O comportamento de deixar em branco pode ser simplesmente não preencher, logo, nenhum click extra. +Quando('eu envio o formulário') do + click_button type: 'submit' end -Quando('eu clico no botão {string}') do |nome_botao| - click_button nome_botao +#Então('eu devo ver a mensagem {string}') do |mensagem| +# expect(page).to have_content(mensagem) +#end + +Então('a resposta deve ser registrada no sistema') do + expect(RespostaForm.exists?(formulario: @formulario, usuario: @discente)).to be true end -Então('o formulário {string} não deve mais aparecer na minha lista de pendentes') do |nome_formulario| - visit '/forms/pending' - expect(page).not_to have_content(nome_formulario) +Então('eu não devo mais ser capaz de responder ao mesmo formulário') do + expect(page).to have_current_path(usuarios_avaliacoes_path(@discente)) + expect(page).not_to have_content(@formulario.turma.disciplina.nome) end + +Quando('eu deixo uma pergunta obrigatória em branco') do + campo_texto = @formulario.elemento_forms.find_by(tipo: 'Texto') + fill_in "respostas[#{campo_texto.id}]", with: '' +end \ No newline at end of file From 9f00ab28b7dc49de0688af78d8ec00c087515735 Mon Sep 17 00:00:00 2001 From: neatzzy Date: Tue, 16 Jun 2026 22:11:51 -0300 Subject: [PATCH 52/55] =?UTF-8?q?testes=20passando=20:tada:=20:tada:=20:ta?= =?UTF-8?q?da:=20O=20MELHOR=20AT=C3=89=20AGORA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/usuarios_controller.rb | 9 +++++++++ app/views/usuarios/avaliacoes.html.erb | 12 ++++++++++++ features/redefinicao_senha.feature | 1 + features/step_definitions/login_steps.rb | 4 ++++ .../step_definitions/responder_formulario_steps.rb | 12 ++++++------ 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/controllers/usuarios_controller.rb b/app/controllers/usuarios_controller.rb index 14e8d24070..6d4b0a73e1 100644 --- a/app/controllers/usuarios_controller.rb +++ b/app/controllers/usuarios_controller.rb @@ -37,6 +37,15 @@ def submeter_resposta redirect_to usuarios_avaliacoes_path(@usuario), alert: "Você já respondeu este formulário." and return end + respostas_em_branco = @formulario.elemento_forms.order(:ordem).any? do |ef| + params.dig(:respostas, ef.id.to_s).blank? + end + + if respostas_em_branco + flash.now[:alert] = "Por favor, responda todas as perguntas obrigatórias" + render :responder_formulario, status: :unprocessable_content and return + end + resposta_form = RespostaForm.new( formulario: @formulario, usuario: current_user, diff --git a/app/views/usuarios/avaliacoes.html.erb b/app/views/usuarios/avaliacoes.html.erb index 9884d7e7df..abaf679ade 100644 --- a/app/views/usuarios/avaliacoes.html.erb +++ b/app/views/usuarios/avaliacoes.html.erb @@ -32,6 +32,18 @@ <%# ── Conteúdo ── %>
+ <% if notice.present? %> +
+ <%= notice %> +
+ <% end %> + + <% if alert.present? %> +
+ <%= alert %> +
+ <% end %> + <% if @avaliacoes.present? %>
diff --git a/features/redefinicao_senha.feature b/features/redefinicao_senha.feature index 0f9d17ff33..443145f980 100644 --- a/features/redefinicao_senha.feature +++ b/features/redefinicao_senha.feature @@ -8,6 +8,7 @@ Funcionalidade: Redefinição de senha Contexto: Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123" + E eu estou na página de login Cenário: Solicitar redefinição de senha com sucesso (happy path) Quando eu clico em "Esqueci minha senha" diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb index f82ef852aa..8830713eef 100644 --- a/features/step_definitions/login_steps.rb +++ b/features/step_definitions/login_steps.rb @@ -1,3 +1,7 @@ +Dado('eu estou na página de login') do + visit root_path +end + Dado('que meu usuário está cadastrado com o email {string}') do |email| Usuario.find_or_create_by!(email: email) do |u| u.matricula = "#{rand(100000..999999)}" diff --git a/features/step_definitions/responder_formulario_steps.rb b/features/step_definitions/responder_formulario_steps.rb index 684ac12e59..32bac21f8a 100644 --- a/features/step_definitions/responder_formulario_steps.rb +++ b/features/step_definitions/responder_formulario_steps.rb @@ -75,7 +75,7 @@ fill_in "respostas[#{ef.id}]", with: 'Uma resposta qualquer' else primeiro_campo = ef.campo_forms.order(:ordem).first - choose "respostas[#{ef.id}]_#{primeiro_campo.id}" + find("input[type='radio'][name='respostas[#{ef.id}]'][value='#{primeiro_campo.id}']").click end end end @@ -88,20 +88,20 @@ click_button type: 'submit' end -#Então('eu devo ver a mensagem {string}') do |mensagem| +# Então('eu devo ver a mensagem {string}') do |mensagem| # expect(page).to have_content(mensagem) -#end +# end Então('a resposta deve ser registrada no sistema') do expect(RespostaForm.exists?(formulario: @formulario, usuario: @discente)).to be true end Então('eu não devo mais ser capaz de responder ao mesmo formulário') do - expect(page).to have_current_path(usuarios_avaliacoes_path(@discente)) - expect(page).not_to have_content(@formulario.turma.disciplina.nome) + click_link @formulario.turma.disciplina.nome + expect(page).to have_content("Você já respondeu este formulário.") end Quando('eu deixo uma pergunta obrigatória em branco') do campo_texto = @formulario.elemento_forms.find_by(tipo: 'Texto') fill_in "respostas[#{campo_texto.id}]", with: '' -end \ No newline at end of file +end From 3b862c04d6940354ad82e0d5b5f3b61f9a90de75 Mon Sep 17 00:00:00 2001 From: neatzzy Date: Tue, 16 Jun 2026 22:21:08 -0300 Subject: [PATCH 53/55] funcionou --- app/controllers/admin_controller.rb | 3 +++ app/views/admin/avaliacoes.html.erb | 35 ++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 95a0d7e368..64e85f7803 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -6,6 +6,9 @@ class AdminController < ApplicationController before_action :set_admin def avaliacoes + @avaliacoes = Formulario + .joins(:turma) + .includes(turma: { disciplina: :departamento, docentes: [] }) end def gerenciamento diff --git a/app/views/admin/avaliacoes.html.erb b/app/views/admin/avaliacoes.html.erb index fd3f3db2ab..e68456981e 100644 --- a/app/views/admin/avaliacoes.html.erb +++ b/app/views/admin/avaliacoes.html.erb @@ -1,3 +1,32 @@ -
-

Teste

-
\ No newline at end of file +<% if @avaliacoes.present? %> +
+ + <% @avaliacoes.each do |formulario| %> + <% turma = formulario.turma %> + <% disciplina = turma.disciplina %> + <% professor = turma.docentes.first %> + +
+
+

+ <%= disciplina.nome %> +

+

+ <%= turma.semestre %><%= " — #{turma.horario}" if turma.horario.present? %> +

+
+ +
+

+ <%= professor&.nome || "Professor(a) não alocado(a)" %> +

+
+
+ <% end %> + +
+<% else %> +
+

Nenhuma avaliação disponível no momento.

+
+<% end %> From 8eccf30e3262574072206a9c3fde6b9688df465e Mon Sep 17 00:00:00 2001 From: neatzzy Date: Tue, 16 Jun 2026 22:37:35 -0300 Subject: [PATCH 54/55] testes rspec arrumados --- app/models/formulario.rb | 2 +- spec/requests/sessions_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/formulario.rb b/app/models/formulario.rb index c801a630f4..87565cbd88 100644 --- a/app/models/formulario.rb +++ b/app/models/formulario.rb @@ -1,5 +1,5 @@ class Formulario < ApplicationRecord - belongs_to :turma, optional: true + belongs_to :turma has_many :elemento_forms, dependent: :destroy has_many :resposta_forms, dependent: :destroy end diff --git a/spec/requests/sessions_spec.rb b/spec/requests/sessions_spec.rb index c6d66e91b8..25e5261454 100644 --- a/spec/requests/sessions_spec.rb +++ b/spec/requests/sessions_spec.rb @@ -47,7 +47,7 @@ it "redireciona para a página do usuário" do get root_path - expect(response).to redirect_to(inicio_path) + expect(response).to redirect_to(usuarios_avaliacoes_path(docente.id)) end end end @@ -98,12 +98,12 @@ context "com credenciais válidas de usuário comum" do it "redireciona para a página do usuário" do post login_path, params: { login: docente.email, senha: "Senha123" } - expect(response).to redirect_to(inicio_path) + expect(response).to redirect_to(usuarios_avaliacoes_path(docente.id)) end it "aceita login pela matrícula" do post login_path, params: { login: docente.matricula, senha: "Senha123" } - expect(response).to redirect_to(inicio_path) + expect(response).to redirect_to(usuarios_avaliacoes_path(docente.id)) end end end From cc38ac17ad2fc34723cc9cb2c6c05ea45a65a374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lvis=20Corr=C3=AAa=20Miranda=20J=C3=BAnior?= Date: Wed, 17 Jun 2026 10:39:37 -0300 Subject: [PATCH 55/55] Revert "Merge branch 'sprint-2' of https://github.com/gusfring41/CAMAAR into sprint-2" This reverts commit 0198cae302131facbaa88c4238bb4f8271de209f, reversing changes made to 6c57ca1893f4ecc68c89d65d27c355c2e8b04e9b. --- Gemfile | 2 +- Gemfile.lock | 8 +- app/controllers/campo_forms_controller.rb | 1 - app/controllers/campos_controller.rb | 1 - app/controllers/cursos_controller.rb | 1 - app/controllers/departamentos_controller.rb | 1 - app/controllers/discentes_controller.rb | 1 - app/controllers/disciplinas_controller.rb | 1 - app/controllers/docentes_controller.rb | 1 - app/controllers/elemento_forms_controller.rb | 1 - app/controllers/elementos_controller.rb | 1 - app/controllers/formularios_controller.rb | 1 - app/controllers/resposta_elems_controller.rb | 1 - app/controllers/resposta_forms_controller.rb | 1 - app/controllers/templates_controller.rb | 1 - app/controllers/turmas_controller.rb | 1 - app/controllers/usuarios_controller.rb | 83 ------- app/services/sigaa_importer.rb | 39 +-- app/views/admin/enviar_formularios.html.erb | 57 ----- app/views/admin/resultados.html.erb | 2 +- app/views/usuarios/avaliacoes.html.erb | 85 ------- app/views/usuarios/index.html.erb | 4 +- .../usuarios/responder_formulario.html.erb | 105 -------- ..._to_formularios_and_make_turma_optional.rb | 6 - ...260616201400_add_tipo_to_elemento_forms.rb | 5 - features/criar_formulario.feature | 25 +- features/redefinicao_senha.feature | 1 - features/responder_formulario.feature | 23 +- .../atualizar_dados_sigaa_steps.rb | 8 +- features/step_definitions/cadastro_steps.rb | 21 +- .../criar_formulario_steps.rb | 102 ++------ .../criar_formulario_template_steps.rb | 225 +++++++++--------- .../step_definitions/exportar_csv_steps.rb | 40 ++-- .../importar_dados_sigaa_steps.rb | 8 +- .../responder_formulario_steps.rb | 112 ++------- spec/models/campo_form_spec.rb | 5 + spec/models/campo_spec.rb | 5 + spec/models/curso_spec.rb | 5 + spec/models/departamento_spec.rb | 5 + spec/models/disciplina_spec.rb | 5 + spec/models/elemento_form_spec.rb | 5 + spec/models/elemento_spec.rb | 5 + spec/models/formulario_spec.rb | 28 +-- spec/models/resposta_elem_spec.rb | 5 + spec/models/resposta_form_spec.rb | 5 + spec/models/turma_spec.rb | 5 + spec/models/usuario_spec.rb | 163 +------------ spec/requests/formulario_spec.rb | 55 ----- spec/requests/importacao_sigaa_spec.rb | 36 --- spec/requests/senhas_spec.rb | 66 ----- spec/requests/sessions_spec.rb | 125 ---------- spec/requests/templates_spec.rb | 65 ----- spec/requests/usuarios_spec.rb | 118 --------- 53 files changed, 278 insertions(+), 1403 deletions(-) delete mode 100644 app/views/admin/enviar_formularios.html.erb delete mode 100644 app/views/usuarios/avaliacoes.html.erb delete mode 100644 app/views/usuarios/responder_formulario.html.erb delete mode 100644 db/migrate/20260616193744_add_titulo_to_formularios_and_make_turma_optional.rb delete mode 100644 db/migrate/20260616201400_add_tipo_to_elemento_forms.rb create mode 100644 spec/models/campo_form_spec.rb create mode 100644 spec/models/campo_spec.rb create mode 100644 spec/models/curso_spec.rb create mode 100644 spec/models/departamento_spec.rb create mode 100644 spec/models/disciplina_spec.rb create mode 100644 spec/models/elemento_form_spec.rb create mode 100644 spec/models/elemento_spec.rb create mode 100644 spec/models/resposta_elem_spec.rb create mode 100644 spec/models/resposta_form_spec.rb create mode 100644 spec/models/turma_spec.rb delete mode 100644 spec/requests/formulario_spec.rb delete mode 100644 spec/requests/importacao_sigaa_spec.rb delete mode 100644 spec/requests/senhas_spec.rb delete mode 100644 spec/requests/sessions_spec.rb delete mode 100644 spec/requests/templates_spec.rb delete mode 100644 spec/requests/usuarios_spec.rb diff --git a/Gemfile b/Gemfile index a105698d72..e7d3112a4a 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ gem "solid_cable" # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false -gem "csv" +gem 'csv' # Deploy this application anywhere as a Docker container [https://kamal-deploy.org] gem "kamal", require: false diff --git a/Gemfile.lock b/Gemfile.lock index deb32c804a..7d7398f022 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -339,7 +339,7 @@ GEM rspec-mocks (>= 3.13.0, < 5.0.0) rspec-support (>= 3.13.0, < 5.0.0) rspec-support (3.13.7) - rubocop (1.88.0) + rubocop (1.87.0) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -373,7 +373,7 @@ GEM logger rubyzip (3.4.0) securerandom (0.4.1) - selenium-webdriver (4.45.0) + selenium-webdriver (4.44.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) @@ -618,7 +618,7 @@ CHECKSUMS rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47 rspec-rails (8.0.4) sha256=06235692fc0892683d3d34977e081db867434b3a24ae0dd0c6f3516bad4e22df rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c - rubocop (1.88.0) sha256=e420ddf1662d0ef34bc8a2910ac4b396a7ddda0b51a708264405241734b08e0b + rubocop (1.87.0) sha256=b9d9ddf55116a513f8ef2c7ae660662d8b49301f118d3f0df61865b33a5c188d rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035 rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834 rubocop-rails (2.35.4) sha256=3aeaa325439c89950e8327565682ea794065d08e2ecbbfe95032bfa295a35df5 @@ -627,7 +627,7 @@ CHECKSUMS ruby-vips (2.3.0) sha256=e685ec02c13969912debbd98019e50492e12989282da5f37d05f5471442f5374 rubyzip (3.4.0) sha256=6de39bc9eba302b635a476d16c9e16b0872ad24517c2f98f2b3a7ea23caff57b securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1 - selenium-webdriver (4.45.0) sha256=ecac65a4df86ac6f7d707e6dcbacaa9c08b6cf2b966babecfb9653c5aa13e2d1 + selenium-webdriver (4.44.0) sha256=6f1df072529af369589c46f0e01132952aabb250cfd683c274d74dc1eb5d8477 solid_cable (4.0.0) sha256=8379680ef6bf36e195eb876a6306ea290f87d5fa10bc4a757bc2a918f83229b5 solid_cache (1.0.10) sha256=bc05a2fb3ac78a6f43cbb5946679cf9db67dd30d22939ededc385cb93e120d41 solid_queue (1.4.0) sha256=e6a18d196f0b27cb6e3c77c5b31258b05fb634f8ed64fb1866ed164047216c2a diff --git a/app/controllers/campo_forms_controller.rb b/app/controllers/campo_forms_controller.rb index 8dbd5a533c..de491c59e0 100644 --- a/app/controllers/campo_forms_controller.rb +++ b/app/controllers/campo_forms_controller.rb @@ -1,5 +1,4 @@ class CampoFormsController < ApplicationController - before_action :require_login before_action :set_campo_form, only: %i[ show edit update destroy ] # GET /campo_forms or /campo_forms.json diff --git a/app/controllers/campos_controller.rb b/app/controllers/campos_controller.rb index b520443484..cabefcb40d 100644 --- a/app/controllers/campos_controller.rb +++ b/app/controllers/campos_controller.rb @@ -1,5 +1,4 @@ class CamposController < ApplicationController - before_action :require_login before_action :set_campo, only: %i[ show edit update destroy ] # GET /campos or /campos.json diff --git a/app/controllers/cursos_controller.rb b/app/controllers/cursos_controller.rb index 3d0d78d8e7..afdf4d6e91 100644 --- a/app/controllers/cursos_controller.rb +++ b/app/controllers/cursos_controller.rb @@ -1,5 +1,4 @@ class CursosController < ApplicationController - before_action :require_login before_action :set_curso, only: %i[ show edit update destroy ] # GET /cursos or /cursos.json diff --git a/app/controllers/departamentos_controller.rb b/app/controllers/departamentos_controller.rb index 49fdfccfb6..106c61bf2b 100644 --- a/app/controllers/departamentos_controller.rb +++ b/app/controllers/departamentos_controller.rb @@ -1,5 +1,4 @@ class DepartamentosController < ApplicationController - before_action :require_login before_action :set_departamento, only: %i[ show edit update destroy ] # GET /departamentos or /departamentos.json diff --git a/app/controllers/discentes_controller.rb b/app/controllers/discentes_controller.rb index 2c7d21c0a5..08d886207d 100644 --- a/app/controllers/discentes_controller.rb +++ b/app/controllers/discentes_controller.rb @@ -1,5 +1,4 @@ class DiscentesController < ApplicationController - before_action :require_login before_action :set_discente, only: %i[ show edit update destroy ] # GET /discentes or /discentes.json diff --git a/app/controllers/disciplinas_controller.rb b/app/controllers/disciplinas_controller.rb index 6ed261b5dd..5938a50d91 100644 --- a/app/controllers/disciplinas_controller.rb +++ b/app/controllers/disciplinas_controller.rb @@ -1,5 +1,4 @@ class DisciplinasController < ApplicationController - before_action :require_login before_action :set_disciplina, only: %i[ show edit update destroy ] # GET /disciplinas or /disciplinas.json diff --git a/app/controllers/docentes_controller.rb b/app/controllers/docentes_controller.rb index 4e29712586..2fc30c57d8 100644 --- a/app/controllers/docentes_controller.rb +++ b/app/controllers/docentes_controller.rb @@ -1,5 +1,4 @@ class DocentesController < ApplicationController - before_action :require_login before_action :set_docente, only: %i[ show edit update destroy ] # GET /docentes or /docentes.json diff --git a/app/controllers/elemento_forms_controller.rb b/app/controllers/elemento_forms_controller.rb index 1bf8b899e0..355d9573ff 100644 --- a/app/controllers/elemento_forms_controller.rb +++ b/app/controllers/elemento_forms_controller.rb @@ -1,5 +1,4 @@ class ElementoFormsController < ApplicationController - before_action :require_login before_action :set_elemento_form, only: %i[ show edit update destroy ] # GET /elemento_forms or /elemento_forms.json diff --git a/app/controllers/elementos_controller.rb b/app/controllers/elementos_controller.rb index 1788ecfbeb..4357f9c17a 100644 --- a/app/controllers/elementos_controller.rb +++ b/app/controllers/elementos_controller.rb @@ -1,5 +1,4 @@ class ElementosController < ApplicationController - before_action :require_login before_action :set_elemento, only: %i[ show edit update destroy ] # GET /elementos or /elementos.json diff --git a/app/controllers/formularios_controller.rb b/app/controllers/formularios_controller.rb index 07d51eadc3..d50b937cf0 100644 --- a/app/controllers/formularios_controller.rb +++ b/app/controllers/formularios_controller.rb @@ -1,5 +1,4 @@ class FormulariosController < ApplicationController - before_action :require_login before_action :set_formulario, only: %i[ show edit update destroy ] # GET /formularios or /formularios.json diff --git a/app/controllers/resposta_elems_controller.rb b/app/controllers/resposta_elems_controller.rb index 719623deb7..ebb155db99 100644 --- a/app/controllers/resposta_elems_controller.rb +++ b/app/controllers/resposta_elems_controller.rb @@ -1,5 +1,4 @@ class RespostaElemsController < ApplicationController - before_action :require_login before_action :set_resposta_elem, only: %i[ show edit update destroy ] # GET /resposta_elems or /resposta_elems.json diff --git a/app/controllers/resposta_forms_controller.rb b/app/controllers/resposta_forms_controller.rb index 8403ecf8f9..16b541a220 100644 --- a/app/controllers/resposta_forms_controller.rb +++ b/app/controllers/resposta_forms_controller.rb @@ -1,5 +1,4 @@ class RespostaFormsController < ApplicationController - before_action :require_login before_action :set_resposta_form, only: %i[ show edit update destroy ] # GET /resposta_forms or /resposta_forms.json diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb index f2c9f06e87..b22654be3b 100644 --- a/app/controllers/templates_controller.rb +++ b/app/controllers/templates_controller.rb @@ -1,6 +1,5 @@ class TemplatesController < ApplicationController layout "gerenciamento" - before_action :require_login before_action :set_admin before_action :set_template, only: %i[ show edit update destroy ] diff --git a/app/controllers/turmas_controller.rb b/app/controllers/turmas_controller.rb index 78321a3d64..5ba8d974ef 100644 --- a/app/controllers/turmas_controller.rb +++ b/app/controllers/turmas_controller.rb @@ -1,5 +1,4 @@ class TurmasController < ApplicationController - before_action :require_login before_action :set_turma, only: %i[ show edit update destroy ] # GET /turmas or /turmas.json diff --git a/app/controllers/usuarios_controller.rb b/app/controllers/usuarios_controller.rb index 6d4b0a73e1..997075c07a 100644 --- a/app/controllers/usuarios_controller.rb +++ b/app/controllers/usuarios_controller.rb @@ -1,89 +1,6 @@ class UsuariosController < ApplicationController - before_action :require_login - before_action :require_admin, except: [ :avaliacoes, :responder_formulario, :submeter_resposta ] before_action :set_usuario, only: %i[ show edit update destroy ] - def avaliacoes - @usuario = Usuario.find(params[:usuario_id]) - - if @usuario.is_a?(Docente) - @turmas = @usuario.turmas - elsif @usuario.is_a?(Discente) - @turmas = @usuario.turmas - else - @turmas = Turma.none - end - - @avaliacoes = Formulario - .joins(:turma) - .where(turma: @turmas) - .includes(turma: { disciplina: :departamento, docentes: [] }) - end - - def responder_formulario - @usuario = Usuario.find(params[:usuario_id]) - @formulario = Formulario.includes(elemento_forms: :campo_forms).find(params[:formulario_id]) - - if RespostaForm.exists?(formulario: @formulario, usuario: current_user) - redirect_to usuarios_avaliacoes_path(@usuario), notice: "Você já respondeu este formulário." - end - end - - def submeter_resposta - @usuario = Usuario.find(params[:usuario_id]) - @formulario = Formulario.includes(elemento_forms: :campo_forms).find(params[:formulario_id]) - - if RespostaForm.exists?(formulario: @formulario, usuario: current_user) - redirect_to usuarios_avaliacoes_path(@usuario), alert: "Você já respondeu este formulário." and return - end - - respostas_em_branco = @formulario.elemento_forms.order(:ordem).any? do |ef| - params.dig(:respostas, ef.id.to_s).blank? - end - - if respostas_em_branco - flash.now[:alert] = "Por favor, responda todas as perguntas obrigatórias" - render :responder_formulario, status: :unprocessable_content and return - end - - resposta_form = RespostaForm.new( - formulario: @formulario, - usuario: current_user, - data_submissao: Date.today - ) - - ActiveRecord::Base.transaction do - resposta_form.save! - - @formulario.elemento_forms.order(:ordem).each do |ef| - resposta_val = params.dig(:respostas, ef.id.to_s) - next if resposta_val.blank? - - if ef.tipo == "Texto" - resposta_form.resposta_elems.create!( - elemento_form: ef, - texto_resposta: resposta_val - ) - else - campo = ef.campo_forms.find_by(id: resposta_val) - next unless campo - - resposta_form.resposta_elems.create!( - elemento_form: ef, - campo_form: campo, - texto_resposta: campo.enunciado - ) - end - end - end - - redirect_to usuarios_avaliacoes_path(@usuario), notice: "Respostas enviadas com sucesso!" - rescue ActiveRecord::RecordInvalid => e - @formulario = Formulario.includes(elemento_forms: :campo_forms).find(params[:formulario_id]) - flash.now[:alert] = "Erro ao salvar respostas: #{e.message}" - render :responder_formulario, status: :unprocessable_content - end - # GET /usuarios or /usuarios.json def index @usuarios = Usuario.all diff --git a/app/services/sigaa_importer.rb b/app/services/sigaa_importer.rb index 9c6e73a1d9..65d5991dbd 100644 --- a/app/services/sigaa_importer.rb +++ b/app/services/sigaa_importer.rb @@ -39,13 +39,7 @@ def self.import_from_files(classes_path, members_path) # docente if m["docente"].is_a?(Hash) - dep_nome = m["docente"]["departamento"] - dep = if dep_nome.present? - dep_cod = dep_nome.parameterize(separator: "_").upcase.first(20) - Departamento.find_or_create_by(codigo: dep_cod) { |d| d.nome = dep_nome } - else - dep_padrao - end + dep = m["docente"]["departamento"].present? ? Departamento.find_or_create_by(nome: m["docente"]["departamento"]) : dep_padrao docente = Docente.find_or_create_by(email: m["docente"]["email"]) do |dct| dct.nome = m["docente"]["nome"] dct.matricula = m["docente"]["matricula"] || m["docente"]["usuario"] @@ -63,13 +57,7 @@ def self.import_from_files(classes_path, members_path) # discentes Array(m["dicente"]).each do |aluno| next unless aluno.is_a?(Hash) - curso = if aluno["curso"].present? - curso_cod = aluno["curso"].parameterize(separator: "_").upcase.first(30) - Curso.find_or_create_by(codigo: curso_cod) do |c| - c.nome = aluno["curso"] - c.departamento = dep_padrao - end - end + curso = Curso.find_or_create_by(nome: aluno["curso"]) { |c| c.departamento = dep_padrao } if aluno["curso"] discente = Discente.find_or_create_by(matricula: aluno["matricula"]) do |d| d.nome = aluno["nome"] d.email = aluno["email"] @@ -120,29 +108,18 @@ def self.update_from_files(classes_path, members_path) next unless turma if m["docente"].is_a?(Hash) - dep_nome = m["docente"]["departamento"] - dep = if dep_nome.present? - dep_cod = dep_nome.parameterize(separator: "_").upcase.first(20) - Departamento.find_or_create_by(codigo: dep_cod) { |d| d.nome = dep_nome } - end + dep = Departamento.find_or_create_by(nome: m["docente"]["departamento"]) if m["docente"]["departamento"] docente = Docente.find_by(email: m["docente"]["email"]) - if docente - docente.update(nome: m["docente"]["nome"], departamento: dep || docente.departamento) - docente.turmas << turma unless docente.turmas.exists?(turma.id) - end + docente.update(nome: m["docente"]["nome"], departamento: dep) if docente + docente.turmas << turma if docente && !docente.turmas.exists?(turma.id) end Array(m["dicente"]).each do |aluno| next unless aluno.is_a?(Hash) - curso = if aluno["curso"].present? - curso_cod = aluno["curso"].parameterize(separator: "_").upcase.first(30) - Curso.find_by(codigo: curso_cod) || Curso.find_by(nome: aluno["curso"]) - end + curso = Curso.find_by(nome: aluno["curso"]) if aluno["curso"] discente = Discente.find_by(matricula: aluno["matricula"]) - if discente - discente.update(nome: aluno["nome"], email: aluno["email"], curso: curso || discente.curso) - discente.turmas << turma unless discente.turmas.exists?(turma.id) - end + discente.update(nome: aluno["nome"], email: aluno["email"], curso: curso) if discente + discente.turmas << turma if discente && !discente.turmas.exists?(turma.id) end end end diff --git a/app/views/admin/enviar_formularios.html.erb b/app/views/admin/enviar_formularios.html.erb deleted file mode 100644 index 28842e4758..0000000000 --- a/app/views/admin/enviar_formularios.html.erb +++ /dev/null @@ -1,57 +0,0 @@ - diff --git a/app/views/admin/resultados.html.erb b/app/views/admin/resultados.html.erb index 5120a9f593..47ad89b4de 100644 --- a/app/views/admin/resultados.html.erb +++ b/app/views/admin/resultados.html.erb @@ -24,7 +24,7 @@ <%= formulario.turma.docentes.first&.nome || "Professor(a) não alocado(a)" %>

- <%= link_to "Baixar Resultado", admin_baixar_csv_path(@admin, id: formulario.id, format: :csv), style: "display: block; text-align: center; background-color: #612F65; color: white; text-decoration: none; padding: 10px 16px; border-radius: 4px; font-weight: bold; font-size: 0.9rem;" %> + <%= link_to "Baixar Resultado", baixar_csv_path(id: formulario.id, format: :csv), style: "display: block; text-align: center; background-color: #612F65; color: white; text-decoration: none; padding: 10px 16px; border-radius: 4px; font-weight: bold; font-size: 0.9rem;" %>
diff --git a/app/views/usuarios/avaliacoes.html.erb b/app/views/usuarios/avaliacoes.html.erb deleted file mode 100644 index abaf679ade..0000000000 --- a/app/views/usuarios/avaliacoes.html.erb +++ /dev/null @@ -1,85 +0,0 @@ -<%# app/views/usuarios/avaliacoes.html.erb %> - -
- - <%# ── Header ── %> -
- -
-

Avaliações

-
- -
-
- -
- -
-
- U -
- -
-
- -
- - <%# ── Conteúdo ── %> -
- - <% if notice.present? %> -
- <%= notice %> -
- <% end %> - - <% if alert.present? %> -
- <%= alert %> -
- <% end %> - - <% if @avaliacoes.present? %> -
- - <% @avaliacoes.each do |formulario| %> - <% turma = formulario.turma %> - <% disciplina = turma.disciplina %> - <% professor = turma.docentes.first %> - - <%= link_to usuarios_responder_formulario_path(@usuario, formulario), - style: "width: 278px; background: #FFFFFF; border-radius: 8px; padding: 24px; display: flex; flex-direction: column; justify-content: space-between; min-height: 130px; text-decoration: none; color: inherit; box-sizing: border-box;" do %> - -
-

- <%= disciplina.nome %> -

-

- <%= turma.semestre %><%= " — #{turma.horario}" if turma.horario.present? %> -

-
- -
-

- <%= professor&.nome || "Professor(a) não alocado(a)" %> -

-
- - <% end %> - <% end %> - -
- <% else %> -
-

Nenhuma avaliação disponível para você no momento.

-
- <% end %> - -
- -
\ No newline at end of file diff --git a/app/views/usuarios/index.html.erb b/app/views/usuarios/index.html.erb index 3715fefa03..53b9428ddc 100644 --- a/app/views/usuarios/index.html.erb +++ b/app/views/usuarios/index.html.erb @@ -6,9 +6,9 @@
<% @usuarios.each do |usuario| %> - <%= render partial: "usuario", object: usuario %> + <%= render usuario %>

- <%= link_to "Show this usuario", usuario_path(usuario) %> + <%= link_to "Show this usuario", usuario %>

<% end %>
diff --git a/app/views/usuarios/responder_formulario.html.erb b/app/views/usuarios/responder_formulario.html.erb deleted file mode 100644 index 87504c7444..0000000000 --- a/app/views/usuarios/responder_formulario.html.erb +++ /dev/null @@ -1,105 +0,0 @@ -<%# app/views/usuarios/responder_formulario.html.erb %> - -<% - titulo_header = if @formulario.titulo.present? - "Avaliação - #{@formulario.titulo}" - elsif @formulario.turma - partes = [@formulario.turma.disciplina&.nome, @formulario.turma.semestre].compact - partes.any? ? "Avaliação - #{partes.join(' - ')}" : "Avaliação" - else - "Avaliação" - end -%> - -
- - <%# ── Header ── %> -
- -
- <%= link_to usuarios_avaliacoes_path(@usuario), - style: "display: flex; align-items: center; color: #000000; text-decoration: none; font-size: 22px; line-height: 1;" do %> - ☰ - <% end %> -

- <%= titulo_header %> -

-
- -
- U -
- -
- - <%# ── Conteúdo ── %> -
- - <% if flash[:alert] %> -
- <%= flash[:alert] %> -
- <% end %> - - <%= form_with url: usuarios_submeter_resposta_path(@usuario, @formulario), - method: :post, - id: "formulario-resposta", - style: "display: flex; flex-direction: column; gap: 16px;" do |f| %> - - <% if @formulario.elemento_forms.empty? %> -
-

Este formulário não possui perguntas.

-
- <% end %> - - <% @formulario.elemento_forms.order(:ordem).each do |ef| %> -
- -

- <%= ef.enunciado %> -

- - <% if ef.tipo == "Texto" %> - - - <% else %> -
- <% ef.campo_forms.order(:ordem).each do |campo| %> - - <% end %> -
- <% end %> - -
- <% end %> - - <% end %> - -
- - <% if @formulario.elemento_forms.any? %> - - <% end %> - -
diff --git a/db/migrate/20260616193744_add_titulo_to_formularios_and_make_turma_optional.rb b/db/migrate/20260616193744_add_titulo_to_formularios_and_make_turma_optional.rb deleted file mode 100644 index f7a355427b..0000000000 --- a/db/migrate/20260616193744_add_titulo_to_formularios_and_make_turma_optional.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddTituloToFormulariosAndMakeTurmaOptional < ActiveRecord::Migration[8.1] - def change - add_column :formularios, :titulo, :string unless column_exists?(:formularios, :titulo) - change_column_null :formularios, :turma_id, true - end -end diff --git a/db/migrate/20260616201400_add_tipo_to_elemento_forms.rb b/db/migrate/20260616201400_add_tipo_to_elemento_forms.rb deleted file mode 100644 index fbdf527578..0000000000 --- a/db/migrate/20260616201400_add_tipo_to_elemento_forms.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTipoToElementoForms < ActiveRecord::Migration[8.1] - def change - add_column :elemento_forms, :tipo, :string unless column_exists?(:elemento_forms, :tipo) - end -end diff --git a/features/criar_formulario.feature b/features/criar_formulario.feature index 3beb886b65..7ebcad2ffd 100644 --- a/features/criar_formulario.feature +++ b/features/criar_formulario.feature @@ -10,21 +10,14 @@ Funcionalidade: Criar formulário de avaliação E eu estou na página de criação de formulários Cenário: Criação de formulário com sucesso (Happy Path) - Quando eu escolho um template para o formulário - E escolho uma turma para enviar o formulário - E envio o formulário + Quando eu preencho o título com "Avaliação de Turma 2026.1" + E eu adiciono uma pergunta do tipo "Múltipla Escolha" com o texto "Como você avalia o professor?" + E eu clico em "Salvar Formulário" Então eu devo ver a mensagem "Formulário criado com sucesso" - E o formulário deve estar disponível para os alunos da turma selecionada - - Cenário: Tentativa de criação sem template (Sad Path) - Quando eu não escolho um template para o formulário - E escolho uma turma para enviar o formulário - E envio o formulário - Então eu devo ver a mensagem "Selecione um template para criar o formulário" - - Cenário: Tentativa de criação sem turma (Sad Path) - Quando eu não escolho uma turma para enviar o formulário - E escolho um template para o formulário - E envio o formulário - Então eu devo ver a mensagem "Selecione pelo menos uma turma" + E eu devo ver o formulário "Avaliação de Turma 2026.1" na lista de formulários + Cenário: Tentativa de criação sem título (Sad Path) + Quando eu deixo o título em branco + E eu adiciono uma pergunta do tipo "Texto" com o texto "Quais suas sugestões?" + E eu clico em "Salvar Formulário" + Então eu devo ver a mensagem "Título não pode ficar em branco" diff --git a/features/redefinicao_senha.feature b/features/redefinicao_senha.feature index 443145f980..0f9d17ff33 100644 --- a/features/redefinicao_senha.feature +++ b/features/redefinicao_senha.feature @@ -8,7 +8,6 @@ Funcionalidade: Redefinição de senha Contexto: Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123" - E eu estou na página de login Cenário: Solicitar redefinição de senha com sucesso (happy path) Quando eu clico em "Esqueci minha senha" diff --git a/features/responder_formulario.feature b/features/responder_formulario.feature index 5a4e6ef00b..1b15384111 100644 --- a/features/responder_formulario.feature +++ b/features/responder_formulario.feature @@ -1,26 +1,25 @@ # language: pt Funcionalidade: Visualizar e responder formulário de avaliação - Como um discente + Como um aluno Quero poder visualizar e responder a um formulário de avaliação Para dar feedback sobre a turma ou disciplina Contexto: - Dado que eu estou logado como discente - E existe um formulário ativo para minha turma + Dado que eu estou logado como aluno + E existe um formulário ativo chamado "Avaliação de Turma 2026.1" E eu estou na página de formulários disponíveis Cenário: Resposta completa ao formulário com sucesso (Happy Path) - Quando eu clico para responder o formulário + Quando eu clico para responder o formulário "Avaliação de Turma 2026.1" Então eu devo visualizar os detalhes e perguntas pertinentes a ele - Quando eu respondo todos os campos do formulário - E eu envio o fomulário - Então eu devo ver a mensagem "Respostas enviadas com sucesso!" - E a resposta deve ser registrada no sistema - E eu não devo mais ser capaz de responder ao mesmo formulário + Quando eu respondo a pergunta "Como você avalia o professor?" com a opção "Ótimo" + E eu clico no botão "Enviar Avaliação" + Então eu devo ver a mensagem "Avaliação enviada com sucesso" + E o formulário "Avaliação de Turma 2026.1" não deve mais aparecer na minha lista de pendentes Cenário: Tentativa de envio com perguntas obrigatórias em branco (Sad Path) - Quando eu clico para responder o formulário - E eu deixo uma pergunta obrigatória em branco - E eu envio o formulário + Quando eu clico para responder o formulário "Avaliação de Turma 2026.1" + E eu deixo a pergunta obrigatória "Como você avalia o professor?" em branco + E eu clico no botão "Enviar Avaliação" Então eu devo ver a mensagem "Por favor, responda todas as perguntas obrigatórias" diff --git a/features/step_definitions/atualizar_dados_sigaa_steps.rb b/features/step_definitions/atualizar_dados_sigaa_steps.rb index 19ede668f2..d0cd1d5a9d 100644 --- a/features/step_definitions/atualizar_dados_sigaa_steps.rb +++ b/features/step_definitions/atualizar_dados_sigaa_steps.rb @@ -3,28 +3,28 @@ Dado('que os dados do SIGAA foram atualizados com sucesso') do allow(SigaaImporter).to receive(:update_from_files).and_return("atualização realizada com sucesso") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_classes: arquivo, arquivo_membros: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que eu tentei atualizar os dados do SIGAA mas ocorreu um erro') do allow(SigaaImporter).to receive(:update_from_files).and_return("falha") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_classes: arquivo, arquivo_membros: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que os dados do SIGAA já estão atualizados na base de dados do sistema') do allow(SigaaImporter).to receive(:update_from_files).and_return("os dados do SIGAA já estão atualizados e não serão atualizados novamente") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_classes: arquivo, arquivo_membros: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que alguns dados do SIGAA já estão atualizados na base de dados do sistema') do allow(SigaaImporter).to receive(:update_from_files).and_return("alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_classes: arquivo, arquivo_membros: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) visit admin_gerenciamento_path(@admin) end diff --git a/features/step_definitions/cadastro_steps.rb b/features/step_definitions/cadastro_steps.rb index f227280a07..69416073bc 100644 --- a/features/step_definitions/cadastro_steps.rb +++ b/features/step_definitions/cadastro_steps.rb @@ -8,8 +8,6 @@ departamento: departamento ) - allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) - allow_any_instance_of(AdminController).to receive(:set_admin) do |controller| controller.instance_variable_set(:@admin, Administrador.find(controller.params[:admin_id])) end @@ -22,24 +20,7 @@ end Dado('que eu importei os dados do SIGAA com sucesso') do - dep = Departamento.find_or_create_by!(codigo: "NAO_ESP") { |d| d.nome = "Não especificado" } - curso = Curso.find_or_create_by!(codigo: "TST") do |c| - c.nome = "Curso Teste" - c.departamento = dep - end - Discente.find_or_create_by!(matricula: "USR001") do |u| - u.nome = "Usuário Teste" - u.email = "usuario@teste.com" - u.curso = curso - end -end - -Então('o e-mail de usuário {string} está cadastrado no sistema com senha indefinida') do |email| - usuario = Usuario.find_by(email: email) - expect(usuario).to be_present, - "Esperava encontrar um usuário com email '#{email}', mas não encontrei." - expect(usuario.senha_hash).to be_blank, - "Esperava que o usuário '#{email}' não tivesse senha definida, mas tinha." + # implementar a partir da feature de importar dados end Então('um email de definição de senha é enviado para o email {string}') do |email| diff --git a/features/step_definitions/criar_formulario_steps.rb b/features/step_definitions/criar_formulario_steps.rb index 35e4bb831a..4df517218c 100644 --- a/features/step_definitions/criar_formulario_steps.rb +++ b/features/step_definitions/criar_formulario_steps.rb @@ -1,99 +1,39 @@ -# frozen_string_literal: true - Dado('que eu estou logado como professor') do - departamento = Departamento.find_or_create_by!(nome: 'Departamento de Teste', codigo: 'TST') - - @admin = Administrador.find_or_create_by!(email: 'professor@teste.com') do |a| - a.nome = 'Professor Teste' - a.matricula = 'prof001' - a.senha = 'Senha123' - a.senha_confirmation = 'Senha123' - a.departamento = departamento - end - - allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) - allow_any_instance_of(AdminController).to receive(:set_admin) do |controller| - controller.instance_variable_set(:@admin, @admin) - end + # Implementar quando definir models e autenticação + # visit '/login' + # fill_in 'Email', with: 'professor@ufpe.br' + # fill_in 'Senha', with: 'senha123' + # click_button 'Entrar' end Dado('eu estou na página de criação de formulários') do - departamento = Departamento.find_or_create_by!(nome: 'Departamento de Teste', codigo: 'TST') - - disciplina = Disciplina.find_or_create_by!(codigo: 'CIC0001') do |d| - d.nome = 'Engenharia de Software' - d.departamento = departamento - end - - @turma = Turma.find_or_create_by!( - disciplina: disciplina, - numero_da_turma: '01', - semestre: '2026.1' - ) do |t| - t.horario = '235M12' - end - - @template = Template.find_or_create_by!(nome: 'Avaliação Padrão', usuario_id: @admin.id) do |t| - elemento = t.elementos.build(enunciado: 'Como você avalia o professor?', ordem: 1) - elemento.campos.build( - tipo_elemento: 'Múltipla Escolha', - enunciado: 'Ótimo', - ordem: 1 - ) - elemento.campos.build( - tipo_elemento: 'Múltipla Escolha', - enunciado: 'Bom', - ordem: 2 - ) - elemento.campos.build( - tipo_elemento: 'Múltipla Escolha', - enunciado: 'Regular', - ordem: 3 - ) - elemento.campos.build( - tipo_elemento: 'Múltipla Escolha', - enunciado: 'Ruim', - ordem: 4 - ) - end - - visit admin_enviar_formularios_path(@admin) + visit '/forms/new' end -Quando('eu escolho um template para o formulário') do - select @template.nome, from: 'template_id' +Quando('eu preencho o título com {string}') do |titulo| + fill_in 'Título do Formulário', with: titulo end -Quando('escolho um template para o formulário') do - select @template.nome, from: 'template_id' +Quando('eu deixo o título em branco') do + fill_in 'Título do Formulário', with: '' end -Quando('escolho uma turma para enviar o formulário') do - check "turma_ids_#{@turma.id}" +Quando('eu adiciono uma pergunta do tipo {string} com o texto {string}') do |tipo, texto| + # Ajustar a interação com os botões/selects dinâmicos na tela quando desenvolvidos + select tipo, from: 'Tipo de Pergunta' + fill_in 'Texto da Pergunta', with: texto + click_button 'Adicionar Pergunta' end -Quando('envio o formulário') do - click_button 'Criar Formulário' -end - -Quando('eu não escolho um template para o formulário') do - # deliberately do nothing - leave template select at default blank option -end - -Quando('eu não escolho uma turma para enviar o formulário') do - # deliberately do nothing - leave no turma checkboxes checked +Quando('eu clico em {string}') do |nome_botao| + visit root_path unless page.has_button?(nome_botao) + click_button nome_botao end Então('eu devo ver a mensagem {string}') do |mensagem| expect(page).to have_content(mensagem) end -Então('o formulário deve estar disponível para os alunos da turma selecionada') do - formulario = Formulario.find_by(turma: @turma) - expect(formulario).to be_present - expect(formulario.titulo).to eq("#{@turma.disciplina.nome} - #{@turma.semestre}") - - elemento_forms_count = formulario.elemento_forms.count - template_elementos_count = @template.elementos.count - expect(elemento_forms_count).to eq(template_elementos_count) -end \ No newline at end of file +Então('eu devo ver o formulário {string} na lista de formulários') do |nome_formulario| + expect(page).to have_content(nome_formulario) +end diff --git a/features/step_definitions/criar_formulario_template_steps.rb b/features/step_definitions/criar_formulario_template_steps.rb index 1d272a0e30..d6fadcdfae 100644 --- a/features/step_definitions/criar_formulario_template_steps.rb +++ b/features/step_definitions/criar_formulario_template_steps.rb @@ -3,156 +3,161 @@ # Step definitions for: Criar formulário baseado em template Dado('que eu estou logado como administrador') do - depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') - - @admin = Administrador.find_or_create_by!(email: 'admin@unb.br') do |u| - u.senha_hash = '123456' - u.nome = 'Admin' - u.matricula = '123456789' - u.departamento = depto - end - - allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) - - allow_any_instance_of(AdminController).to receive(:set_admin) do |controller| - controller.instance_variable_set(:@admin, @admin) - end + # TODO: Implementar autenticação como administrador + # administrador = Administrador.create!( + # nome: "Admin", + # email: "admin@ufpe.br", + # matricula: "admin123", + # departamento: Departamento.first + # ) + # administrador.enviar_email_definicao_senha! + # visit login_path + # fill_in 'login', with: administrador.email + # fill_in 'senha', with: 'senha_temporaria' + # click_button 'Entrar' end Dado('que existe um template chamado {string} com as seguintes perguntas:') do |nome_template, table| - @admin ||= Administrador.first - - @template = Template.new(nome: nome_template, administrador: @admin) - - table.hashes.each_with_index do |row, index| - elemento = @template.elementos.build(enunciado: row['Pergunta'], ordem: index + 1) - - tipo = row['Tipo'] - opcoes_str = row['Opções'] || '' - - if tipo == 'Texto' || opcoes_str.blank? - elemento.campos.build(tipo_elemento: 'Texto', ordem: 1) - else - opcoes = opcoes_str.split(',').map(&:strip) - opcoes.each_with_index do |opcao, opt_idx| - elemento.campos.build(tipo_elemento: tipo, enunciado: opcao, ordem: opt_idx + 1) - end - end - end - - @template.save! + # table is a Cucumber::MultilineArgument::DataTable + # | Pergunta | Tipo | Opções | + # | Como você avalia o professor? | Múltipla Escolha | Ótimo, Bom, Regular, Ruim | + # | Qual seu nível de satisfação? | Escala | 1, 2, 3, 4, 5 | + # | Deixe seu comentário | Texto | | + # + # TODO: Implementar criação de template com elementos e campos + # @template = Template.create!(nome: nome_template) + # + # table.hashes.each do |row| + # elemento = @template.elementos.create!(enunciado: row['Pergunta'], ordem: @template.elementos.count + 1) + # + # case row['Tipo'] + # when 'Múltipla Escolha', 'Escala' + # row['Opções'].split(', ').each_with_index do |opcao, index| + # elemento.campos.create!(tipo_elemento: row['Tipo'], enunciado: opcao, ordem: index + 1) + # end + # when 'Texto' + # elemento.campos.create!(tipo_elemento: 'Texto', enunciado: '', ordem: 1) + # end + # end end Dado('que existem as seguintes turmas no semestre {string}:') do |semestre, table| - depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') - - table.hashes.each do |row| - disciplina = Disciplina.find_or_create_by!(codigo: row['Código']) do |d| - d.nome = row['Disciplina'] - d.departamento = depto - end - - Turma.find_or_create_by!( - disciplina: disciplina, - numero_da_turma: row['Turma'], - semestre: semestre - ) do |t| - t.horario = 'Seg 08:00-10:00' - end - end - - @turmas_disponiveis = Turma.where(semestre: semestre) + # table is a Cucumber::MultilineArgument::DataTable + # | Código | Disciplina | Turma | + # | TEC001 | Matemática | A | + # | TEC002 | Português | B | + # | TEC003 | História | A | + # + # TODO: Implementar criação de turmas + # table.hashes.each do |row| + # departamento = Departamento.find_or_create_by!(nome: 'Departamento Padrão', codigo: 'DEP01') + # disciplina = Disciplina.find_or_create_by!( + # codigo: row['Código'], + # nome: row['Disciplina'], + # departamento: departamento + # ) + # Turma.find_or_create_by!( + # disciplina: disciplina, + # numero_da_turma: row['Turma'], + # semestre: semestre, + # horario: 'Seg 08:00-10:00' + # ) + # end + # @turmas_disponiveis = Turma.where(semestre: semestre) end Quando('eu acesso a página de criação de formulário a partir de template') do - visit admin_enviar_formularios_path(@admin) + # TODO: Implementar rota para criação de formulário a partir de template + # visit new_formulario_from_template_path end Quando('eu seleciono o template {string}') do |nome_template| - select nome_template, from: 'template_id' + # TODO: Implementar seleção de template na interface + # select nome_template, from: 'template_id' end Quando('eu não seleciono nenhum template') do - # Garante que o campo de template permanece em branco - select 'Template', from: 'template_id' + # TODO: Garantir que nenhum template está selecionado end -Quando('eu seleciono as turmas {string}') do |turma_info| - partes = turma_info.split(' - ') - codigo = partes[0] - nome_disciplina = partes[1] - numero_turma = partes[2] - - disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) - turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) - check "turma_ids_#{turma.id}" +Quando('eu seleciono as turmas {string}') do |turmas_texto| + # TODO: Implementar seleção de turmas + # Exemplo de turmas_texto: "TEC001 - Matemática - A" + # turmas_texto.split(' e ').each do |turma_info| + # partes = turma_info.split(' - ') + # codigo = partes[0] + # nome_disciplina = partes[1] + # numero_turma = partes[2] + # + # disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # check "turma_ids_#{turma.id}" + # end end -Quando('eu seleciono as turmas {string} e {string}') do |turma1_info, turma2_info| - [ turma1_info, turma2_info ].each do |turma_info| - partes = turma_info.split(' - ') - codigo = partes[0] - nome_disciplina = partes[1] - numero_turma = partes[2] - - disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) - turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) - check "turma_ids_#{turma.id}" - end +Quando('eu não seleciono nenhuma turma') do + # TODO: Garantir que nenhuma turma está selecionada end -Quando('eu clico em {string}') do |botao| - click_button botao +Quando('eu clico em {string}') do |nome_botao| + click_button nome_botao end -Quando('eu não seleciono nenhuma turma') do - # Nenhum checkbox marcado — ação implícita +Então('eu devo ver a mensagem {string}') do |mensagem| + expect(page).to have_content(mensagem) end Então('o formulário deve conter as perguntas do template {string}') do |nome_template| - template = Template.find_by!(nome: nome_template) - formulario = Formulario.last - expect(formulario.elemento_forms.count).to eq(template.elementos.count) - formulario.elemento_forms.order(:ordem).each_with_index do |ef, i| - expect(ef.enunciado).to eq(template.elementos.order(:ordem)[i].enunciado) - end + # TODO: Verificar se o formulário foi criado com os elementos copiados do template + # template = Template.find_by!(nome: nome_template) + # formulario = Formulario.last + # expect(formulario.elemento_forms.count).to eq(template.elementos.count) + # formulario.elemento_forms.each_with_index do |ef, i| + # expect(ef.enunciado).to eq(template.elementos[i].enunciado) + # end end Então('o formulário deve estar associado à turma {string}') do |nome_turma_info| - partes = nome_turma_info.split(' - ') - nome_disciplina = partes[0] - numero_turma = partes[1] + # TODO: Verificar associação com a turma correta + # partes = nome_turma_info.split(' - ') + # nome_disciplina = partes[0] + # numero_turma = partes[1] + # disciplina = Disciplina.find_by!(nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # expect(Formulario.last.turma).to eq(turma) +end - disciplina = Disciplina.find_by!(nome: nome_disciplina) - turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) - expect(Formulario.last.turma).to eq(turma) +Então('eu devo ver a mensagem {string}') do |mensagem| + expect(page).to have_content(mensagem) end Então('deve existir um formulário para a turma {string}') do |nome_turma_info| - partes = nome_turma_info.split(' - ') - nome_disciplina = partes[0] - numero_turma = partes[1] - - disciplina = Disciplina.find_by!(nome: nome_disciplina) - turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) - expect(Formulario.exists?(turma: turma)).to be true + # TODO: Verificar existência do formulário para a turma + # partes = nome_turma_info.split(' - ') + # nome_disciplina = partes[0] + # numero_turma = partes[1] + # disciplina = Disciplina.find_by!(nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # expect(Formulario.exists?(turma: turma)).to be true end Então('cada formulário deve conter as perguntas do template {string}') do |nome_template| - template = Template.find_by!(nome: nome_template) - Formulario.all.each do |formulario| - expect(formulario.elemento_forms.count).to eq(template.elementos.count) - end + # template = Template.find_by!(nome: nome_template) + # Formulario.all.each do |formulario| + # expect(formulario.elemento_forms.count).to eq(template.elementos.count) + # end end Então('eu devo ver a lista de templates disponíveis') do - Template.all.each do |template| - expect(page).to have_content(template.nome) - end + # TODO: Verificar se os templates são exibidos + # Template.all.each do |template| + # expect(page).to have_content(template.nome) + # end end Então('eu devo ver a lista de turmas do semestre {string} disponíveis') do |semestre| - Turma.where(semestre: semestre).each do |turma| - expect(page).to have_content(turma.disciplina.nome) - end + # TODO: Verificar se as turmas do semestre são exibidas + # Turma.where(semestre: semestre).each do |turma| + # expect(page).to have_content(turma.disciplina.nome) + # end end diff --git a/features/step_definitions/exportar_csv_steps.rb b/features/step_definitions/exportar_csv_steps.rb index 6574601495..4687e68e13 100644 --- a/features/step_definitions/exportar_csv_steps.rb +++ b/features/step_definitions/exportar_csv_steps.rb @@ -7,23 +7,23 @@ codigo: "DEP01", nome: "Departamento de Computação" ) - + @admin = Administrador.create!( matricula: "ADM001", nome: "Admin Teste", email: "admin@teste.com", departamento: @departamento ) - + # Reutiliza o step de login já existente nos steps de autenticação step 'que meu usuário está cadastrado com o email "admin@teste.com" e senha "senha123"' step 'eu tento realizar o login com o email "admin@teste.com" e a senha "senha123"' - - visit admin_resultados_path(@admin) + + visit admin_resultados_path end Dado("vejo os formulários enviados para todas as turmas do meu departamento") do - expect(page).to have_current_path(admin_resultados_path(@admin)) + expect(page).to have_current_path(admin_resultados_path) end Dado("existe a {string} de {string} que possui um formulário associado a ela") do |nome_turma, nome_disciplina| @@ -61,7 +61,7 @@ nome: "Ciência da Computação", departamento: @departamento ) - + @aluno = Discente.create!( matricula: "ALU001", nome: "Aluno Teste", @@ -69,33 +69,33 @@ curso: @curso_aluno, departamento: @departamento ) - + @resposta = RespostaForm.create!( formulario: @formulario, usuario: @aluno, data_submissao: Date.today ) - @template = Template.new(nome: "Template Padrão", administrador: @admin) + @template = Template.new(nome: "Template Padrão") elemento_base = @template.elementos.build(ordem: 1, enunciado: "Avaliação") elemento_base.campos.build(ordem: 1, enunciado: "Muito bom", tipo_elemento: "Múltipla Escolha") elemento_base.campos.build(ordem: 2, enunciado: "Excelente", tipo_elemento: "Múltipla Escolha") @template.save! - [ @elemento1, @elemento2 ].each do |ef| + [@elemento1, @elemento2].each do |ef| elemento_base.campos.each do |campo_base| CampoForm.find_or_create_by!(enunciado: campo_base.enunciado, elemento_form: ef) do |cf| cf.ordem = campo_base.ordem end end end - + { @elemento1 => "Muito bom", @elemento2 => "Excelente" }.each do |ef, texto| cf = ef.campo_forms.find_by!(enunciado: texto) - + RespostaElem.create!( texto_resposta: texto, resposta_form: @resposta, @@ -103,8 +103,8 @@ campo_form: cf ) end - - visit admin_resultados_path(@admin) + + visit admin_resultados_path end @@ -119,15 +119,15 @@ num_turma = @formulario.turma.numero_da_turma.parameterize(separator: '_') nome_materia = @formulario.turma.disciplina.nome.parameterize(separator: '_') nome_esperado = "formulario_#{@formulario.id}_turma_#{num_turma}_#{nome_materia}" - + content_disposition = page.response_headers["Content-Disposition"] - + expect(content_disposition).to be_present, "Esperava um header Content-Disposition indicando download, mas não havia nenhum." - + expect(content_disposition).to include("attachment"), "Esperava 'attachment' no Content-Disposition, mas foi: #{content_disposition}" - + expect(content_disposition).to include(nome_esperado), "Esperava '#{nome_esperado}' no nome do arquivo, " \ "mas o header foi: #{content_disposition}" @@ -172,9 +172,9 @@ Dado("que a {string} possui outro formulário") do |nome_turma| @turma_sad = Turma.find_by(numero_da_turma: nome_turma) || @turma - + @formulario_vazio = Formulario.create!(turma: @turma_sad) - + ElementoForm.create!( ordem: 1, enunciado: "Pergunta sem respostas", @@ -187,7 +187,7 @@ RespostaForm.where(formulario_id: @formulario_vazio.id).count ).to eq(0), "Esperava 0 respostas para o formulário vazio, mas havia algumas." - visit admin_resultados_path(@admin) + visit admin_resultados_path end Então("vejo a mensagem de erro {string}") do |mensagem_esperada| diff --git a/features/step_definitions/importar_dados_sigaa_steps.rb b/features/step_definitions/importar_dados_sigaa_steps.rb index 5c5d86b942..f2fa158a39 100644 --- a/features/step_definitions/importar_dados_sigaa_steps.rb +++ b/features/step_definitions/importar_dados_sigaa_steps.rb @@ -6,28 +6,28 @@ Dado('que os dados do SIGAA foram importados com sucesso') do allow(SigaaImporter).to receive(:import_from_files).and_return("importação realizada com sucesso") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_classes: arquivo, arquivo_membros: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que eu tentei importar os dados do SIGAA mas ocorreu um erro') do allow(SigaaImporter).to receive(:import_from_files).and_return("a importação falhou") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_classes: arquivo, arquivo_membros: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que os dados do SIGAA já existem na base de dados do sistema') do allow(SigaaImporter).to receive(:import_from_files).and_return("os dados já existem e não foram duplicados") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_classes: arquivo, arquivo_membros: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) visit admin_gerenciamento_path(@admin) end Dado('que alguns dados do SIGAA já existem na base de dados do sistema') do allow(SigaaImporter).to receive(:import_from_files).and_return("alguns dados já foram importados e não serão importados novamente") arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") - page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_classes: arquivo, arquivo_membros: arquivo }) + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) visit admin_gerenciamento_path(@admin) end diff --git a/features/step_definitions/responder_formulario_steps.rb b/features/step_definitions/responder_formulario_steps.rb index 32bac21f8a..eebcbd09dd 100644 --- a/features/step_definitions/responder_formulario_steps.rb +++ b/features/step_definitions/responder_formulario_steps.rb @@ -1,107 +1,43 @@ -Dado('que eu estou logado como discente') do - depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') - curso = Curso.find_or_create_by!(codigo: 'TST') do |c| - c.nome = 'Curso Teste' - c.departamento = depto - end - - @discente = Discente.find_or_create_by!(matricula: '2024001') do |u| - u.nome = 'Discente Teste' - u.email = 'discente@teste.com' - u.senha = 'Senha123' - u.senha_confirmation = 'Senha123' - u.curso = curso - end - - allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@discente) +Dado('que eu estou logado como aluno') do + # Implementar quando definir models e autenticação + # visit '/login' + # fill_in 'Email', with: 'aluno@ufpe.br' + # fill_in 'Senha', with: 'senha123' + # click_button 'Entrar' end -Dado('existe um formulário ativo para minha turma') do - depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') - disciplina = Disciplina.find_or_create_by!(codigo: 'CIC0001') do |d| - d.nome = 'Engenharia de Software' - d.departamento = depto - end - - turma = Turma.find_or_create_by!( - disciplina: disciplina, - numero_da_turma: '01', - semestre: '2026.1' - ) do |t| - t.horario = '235M12' - end - - @discente.turmas << turma unless @discente.turmas.include?(turma) - - @formulario = Formulario.find_or_create_by!(turma: turma) do |f| - f.titulo = 'Avaliação de Turma 2026.1' - end - - elemento = @formulario.elemento_forms.find_or_create_by!(ordem: 1) do |ef| - ef.enunciado = 'Como você avalia o professor?' - ef.tipo = 'Múltipla Escolha' - end - - elemento.campo_forms.find_or_create_by!(ordem: 1) { |c| c.enunciado = 'Ótimo' } - elemento.campo_forms.find_or_create_by!(ordem: 2) { |c| c.enunciado = 'Bom' } - elemento.campo_forms.find_or_create_by!(ordem: 3) { |c| c.enunciado = 'Regular' } - elemento.campo_forms.find_or_create_by!(ordem: 4) { |c| c.enunciado = 'Ruim' } - - elemento2 = @formulario.elemento_forms.find_or_create_by!(ordem: 2) do |ef| - ef.enunciado = 'Comente sobre a didática' - ef.tipo = 'Texto' - end - - elemento2.campo_forms.find_or_create_by!(ordem: 1) +Dado('existe um formulário ativo chamado {string}') do |nome_formulario| + # Implementar a criação desse registro (Form/Evaluation) no banco usando Factory/ActiveRecord end Dado('eu estou na página de formulários disponíveis') do - visit usuarios_avaliacoes_path(@discente) + visit '/forms/pending' end -Quando('eu clico para responder o formulário') do - click_link @formulario.turma.disciplina.nome +Quando('eu clico para responder o formulário {string}') do |nome_formulario| + # Ajustar seletor dependendo da interface, por exemplo, achar o escopo do texto ou tr + click_link "Responder" end Então('eu devo visualizar os detalhes e perguntas pertinentes a ele') do - @formulario.elemento_forms.each do |ef| - expect(page).to have_content(ef.enunciado) - end -end - -Quando('eu respondo todos os campos do formulário') do - @formulario.elemento_forms.order(:ordem).each do |ef| - if ef.tipo == 'Texto' - fill_in "respostas[#{ef.id}]", with: 'Uma resposta qualquer' - else - primeiro_campo = ef.campo_forms.order(:ordem).first - find("input[type='radio'][name='respostas[#{ef.id}]'][value='#{primeiro_campo.id}']").click - end - end + # Assumindo que a classe .form-question existirá na view + expect(page).to have_selector('.form-question') end -Quando('eu envio o fomulário') do - click_button type: 'submit' +Quando('eu respondo a pergunta {string} com a opção {string}') do |pergunta, opcao| + # Ajustar conformidade de input visual (radio, select, text) + choose opcao end -Quando('eu envio o formulário') do - click_button type: 'submit' -end - -# Então('eu devo ver a mensagem {string}') do |mensagem| -# expect(page).to have_content(mensagem) -# end - -Então('a resposta deve ser registrada no sistema') do - expect(RespostaForm.exists?(formulario: @formulario, usuario: @discente)).to be true +Quando('eu deixo a pergunta obrigatória {string} em branco') do |pergunta| + # O comportamento de deixar em branco pode ser simplesmente não preencher, logo, nenhum click extra. end -Então('eu não devo mais ser capaz de responder ao mesmo formulário') do - click_link @formulario.turma.disciplina.nome - expect(page).to have_content("Você já respondeu este formulário.") +Quando('eu clico no botão {string}') do |nome_botao| + click_button nome_botao end -Quando('eu deixo uma pergunta obrigatória em branco') do - campo_texto = @formulario.elemento_forms.find_by(tipo: 'Texto') - fill_in "respostas[#{campo_texto.id}]", with: '' +Então('o formulário {string} não deve mais aparecer na minha lista de pendentes') do |nome_formulario| + visit '/forms/pending' + expect(page).not_to have_content(nome_formulario) end diff --git a/spec/models/campo_form_spec.rb b/spec/models/campo_form_spec.rb new file mode 100644 index 0000000000..05d3574c3d --- /dev/null +++ b/spec/models/campo_form_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CampoForm, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/campo_spec.rb b/spec/models/campo_spec.rb new file mode 100644 index 0000000000..6618006be8 --- /dev/null +++ b/spec/models/campo_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Campo, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/curso_spec.rb b/spec/models/curso_spec.rb new file mode 100644 index 0000000000..4e29152a4a --- /dev/null +++ b/spec/models/curso_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Curso, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/departamento_spec.rb b/spec/models/departamento_spec.rb new file mode 100644 index 0000000000..0a0d313f9c --- /dev/null +++ b/spec/models/departamento_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Departamento, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/disciplina_spec.rb b/spec/models/disciplina_spec.rb new file mode 100644 index 0000000000..17de7443da --- /dev/null +++ b/spec/models/disciplina_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Disciplina, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/elemento_form_spec.rb b/spec/models/elemento_form_spec.rb new file mode 100644 index 0000000000..2a8ad23d78 --- /dev/null +++ b/spec/models/elemento_form_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ElementoForm, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/elemento_spec.rb b/spec/models/elemento_spec.rb new file mode 100644 index 0000000000..fd36adff7a --- /dev/null +++ b/spec/models/elemento_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Elemento, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/formulario_spec.rb b/spec/models/formulario_spec.rb index 7ff3ac9799..2318f88769 100644 --- a/spec/models/formulario_spec.rb +++ b/spec/models/formulario_spec.rb @@ -1,29 +1,5 @@ require 'rails_helper' RSpec.describe Formulario, type: :model do - let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } - let(:disciplina) { Disciplina.find_or_create_by!(nome: "Engenharia de Software", codigo: "CIC0097", departamento: departamento) } - let(:turma) { Turma.find_or_create_by!(numero_da_turma: "TA", disciplina: disciplina, semestre: "2026.1") } - - context "validações de criação e relacionamentos" do - it "é válido quando associado a uma turma" do - formulario = Formulario.new(turma: turma) - expect(formulario).to be_valid - end - - it "não é válido sem estar vinculado a uma turma" do - formulario = Formulario.new(turma: nil) - expect(formulario).not_to be_valid - end - - it "possui relacionamento com elemento_forms" do - formulario = Formulario.new(turma: turma) - expect(formulario).to respond_to(:elemento_forms) - end - - it "possui relacionamento com resposta_forms" do - formulario = Formulario.new(turma: turma) - expect(formulario).to respond_to(:resposta_forms) - end - end -end \ No newline at end of file + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/resposta_elem_spec.rb b/spec/models/resposta_elem_spec.rb new file mode 100644 index 0000000000..f466723e9d --- /dev/null +++ b/spec/models/resposta_elem_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe RespostaElem, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/resposta_form_spec.rb b/spec/models/resposta_form_spec.rb new file mode 100644 index 0000000000..16bb6683d4 --- /dev/null +++ b/spec/models/resposta_form_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe RespostaForm, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/turma_spec.rb b/spec/models/turma_spec.rb new file mode 100644 index 0000000000..b7629b1e16 --- /dev/null +++ b/spec/models/turma_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Turma, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/usuario_spec.rb b/spec/models/usuario_spec.rb index 8f1baa9b8b..12591f4841 100644 --- a/spec/models/usuario_spec.rb +++ b/spec/models/usuario_spec.rb @@ -1,166 +1,5 @@ require 'rails_helper' RSpec.describe Usuario, type: :model do - let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } - let(:curso) { Curso.find_or_create_by!(nome: "Engenharia de Software", codigo: "ESW", departamento: departamento) } - - let(:docente_valido) do - Docente.new( - nome: "Professor Teste", - matricula: "doc001", - email: "prof@unb.br", - formacao: "Doutorado", - senha: "Senha123", - senha_confirmation: "Senha123" - ) - end - - context "validações" do - it "é válido com todos os atributos obrigatórios" do - expect(docente_valido).to be_valid - end - - it "não é válido sem nome" do - docente_valido.nome = nil - expect(docente_valido).not_to be_valid - end - - it "não é válido sem matrícula" do - docente_valido.matricula = nil - expect(docente_valido).not_to be_valid - end - - it "não é válido sem email" do - docente_valido.email = nil - expect(docente_valido).not_to be_valid - end - - it "não é válido com matrícula duplicada" do - docente_valido.save! - outro = Docente.new( - nome: "Outro Prof", - matricula: "doc001", - email: "outro@unb.br", - formacao: "Mestrado", - senha: "Senha123", - senha_confirmation: "Senha123" - ) - expect(outro).not_to be_valid - end - - it "não é válido com email duplicado" do - docente_valido.save! - outro = Docente.new( - nome: "Outro Prof", - matricula: "doc002", - email: "prof@unb.br", - formacao: "Mestrado", - senha: "Senha123", - senha_confirmation: "Senha123" - ) - expect(outro).not_to be_valid - end - - it "não é válido com senha menor que 6 caracteres" do - docente_valido.senha = "abc" - docente_valido.senha_confirmation = "abc" - expect(docente_valido).not_to be_valid - end - - it "não é válido quando confirmação de senha não confere" do - docente_valido.senha_confirmation = "outra_senha" - expect(docente_valido).not_to be_valid - end - end - - context "#senha_definida?" do - it "retorna false quando senha_hash está em branco" do - usuario = Docente.new(nome: "X", matricula: "x1", email: "x@x.com", formacao: "Grad") - expect(usuario.senha_definida?).to be false - end - - it "retorna true após definir e salvar uma senha" do - docente_valido.save! - expect(docente_valido.senha_definida?).to be true - end - end - - context "#autenticar_senha" do - before { docente_valido.save! } - - it "retorna true com a senha correta" do - expect(docente_valido.autenticar_senha("Senha123")).to be true - end - - it "retorna false com a senha incorreta" do - expect(docente_valido.autenticar_senha("errada")).to be false - end - - it "retorna false quando senha_hash está em branco" do - usuario = Docente.new(nome: "Y", matricula: "y1", email: "y@y.com", formacao: "Grad") - expect(usuario.autenticar_senha("qualquer")).to be false - end - end - - context "#gerar_definicao_senha_token!" do - before { docente_valido.save! } - - it "preenche definicao_senha_token" do - docente_valido.gerar_definicao_senha_token! - expect(docente_valido.definicao_senha_token).to be_present - end - - it "preenche definicao_senha_sent_at" do - docente_valido.gerar_definicao_senha_token! - expect(docente_valido.definicao_senha_sent_at).to be_present - end - end - - context "#limpar_definicao_senha_token!" do - before do - docente_valido.save! - docente_valido.gerar_definicao_senha_token! - end - - it "apaga definicao_senha_token" do - docente_valido.limpar_definicao_senha_token! - expect(docente_valido.definicao_senha_token).to be_nil - end - - it "apaga definicao_senha_sent_at" do - docente_valido.limpar_definicao_senha_token! - expect(docente_valido.definicao_senha_sent_at).to be_nil - end - end - - context "#gerar_redefinicao_senha_token!" do - before { docente_valido.save! } - - it "preenche redefinicao_senha_token" do - docente_valido.gerar_redefinicao_senha_token! - expect(docente_valido.redefinicao_senha_token).to be_present - end - - it "preenche redefinicao_senha_sent_at" do - docente_valido.gerar_redefinicao_senha_token! - expect(docente_valido.redefinicao_senha_sent_at).to be_present - end - end - - context "#limpar_redefinicao_senha_token!" do - before do - docente_valido.save! - docente_valido.gerar_redefinicao_senha_token! - end - - it "apaga redefinicao_senha_token" do - docente_valido.limpar_redefinicao_senha_token! - expect(docente_valido.redefinicao_senha_token).to be_nil - end - - it "apaga redefinicao_senha_sent_at" do - docente_valido.limpar_redefinicao_senha_token! - expect(docente_valido.redefinicao_senha_sent_at).to be_nil - end - end + pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/requests/formulario_spec.rb b/spec/requests/formulario_spec.rb deleted file mode 100644 index 48c4ce7045..0000000000 --- a/spec/requests/formulario_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'rails_helper' - -RSpec.describe "Formularios", type: :request do - let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } - let(:disciplina) { Disciplina.find_or_create_by!(nome: "Engenharia de Software", codigo: "CIC0097", departamento: departamento) } - let(:turma) { Turma.find_or_create_by!(numero_da_turma: "TA", disciplina: disciplina, semestre: "2026.1") } - - let(:curso) { Curso.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC", departamento: departamento) } - - let(:admin) do - Administrador.create!( - nome: "Admin", matricula: "123", email: "admin@unb.br", - senha: "Senha123", senha_confirmation: "Senha123", departamento: departamento - ) - end - - let(:discente) do - Discente.create!( - nome: "Aluno Teste", matricula: "241000", email: "aluno@unb.br", - curso: curso, # 2. Recebendo a variável em vez da string! - senha: "Senha123", senha_confirmation: "Senha123" - ) - end - - describe "Feature 10: Criar formulário (Admin)" do - before { post login_path, params: { login: admin.email, senha: "Senha123" } } - - it "cria um formulário vinculando à turma" do - expect { - post formularios_path, params: { - formulario: { - turma_id: turma.id - } - } - }.to change(Formulario, :count).by(1) - - expect(response).to be_redirect - end - end - - describe "Feature 11: Visualizar formulários (Participante)" do - let!(:formulario) do - Formulario.create!(turma: turma) - end - - before do - post login_path, params: { login: discente.email, senha: "Senha123" } - end - - it "lista os formulários disponíveis para o aluno" do - get formularios_path - expect(response).to have_http_status(:ok) - end - end -end \ No newline at end of file diff --git a/spec/requests/importacao_sigaa_spec.rb b/spec/requests/importacao_sigaa_spec.rb deleted file mode 100644 index 801e751a76..0000000000 --- a/spec/requests/importacao_sigaa_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'rails_helper' - -RSpec.describe "Importação SIGAA", type: :request do - let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } - let(:admin) do - Administrador.create!( - nome: "Admin", - matricula: "123", - email: "admin@unb.br", - senha: "Senha123", - senha_confirmation: "Senha123", - departamento: departamento - ) - end - - before do - post login_path, params: { login: admin.email, senha: "Senha123" } - end - - describe "POST /admin/:admin_id/sincronizar_sigaa" do - it "importa usuários do JSON com sucesso" do - # Vamos usar o seu class_members.json para simular os dois uploads que o controller exige - json_file = fixture_file_upload(Rails.root.join('class_members.json'), 'application/json') - - # Batendo na rota correta passando o admin_id e os 3 parâmetros que o processar_sincronizacao espera - post admin_sincronizar_sigaa_path(admin_id: admin.id), params: { - acao: "importar", - arquivo_classes: json_file, - arquivo_membros: json_file - } - - # O controller redireciona para a página de gerenciamento do admin, não importa o resultado - expect(response).to redirect_to(admin_gerenciamento_path(admin)) - end - end -end \ No newline at end of file diff --git a/spec/requests/senhas_spec.rb b/spec/requests/senhas_spec.rb deleted file mode 100644 index 29fd178e05..0000000000 --- a/spec/requests/senhas_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'rails_helper' - -RSpec.describe "Gerenciamento de Senhas", type: :request do - let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } - let(:usuario_sem_senha) do - Docente.create!( - nome: "Novo Professor", - matricula: "doc002", - email: "novo@unb.br", - formacao: "Mestrado", - senha_hash: nil, - definicao_senha_token: "token_definicao_123" - ) - end - - let(:usuario_esquecido) do - Docente.create!( - nome: "Professor Esquecido", - matricula: "doc003", - email: "esquecido@unb.br", - formacao: "Doutorado", - senha: "SenhaAntiga123", - senha_confirmation: "SenhaAntiga123", - redefinicao_senha_token: "token_redefinicao_456" - ) - end - - describe "Feature 3: Cadastrar senha (Primeiro Acesso)" do - it "GET /definir_senha/:token acessa a tela de cadastro" do - get edit_definicao_senha_path(token: usuario_sem_senha.definicao_senha_token) - expect(response).to have_http_status(:ok) - end - - it "PATCH /definir_senha/:token define a senha e redireciona para login" do - patch definicao_senha_path(token: usuario_sem_senha.definicao_senha_token), params: { - senha: "NovaSenhaSegura123", - senha_confirmation: "NovaSenhaSegura123" - } - - usuario_sem_senha.reload - expect(usuario_sem_senha.senha_definida?).to be true - - expect(response).to redirect_to(root_path) - end - end - - describe "Feature 4: Redefinir senha" do - it "POST /redefinir_senha solicita a troca e envia email" do - post redefinir_senha_path, params: { email: usuario_esquecido.email } - usuario_esquecido.reload - - expect(usuario_esquecido.redefinicao_senha_token).not_to be_nil - - expect(response).to redirect_to(root_path) - end - - it "PATCH /redefinir_senha/:token salva a nova senha e redireciona" do - patch redefinicao_senha_path(token: usuario_esquecido.redefinicao_senha_token), params: { - senha: "SenhaTotalmenteNova1", - senha_confirmation: "SenhaTotalmenteNova1" - } - - expect(response).to redirect_to(root_path) - end - end -end \ No newline at end of file diff --git a/spec/requests/sessions_spec.rb b/spec/requests/sessions_spec.rb deleted file mode 100644 index 25e5261454..0000000000 --- a/spec/requests/sessions_spec.rb +++ /dev/null @@ -1,125 +0,0 @@ -require 'rails_helper' - -RSpec.describe "Sessions", type: :request do - let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } - - let!(:admin) do - Administrador.create!( - nome: "Admin Teste", - matricula: "adm001", - email: "admin@unb.br", - senha: "Senha123", - senha_confirmation: "Senha123", - departamento: departamento - ) - end - - let!(:docente) do - Docente.create!( - nome: "Prof Teste", - matricula: "doc001", - email: "prof@unb.br", - formacao: "Doutorado", - senha: "Senha123", - senha_confirmation: "Senha123" - ) - end - - describe "GET /" do - context "quando não está logado" do - it "exibe a tela de login" do - get root_path - expect(response).to have_http_status(:ok) - end - end - - context "quando já está logado como Administrador" do - before { post login_path, params: { login: admin.email, senha: "Senha123" } } - - it "redireciona para a página de avaliações do admin" do - get root_path - expect(response).to redirect_to(admin_avaliacoes_path(admin.id)) - end - end - - context "quando já está logado como usuário comum" do - before { post login_path, params: { login: docente.email, senha: "Senha123" } } - - it "redireciona para a página do usuário" do - get root_path - expect(response).to redirect_to(usuarios_avaliacoes_path(docente.id)) - end - end - end - - describe "POST /login" do - context "com credenciais inválidas" do - it "redireciona para root com alerta quando login está em branco" do - post login_path, params: { login: "", senha: "Senha123" } - expect(response).to redirect_to(root_path) - follow_redirect! - expect(response.body).to include("informe seu email ou matrícula") - end - - it "redireciona para root com alerta quando senha está em branco" do - post login_path, params: { login: docente.email, senha: "" } - expect(response).to redirect_to(root_path) - follow_redirect! - expect(response.body).to include("informe a sua senha") - end - - it "redireciona para root com alerta quando usuário não existe" do - post login_path, params: { login: "naoexiste@unb.br", senha: "Senha123" } - expect(response).to redirect_to(root_path) - follow_redirect! - expect(response.body).to include("usuário não encontrado") - end - - it "redireciona para root com alerta quando senha está incorreta" do - post login_path, params: { login: docente.email, senha: "errada" } - expect(response).to redirect_to(root_path) - follow_redirect! - expect(response.body).to include("senha incorreta") - end - end - - context "com credenciais válidas de Administrador" do - it "redireciona para a página de avaliações do admin" do - post login_path, params: { login: admin.email, senha: "Senha123" } - expect(response).to redirect_to(admin_avaliacoes_path(admin.id)) - end - - it "aceita login pela matrícula" do - post login_path, params: { login: admin.matricula, senha: "Senha123" } - expect(response).to redirect_to(admin_avaliacoes_path(admin.id)) - end - end - - context "com credenciais válidas de usuário comum" do - it "redireciona para a página do usuário" do - post login_path, params: { login: docente.email, senha: "Senha123" } - expect(response).to redirect_to(usuarios_avaliacoes_path(docente.id)) - end - - it "aceita login pela matrícula" do - post login_path, params: { login: docente.matricula, senha: "Senha123" } - expect(response).to redirect_to(usuarios_avaliacoes_path(docente.id)) - end - end - end - - describe "DELETE /logout" do - before { post login_path, params: { login: docente.email, senha: "Senha123" } } - - it "redireciona para a raiz" do - delete logout_path - expect(response).to redirect_to(root_path) - end - - it "encerra a sessão e exige novo login para rotas protegidas" do - delete logout_path - get inicio_path - expect(response).to redirect_to(root_path) - end - end -end diff --git a/spec/requests/templates_spec.rb b/spec/requests/templates_spec.rb deleted file mode 100644 index b9f678b730..0000000000 --- a/spec/requests/templates_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'rails_helper' - -RSpec.describe "Templates", type: :request do - let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } - let(:admin) do - Administrador.create!( - nome: "Admin", - matricula: "123", - email: "admin@unb.br", - senha: "Senha123", - senha_confirmation: "Senha123", - departamento: departamento - ) - end - let!(:template_existente) do - template = Template.new(nome: "Template Base", administrador: admin) - template.elementos.build(enunciado: "Questão 1", ordem: 1) - template.save! - template - end - - before do - post login_path, params: { login: admin.email, senha: "Senha123" } - end - - describe "GET /templates" do - it "Feature 6: Visualiza a lista de templates" do - get admin_templates_path(admin_id: admin.id) - expect(response).to have_http_status(:ok) - end - end - - describe "POST /templates" do - it "Feature 5: Cria um template com sucesso" do - expect { - post admin_templates_path(admin_id: admin.id), params: { - template: { - nome: "Avaliação Nova", - administrador_id: admin.id, - elementos_attributes: [ { enunciado: "Questão 1", ordem: 1 } ] - } - } - }.to change(Template, :count).by(1) - expect(response).to be_redirect - end - end - - describe "PATCH /templates/:id" do - it "Feature 7: Edita um template existente" do - patch admin_template_path(admin_id: admin.id, id: template_existente.id), params: { - template: { nome: "Nome Atualizado" } - } - template_existente.reload - expect(template_existente.nome).to eq("Nome Atualizado") - end - end - - describe "DELETE /templates/:id" do - it "Feature 7: Deleta um template" do - expect { - delete admin_template_path(admin_id: admin.id, id: template_existente.id) - }.to change(Template, :count).by(-1) - end - end -end \ No newline at end of file diff --git a/spec/requests/usuarios_spec.rb b/spec/requests/usuarios_spec.rb deleted file mode 100644 index 804d766ac8..0000000000 --- a/spec/requests/usuarios_spec.rb +++ /dev/null @@ -1,118 +0,0 @@ -require 'rails_helper' - -RSpec.describe "Usuarios", type: :request do - let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } - - let!(:admin) do - Administrador.create!( - nome: "Admin Teste", - matricula: "adm001", - email: "admin@unb.br", - senha: "Senha123", - senha_confirmation: "Senha123", - departamento: departamento - ) - end - - let!(:docente) do - Docente.create!( - nome: "Prof Teste", - matricula: "doc001", - email: "prof@unb.br", - formacao: "Doutorado", - senha: "Senha123", - senha_confirmation: "Senha123" - ) - end - - def logar_como(usuario) - post login_path, params: { login: usuario.email, senha: "Senha123" } - end - - describe "GET /usuarios (require_login)" do - context "sem sessão ativa" do - it "redireciona para a tela de login com alerta" do - get usuarios_path - expect(response).to redirect_to(root_path) - follow_redirect! - expect(response.body).to include("precisa estar logado") - end - end - end - - describe "GET /usuarios (require_admin)" do - context "logado como usuário comum" do - before { logar_como(docente) } - - it "redireciona para a página inicial com alerta de acesso negado" do - get usuarios_path - expect(response).to redirect_to(inicio_path) - follow_redirect! - expect(response.body).to include("Acesso negado") - end - end - - context "logado como Administrador" do - before { logar_como(admin) } - - it "permite o acesso" do - get usuarios_path - expect(response).to have_http_status(:ok) - end - end - end - - describe "GET /usuarios/:id" do - context "sem sessão ativa" do - it "redireciona para a tela de login" do - get usuario_path(docente) - expect(response).to redirect_to(root_path) - end - end - - context "logado como usuário comum" do - before { logar_como(docente) } - - it "redireciona para a página inicial" do - get usuario_path(docente) - expect(response).to redirect_to(inicio_path) - end - end - - context "logado como Administrador" do - before { logar_como(admin) } - - it "permite o acesso" do - get usuario_path(docente) - expect(response).to have_http_status(:ok) - end - end - end - - describe "DELETE /usuarios/:id" do - context "sem sessão ativa" do - it "redireciona para a tela de login" do - delete usuario_path(docente) - expect(response).to redirect_to(root_path) - end - end - - context "logado como usuário comum" do - before { logar_como(docente) } - - it "redireciona para a página inicial" do - delete usuario_path(docente) - expect(response).to redirect_to(inicio_path) - end - end - - context "logado como Administrador" do - before { logar_como(admin) } - - it "remove o usuário e redireciona para a listagem" do - delete usuario_path(docente) - expect(response).to redirect_to(usuarios_path) - end - end - end -end