diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..3bbd03ac Binary files /dev/null and b/.DS_Store differ diff --git a/.rake_tasks~ b/.rake_tasks~ new file mode 100644 index 00000000..c00fc44b --- /dev/null +++ b/.rake_tasks~ @@ -0,0 +1,55 @@ +about +active_storage:install +app:template +app:update +assets:clean[keep] +assets:clobber +assets:environment +assets:precompile +cache_digests:dependencies +cache_digests:nested_dependencies +cucumber +cucumber:all +cucumber:ok +cucumber:rerun +cucumber:wip +db:create +db:drop +db:environment:set +db:fixtures:load +db:migrate +db:migrate:status +db:rollback +db:schema:cache:clear +db:schema:cache:dump +db:schema:dump +db:schema:load +db:seed +db:setup +db:structure:dump +db:structure:load +db:version +dev:cache +initializers +log:clear +middleware +notes +notes:custom +restart +routes +secret +spec +spec:controllers +spec:helpers +spec:models +spec:requests +spec:routing +spec:views +stats +test +test:db +test:system +time:zones[country_or_offset] +tmp:clear +tmp:create +yarn:install diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..7f44804c --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 2.6.3 diff --git a/Gemfile b/Gemfile index 54be0f4e..0c45aad4 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,6 @@ group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'rspec-rails' - end group :development do @@ -56,15 +55,23 @@ end group :test do # Adds support for Capybara system testing and selenium driver - gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'webdrivers' gem 'cucumber-rails', require: false + gem 'cucumber-rails-training-wheels' # some pre-fabbed step definitions # database_cleaner is not required, but highly recommended gem 'database_cleaner' + gem 'capybara', '>= 2.15' + gem 'launchy' # a useful debugging aid for user stories gem 'shoulda-matchers' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +# Rails 5.2 and Rails 6 +gem 'active_storage_validations' + +# Optional, to use :dimension validator or :aspect_ratio validator +gem 'mini_magick', '>= 4.9.5' diff --git a/Gemfile.lock b/Gemfile.lock index 0a9e4f86..0e242db3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,43 +1,45 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.3) - actionpack (= 5.2.3) + actioncable (5.2.4.4) + actionpack (= 5.2.4.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) + actionmailer (5.2.4.4) + actionpack (= 5.2.4.4) + actionview (= 5.2.4.4) + activejob (= 5.2.4.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.3) - actionview (= 5.2.3) - activesupport (= 5.2.3) - rack (~> 2.0) + actionpack (5.2.4.4) + actionview (= 5.2.4.4) + activesupport (= 5.2.4.4) + rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.3) - activesupport (= 5.2.3) + actionview (5.2.4.4) + activesupport (= 5.2.4.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.3) - activesupport (= 5.2.3) + active_storage_validations (0.9.0) + rails (>= 5.2.0) + activejob (5.2.4.4) + activesupport (= 5.2.4.4) globalid (>= 0.3.6) - activemodel (5.2.3) - activesupport (= 5.2.3) - activerecord (5.2.3) - activemodel (= 5.2.3) - activesupport (= 5.2.3) + activemodel (5.2.4.4) + activesupport (= 5.2.4.4) + activerecord (5.2.4.4) + activemodel (= 5.2.4.4) + activesupport (= 5.2.4.4) arel (>= 9.0) - activestorage (5.2.3) - actionpack (= 5.2.3) - activerecord (= 5.2.3) + activestorage (5.2.4.4) + actionpack (= 5.2.4.4) + activerecord (= 5.2.4.4) marcel (~> 0.3.1) - activesupport (5.2.3) + activesupport (5.2.4.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -45,14 +47,13 @@ GEM addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) arel (9.0.0) - backports (3.15.0) - bcrypt (3.1.13) + bcrypt (3.1.16) bindex (0.8.1) - bootsnap (1.4.5) + bootsnap (1.5.1) msgpack (~> 1.0) - builder (3.2.3) - byebug (11.0.1) - capybara (3.29.0) + builder (3.2.4) + byebug (11.1.3) + capybara (3.33.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -68,131 +69,160 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.5) - crass (1.0.5) - cucumber (3.1.2) - builder (>= 2.1.2) - cucumber-core (~> 3.2.0) - cucumber-expressions (~> 6.0.1) - cucumber-wire (~> 0.0.1) - diff-lcs (~> 1.3) - gherkin (~> 5.1.0) - multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.1.2) - cucumber-core (3.2.1) - backports (>= 3.8.0) - cucumber-tag_expressions (~> 1.1.0) - gherkin (~> 5.0) - cucumber-expressions (6.0.1) - cucumber-rails (2.0.0) - capybara (>= 2.12, < 4) - cucumber (>= 3.0.2, < 4) - mime-types (>= 2.0, < 4) + concurrent-ruby (1.1.7) + crass (1.0.6) + cucumber (5.2.0) + builder (~> 3.2, >= 3.2.4) + cucumber-core (~> 8.0, >= 8.0.1) + cucumber-create-meta (~> 2.0, >= 2.0.2) + cucumber-cucumber-expressions (~> 10.3, >= 10.3.0) + cucumber-gherkin (~> 15.0, >= 15.0.2) + cucumber-html-formatter (~> 9.0, >= 9.0.0) + cucumber-messages (~> 13.1, >= 13.1.0) + cucumber-wire (~> 4.0, >= 4.0.1) + diff-lcs (~> 1.4, >= 1.4.4) + multi_test (~> 0.1, >= 0.1.2) + sys-uname (~> 1.2, >= 1.2.1) + cucumber-core (8.0.1) + cucumber-gherkin (~> 15.0, >= 15.0.2) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-tag-expressions (~> 2.0, >= 2.0.4) + cucumber-create-meta (2.0.4) + cucumber-messages (~> 13.1, >= 13.1.0) + sys-uname (~> 1.2, >= 1.2.1) + cucumber-cucumber-expressions (10.3.0) + cucumber-gherkin (15.0.2) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-html-formatter (9.0.0) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-messages (13.2.0) + protobuf-cucumber (~> 3.10, >= 3.10.8) + cucumber-rails (2.2.0) + capybara (>= 2.18, < 4) + cucumber (>= 3.0.2, < 6) + mime-types (~> 3.2) nokogiri (~> 1.8) - railties (>= 4.2, < 7) - cucumber-tag_expressions (1.1.1) - cucumber-wire (0.0.1) - database_cleaner (1.7.0) - devise (4.7.1) + rails (>= 5.0, < 7) + cucumber-rails-training-wheels (1.0.0) + cucumber-rails (>= 1.1.1) + cucumber-tag-expressions (2.0.4) + cucumber-wire (4.0.1) + cucumber-core (~> 8.0, >= 8.0.1) + cucumber-cucumber-expressions (~> 10.3, >= 10.3.0) + cucumber-messages (~> 13.0, >= 13.0.1) + database_cleaner (1.8.5) + devise (4.7.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - diff-lcs (1.3) - erubi (1.9.0) + diff-lcs (1.4.4) + erubi (1.10.0) execjs (2.7.0) - ffi (1.11.1) - gherkin (5.1.0) + ffi (1.13.1) + ffi (1.13.1-x64-mingw32) globalid (0.4.2) activesupport (>= 4.2.0) - i18n (1.7.0) + i18n (1.8.5) concurrent-ruby (~> 1.0) - jbuilder (2.9.1) - activesupport (>= 4.2.0) + jbuilder (2.10.1) + activesupport (>= 5.0.0) + launchy (2.5.0) + addressable (~> 2.7) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - loofah (2.3.1) + loofah (2.7.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) marcel (0.3.3) mimemagic (~> 0.3.2) - method_source (0.9.2) - mime-types (3.3) + method_source (1.0.0) + middleware (0.1.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2019.1009) - mimemagic (0.3.3) + mime-types-data (3.2020.1104) + mimemagic (0.3.5) + mini_magick (4.11.0) mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.12.2) - msgpack (1.3.1) - multi_json (1.14.1) + minitest (5.14.2) + msgpack (1.3.3) + msgpack (1.3.3-x64-mingw32) multi_test (0.1.2) - nio4r (2.5.2) - nokogiri (1.10.8) + nio4r (2.5.4) + nokogiri (1.10.10) + mini_portile2 (~> 2.4.0) + nokogiri (1.10.10-x64-mingw32) mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) - pg (1.1.4) - public_suffix (4.0.1) + pg (1.2.3) + pg (1.2.3-x64-mingw32) + protobuf-cucumber (3.10.8) + activesupport (>= 3.2) + middleware + thor + thread_safe + public_suffix (4.0.6) puma (3.12.6) rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.3) - actioncable (= 5.2.3) - actionmailer (= 5.2.3) - actionpack (= 5.2.3) - actionview (= 5.2.3) - activejob (= 5.2.3) - activemodel (= 5.2.3) - activerecord (= 5.2.3) - activestorage (= 5.2.3) - activesupport (= 5.2.3) + rails (5.2.4.4) + actioncable (= 5.2.4.4) + actionmailer (= 5.2.4.4) + actionpack (= 5.2.4.4) + actionview (= 5.2.4.4) + activejob (= 5.2.4.4) + activemodel (= 5.2.4.4) + activerecord (= 5.2.4.4) + activestorage (= 5.2.4.4) + activesupport (= 5.2.4.4) bundler (>= 1.3.0) - railties (= 5.2.3) + railties (= 5.2.4.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - railties (5.2.3) - actionpack (= 5.2.3) - activesupport (= 5.2.3) + railties (5.2.4.4) + actionpack (= 5.2.4.4) + activesupport (= 5.2.4.4) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) - rake (13.0.0) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rake (13.0.1) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (1.6.0) - responders (3.0.0) + regexp_parser (1.8.2) + responders (3.0.1) actionpack (>= 5.0) railties (>= 5.0) - rspec-core (3.9.0) - rspec-support (~> 3.9.0) - rspec-expectations (3.9.0) + rspec-core (3.10.0) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.0) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-rails (3.9.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.0) + rspec-support (~> 3.10.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.10.0) ruby_dep (1.5.0) - rubyzip (2.0.0) + rubyzip (2.3.0) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -204,44 +234,48 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - selenium-webdriver (3.142.6) + selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - shoulda-matchers (4.1.2) + shoulda-matchers (4.4.1) activesupport (>= 4.2.0) - spring (2.1.0) + spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - thor (0.20.3) + sys-uname (1.2.2) + ffi (~> 1.1) + thor (1.0.1) thread_safe (0.3.6) tilt (2.0.10) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) - tzinfo (1.2.5) + tzinfo (1.2.8) thread_safe (~> 0.1) + tzinfo-data (1.2020.4) + tzinfo (>= 1.0.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - warden (1.2.8) - rack (>= 2.0.6) + warden (1.2.9) + rack (>= 2.0.9) web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - webdrivers (4.1.3) + webdrivers (4.4.1) nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) - websocket-driver (0.7.1) + websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) @@ -249,17 +283,22 @@ GEM PLATFORMS ruby + x64-mingw32 DEPENDENCIES + active_storage_validations bootsnap (>= 1.1.0) byebug capybara (>= 2.15) coffee-rails (~> 4.2) cucumber-rails + cucumber-rails-training-wheels database_cleaner devise jbuilder (~> 2.5) + launchy listen (>= 3.0.5, < 3.2) + mini_magick (>= 4.9.5) pg (>= 0.18, < 2.0) puma (~> 3.12) rails (~> 5.2.3) diff --git a/app/assets/javascripts/accreditations.coffee b/app/assets/javascripts/accreditations.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/accreditations.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/requirements.coffee b/app/assets/javascripts/requirements.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/requirements.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/sei_processes.coffee b/app/assets/javascripts/sei_processes.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/sei_processes.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/accreditations.scss b/app/assets/stylesheets/accreditations.scss new file mode 100644 index 00000000..5c7ed1fa --- /dev/null +++ b/app/assets/stylesheets/accreditations.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Accreditations controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/requirements.scss b/app/assets/stylesheets/requirements.scss new file mode 100644 index 00000000..911f2332 --- /dev/null +++ b/app/assets/stylesheets/requirements.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Requirements controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss new file mode 100644 index 00000000..60451880 --- /dev/null +++ b/app/assets/stylesheets/scaffolds.scss @@ -0,0 +1,84 @@ +body { + background-color: #fff; + color: #333; + margin: 33px; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + + &:visited { + color: #666; + } + + &:hover { + color: #fff; + background-color: #000; + } +} + +th { + padding-bottom: 5px; +} + +td { + padding: 0 5px 7px; +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px 7px 0; + margin-bottom: 20px; + background-color: #f0f0f0; + + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px -7px 0; + background-color: #c00; + color: #fff; + } + + ul li { + font-size: 12px; + list-style: square; + } +} + +label { + display: block; +} diff --git a/app/assets/stylesheets/sei_processes.scss b/app/assets/stylesheets/sei_processes.scss new file mode 100644 index 00000000..d0b190c0 --- /dev/null +++ b/app/assets/stylesheets/sei_processes.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the SeiProcesses controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/accreditations_controller.rb b/app/controllers/accreditations_controller.rb new file mode 100644 index 00000000..54e31ebc --- /dev/null +++ b/app/controllers/accreditations_controller.rb @@ -0,0 +1,73 @@ +class AccreditationsController < ApplicationController + before_action :set_accreditation, only: [:show, :edit, :update, :destroy] + + # GET /accreditations + # GET /accreditations.json + def index + @accreditations = Accreditation.all + end + + # GET /accreditations/1 + # GET /accreditations/1.json + def show + end + + # GET /accreditations/new + def new + end + + # GET /accreditations/1/edit + def edit + end + + # POST /accreditations + # POST /accreditations.json + def create + @accreditation = Accreditation.new(accreditation_params) + + respond_to do |format| + if @accreditation.save + format.html { redirect_to accreditations_url, notice: 'Accreditation was successfully created.' } + format.json { render :show, status: :created, location: @accreditation } + else + format.html { render :new } + format.json { render json: @accreditation.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /accreditations/1 + # PATCH/PUT /accreditations/1.json + def update + respond_to do |format| + if @accreditation.update(accreditation_params) + format.html { redirect_to accreditations_url, notice: 'Credenciamento atualizado com sucesso!' } + format.json { render :show, status: :ok, location: @accreditation } + else + format.html { render :edit } + format.json { render json: @accreditation.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /accreditations/1 + # DELETE /accreditations/1.json + def destroy + @accreditation.destroy + respond_to do |format| + format.html { redirect_to accreditations_url, notice: 'Accreditation was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_accreditation + @accreditation = Accreditation.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def accreditation_params + params.require(:accreditation).permit(:user_id, :start_date, :end_date, :sei_proccess_id) + end +end diff --git a/app/controllers/requirements_controller.rb b/app/controllers/requirements_controller.rb new file mode 100644 index 00000000..fbe65d66 --- /dev/null +++ b/app/controllers/requirements_controller.rb @@ -0,0 +1,81 @@ +class RequirementsController < ApplicationController + before_action :set_requirement, only: [:show, :edit, :update, :destroy] + + # GET /requirements + # GET /requirements.json + def index + @requirements = Requirement.all + end + + # GET /requirements/1 + # GET /requirements/1.json + def show + end + + # GET /requirements/new + def new + @requirement = Requirement.new + end + + # GET /requirements/1/edit + def edit + end + + # POST /requirements + # POST /requirements.json + def create + @requirement = Requirement.new(requirement_params) + + respond_to do |format| + if @requirement.save + format.html { redirect_to @requirement, notice: 'Requisitos criados com sucesso!' } + format.json { render :show, status: :created, location: @requirement } + else + format.html { render :new } + format.json { render json: @requirement.errors, status: :unprocessable_entity } + end + end + end + + def delete_document_attachment + @document = ActiveStorage::Attachment.find_by(id: params[:id]) + @requirement_id = params[:requirement_id] + @document&.purge + redirect_to edit_requirement_path(@requirement_id) + end + + # PATCH/PUT /requirements/1 + # PATCH/PUT /requirements/1.json + def update + respond_to do |format| + if @requirement.update(requirement_params) + format.html { redirect_to @requirement, notice: 'Requisitos atualizados com sucesso!' } + format.json { render :show, status: :ok, location: @requirement } + else + format.html { render :edit } + format.json { render json: @requirement.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /requirements/1 + # DELETE /requirements/1.json + def destroy + @requirement.destroy + respond_to do |format| + format.html { redirect_to requirements_url, notice: 'Requisitos excluídos com sucesso!' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_requirement + @requirement = Requirement.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def requirement_params + params.require(:requirement).permit(:title, :content, documents: []) + end +end diff --git a/app/controllers/sei_processes_controller.rb b/app/controllers/sei_processes_controller.rb new file mode 100644 index 00000000..3accd0e4 --- /dev/null +++ b/app/controllers/sei_processes_controller.rb @@ -0,0 +1,89 @@ +class SeiProcessesController < ApplicationController + before_action :set_sei_process, only: [:show, :edit, :update, :destroy] + + # GET /sei_processes + # GET /sei_processes.json + def index + @all_statuses = %w[Espera Aprovado Rejeitado] + + session[:statuses] = params[:statuses] || session[:statuses] || @all_statuses.zip([]).to_h + @status_filter = session[:statuses].keys + + if current_user.role == "administrator" + @sei_processes = SeiProcess.where(status: @status_filter) + else + @my_processes = SeiProcess.where(user_id: current_user.id, status: @status_filter) + end + end + + # GET /sei_processes/1 + # GET /sei_processes/1.json + def show + end + + # GET /sei_processes/new + def new + @requirements = Requirement.find_by(title: 'Requisitos de Credenciamento') + @sei_process = SeiProcess.new(user_id: current_user.id, status: 'Espera', code: '0') + end + + # GET /sei_processes/1/edit + def edit + end + + # POST /sei_processes + # POST /sei_processes.json + def create + @sei_process = SeiProcess.new(sei_process_params) + + respond_to do |format| + if @sei_process.save + format.html { redirect_to sei_processes_url, notice: 'Processo aberto com sucesso!' } + format.json { render :index, status: :created, location: @sei_process } + else + format.html { render :new } + format.json { render json: @sei_process.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /sei_processes/1 + # PATCH/PUT /sei_processes/1.json + def update + respond_to do |format| + if @sei_process.update(sei_process_params) + format.html { redirect_to sei_processes_url, notice: 'Processo atualizado com sucesso!' } + format.json { render :index, status: :ok, location: @sei_process } + + if (@sei_process.status == 'Aprovado') && @sei_process.documents.attached? + Accreditation.create!(user_id: @sei_process.user_id, sei_process_id: @sei_process.id) + end + + else + format.html { render :edit } + format.json { render json: @sei_process.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /sei_processes/1 + # DELETE /sei_processes/1.json + def destroy + @sei_process.destroy + respond_to do |format| + format.html { redirect_to sei_processes_url, notice: 'Processo excluído com sucesso!' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_sei_process + @sei_process = SeiProcess.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def sei_process_params + params.require(:sei_process).permit(:user_id, :status, :code, documents: []) + end +end diff --git a/app/helpers/accreditations_helper.rb b/app/helpers/accreditations_helper.rb new file mode 100644 index 00000000..ad946900 --- /dev/null +++ b/app/helpers/accreditations_helper.rb @@ -0,0 +1,2 @@ +module AccreditationsHelper +end diff --git a/app/helpers/requirements_helper.rb b/app/helpers/requirements_helper.rb new file mode 100644 index 00000000..377e5e33 --- /dev/null +++ b/app/helpers/requirements_helper.rb @@ -0,0 +1,2 @@ +module RequirementsHelper +end diff --git a/app/helpers/sei_processes_helper.rb b/app/helpers/sei_processes_helper.rb new file mode 100644 index 00000000..c74ddc6e --- /dev/null +++ b/app/helpers/sei_processes_helper.rb @@ -0,0 +1,2 @@ +module SeiProcessesHelper +end diff --git a/app/models/accreditation.rb b/app/models/accreditation.rb new file mode 100644 index 00000000..df0d1da3 --- /dev/null +++ b/app/models/accreditation.rb @@ -0,0 +1,13 @@ +class Accreditation < ApplicationRecord + belongs_to :user + belongs_to :sei_process + + validate :check_date, on: :update + def check_date + if (end_date == nil) || (end_date < start_date) + self.errors.add(:end_date, 'Data inválida') + return false + end + true + end +end diff --git a/app/models/requirement.rb b/app/models/requirement.rb new file mode 100644 index 00000000..98106d97 --- /dev/null +++ b/app/models/requirement.rb @@ -0,0 +1,4 @@ +class Requirement < ApplicationRecord + validates :title, presence: true, uniqueness: true + has_many_attached :documents +end diff --git a/app/models/sei_process.rb b/app/models/sei_process.rb new file mode 100644 index 00000000..ec8776c8 --- /dev/null +++ b/app/models/sei_process.rb @@ -0,0 +1,11 @@ +class SeiProcess < ApplicationRecord + belongs_to :user + has_many_attached :documents + validates :documents, attached: true + + enum status: { + Espera: 0, + Aprovado: 1, + Rejeitado: 2 + } +end diff --git a/app/views/accreditations/_accreditation.json.jbuilder b/app/views/accreditations/_accreditation.json.jbuilder new file mode 100644 index 00000000..3e22c1cd --- /dev/null +++ b/app/views/accreditations/_accreditation.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! accreditation, :id, :user_id, :start_date, :end_date, :sei_process_id, :created_at, :updated_at +json.url accreditation_url(accreditation, format: :json) diff --git a/app/views/accreditations/_form_edit.html.erb b/app/views/accreditations/_form_edit.html.erb new file mode 100644 index 00000000..aa1b6c0f --- /dev/null +++ b/app/views/accreditations/_form_edit.html.erb @@ -0,0 +1,27 @@ +<%= form_with(model: accreditation, local: true) do |form| %> + <% if accreditation.errors.any? %> +
+

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

+ + +
+ <% end %> + +
+ <%= form.label :start_date, "Data inicial" %> + <%= form.date_field :start_date, value: Date.current %> +
+ +
+ <%= form.label :end_date, "Data final" %> + <%= form.date_field :end_date %> +
+ +
+ <%= form.submit "Salvar" %> +
+<% end %> \ No newline at end of file diff --git a/app/views/accreditations/edit.html.erb b/app/views/accreditations/edit.html.erb new file mode 100644 index 00000000..81a27cdf --- /dev/null +++ b/app/views/accreditations/edit.html.erb @@ -0,0 +1,31 @@ +

Definir Prazo de Credenciamento

+ +

+ Código do Processo SEI: + <%= @accreditation.sei_process_id %> +

+

+ Nome: + <%= @accreditation.user.full_name %> +

+

+ Matrícula: + <%= @accreditation.user.registration %> +

+ +<% if @accreditation.sei_process.documents.attached? %> +

+ Documentos anexados: + <% @accreditation.sei_process.documents.each do | document | %> +

+ <%= link_to document.filename, rails_blob_path(document, disposition: 'attachment') %> +
+ <% end %> +

+<% end %> +
+ +<%= render 'form_edit', accreditation: @accreditation %> + +<%= link_to 'Mostrar', @accreditation %> | +<%= link_to 'Voltar', accreditations_path %> diff --git a/app/views/accreditations/index.html.erb b/app/views/accreditations/index.html.erb new file mode 100644 index 00000000..e8a7a3a2 --- /dev/null +++ b/app/views/accreditations/index.html.erb @@ -0,0 +1,36 @@ +

+ +

Credenciamentos

+ + + + + + + + + + + + + + + <% @accreditations.each do |accreditation| %> + + + + + + + <% if accreditation.start_date != nil && accreditation.end_date != nil %> + + <% else %> + + <% end %> + + <% end %> + +
NomeMatrículaCódigo SEIData de InícioData de Fim
<%= accreditation.user.full_name %><%= accreditation.user.registration %><%= accreditation.sei_process_id %><%= accreditation.start_date %><%= accreditation.end_date %><%= link_to 'Mostrar', accreditation %><%= link_to 'Definir Prazo', edit_accreditation_path(accreditation) %>
+ +
+<%= link_to 'Página Inicial', home_index_path %> diff --git a/app/views/accreditations/index.json.jbuilder b/app/views/accreditations/index.json.jbuilder new file mode 100644 index 00000000..d4cbce83 --- /dev/null +++ b/app/views/accreditations/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @accreditations, partial: "accreditations/accreditation", as: :accreditation diff --git a/app/views/accreditations/show.html.erb b/app/views/accreditations/show.html.erb new file mode 100644 index 00000000..83e41451 --- /dev/null +++ b/app/views/accreditations/show.html.erb @@ -0,0 +1,39 @@ +

+ +

Credenciamento

+ +

+ Código do Processo SEI: + <%= @accreditation.sei_process_id %> +

+

+ Nome: + <%= @accreditation.user.full_name %> +

+

+ Matrícula: + <%= @accreditation.user.registration %> +

+

+ Data de Início: + <%= @accreditation.start_date %> +

+

+ Data de Fim: + <%= @accreditation.end_date %> +

+ +<% if @accreditation.sei_process.documents.attached? %> +

+ Documentos anexados: + <% @accreditation.sei_process.documents.each do | document | %> +

+ <%= link_to document.filename, rails_blob_path(document, disposition: 'attachment') %> +
+ <% end %> +

+<% end %> +
+ +<%= link_to 'Editar', edit_accreditation_path(@accreditation) %> | +<%= link_to 'Voltar', accreditations_path %> diff --git a/app/views/accreditations/show.json.jbuilder b/app/views/accreditations/show.json.jbuilder new file mode 100644 index 00000000..59641fd3 --- /dev/null +++ b/app/views/accreditations/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "accreditations/accreditation", accreditation: @accreditation diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 33ba387d..24d2b84e 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,12 +1,23 @@ -

Home#index

-

Find me in app/views/home/index.html.erb

+

Início

<% if user_signed_in? %>

Usuário atual

Nome: <%= current_user.full_name %>

Email: <%= current_user.email %>

Cargo: <%= current_user.role %>

- <%= link_to "Sair", destroy_user_session_path, method: :delete %> + + <% if current_user.role == "administrator" %> + <%= link_to "Lista de Requisitos", requirements_path %> + <%= link_to "Lista de Processos", sei_processes_path %> + <%= link_to "Lista de Credenciamentos", accreditations_path %> + + <% else %> + <%= link_to "Meus Processos Abertos", sei_processes_path %> + <% end %> + +
+ <%= link_to "Sair", destroy_user_session_path, method: :delete %> + <% else %>

Entre para acessar o sistema!

Você também pode se registrar ou pegar uma conta no arquivo db/seeds.rb

diff --git a/app/views/requirements/_form_edit.html.erb b/app/views/requirements/_form_edit.html.erb new file mode 100644 index 00000000..95a4d603 --- /dev/null +++ b/app/views/requirements/_form_edit.html.erb @@ -0,0 +1,46 @@ +<%= form_with(model: requirement, local: true) do |form| %> + <% if requirement.errors.any? %> +
+

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

+ +
    + <% requirement.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :title, "Título" %> + <%= form.text_field :title %> +
+ +
+ <%= form.label :content, "Conteúdo" %> + <%= form.text_area :content %> +
+ + <% if @requirement.documents.attached? %> +
Documentos anexados:
+ <% @requirement.documents.each do | document | %> +
+ <%= link_to document.filename, rails_blob_path(document, disposition: 'attachment') %> + <%= link_to 'Remover', delete_document_attachment_requirement_url(document.id, requirement_id: @requirement.id), + method: :delete, + data: { } + %> +
+ <% end %> + <% end %> +
+ +
+ <%= form.label :documents, "Documentos" %> + <%= form.file_field :documents, multiple: true %> +
+ +
+ <%= form.submit "Salvar" %> +
+<% end %> diff --git a/app/views/requirements/_form_new.html.erb b/app/views/requirements/_form_new.html.erb new file mode 100644 index 00000000..4fdb5112 --- /dev/null +++ b/app/views/requirements/_form_new.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: requirement, local: true) do |form| %> + <% if requirement.errors.any? %> +
+

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

+ +
    + <% requirement.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :title, "Título" %> + <%= form.text_field :title %> +
+ +
+ <%= form.label :content, "Conteúdo" %> + <%= form.text_area :content %> +
+ +
+ <%= form.label :documents, "Documentos" %> + <%= form.file_field :documents, multiple: true %> +
+ +
+ <%= form.submit "Enviar" %> +
+<% end %> diff --git a/app/views/requirements/_requirement.json.jbuilder b/app/views/requirements/_requirement.json.jbuilder new file mode 100644 index 00000000..1fb3b1c7 --- /dev/null +++ b/app/views/requirements/_requirement.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! requirement, :id, :title, :content, :created_at, :updated_at +json.url requirement_url(requirement, format: :json) diff --git a/app/views/requirements/edit.html.erb b/app/views/requirements/edit.html.erb new file mode 100644 index 00000000..1e0ff4ca --- /dev/null +++ b/app/views/requirements/edit.html.erb @@ -0,0 +1,6 @@ +

Editar Requisitos

+ +<%= render 'form_edit', requirement: @requirement %> + +<%= link_to 'Mostrar', @requirement %> | +<%= link_to 'Voltar', requirements_path %> diff --git a/app/views/requirements/index.html.erb b/app/views/requirements/index.html.erb new file mode 100644 index 00000000..d11e2de3 --- /dev/null +++ b/app/views/requirements/index.html.erb @@ -0,0 +1,28 @@ +

+ +

Informações de Requisitos

+ + + + + + + + + + + <% @requirements.each do |requirement| %> + + + + + + + <% end %> + +
Tipo de Requisito
<%= requirement.title %><%= link_to 'Mostrar', requirement %><%= link_to 'Editar', edit_requirement_path(requirement) %><%= link_to 'Excluir', requirement, method: :delete, data: { confirm: 'Tem certeza que deseja excluir essa Informação?' } %>
+ +
+<%= link_to 'Adicionar Informação de Requisitos', new_requirement_path %> +
+<%= link_to 'Página Inicial', home_index_path %> diff --git a/app/views/requirements/index.json.jbuilder b/app/views/requirements/index.json.jbuilder new file mode 100644 index 00000000..eb67c381 --- /dev/null +++ b/app/views/requirements/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @requirements, partial: "requirements/requirement", as: :requirement diff --git a/app/views/requirements/new.html.erb b/app/views/requirements/new.html.erb new file mode 100644 index 00000000..ad004d74 --- /dev/null +++ b/app/views/requirements/new.html.erb @@ -0,0 +1,5 @@ +

Nova Informação de Requisitos

+ +<%= render 'form_new', requirement: @requirement %> + +<%= link_to 'Voltar', requirements_path %> diff --git a/app/views/requirements/show.html.erb b/app/views/requirements/show.html.erb new file mode 100644 index 00000000..cec4f83b --- /dev/null +++ b/app/views/requirements/show.html.erb @@ -0,0 +1,25 @@ +

+ +

+ Tipo dos Requisitos: + <%= @requirement.title %> +

+ +

+ Conteúdo: + <%= @requirement.content %> +

+ +<% if @requirement.documents.attached? %> +

+ Documentos anexados + <% @requirement.documents.each do |document| %> +

+ <%= link_to document.filename, rails_blob_path(document, disposition: 'attachment') %> +
+ <% end %> +

+<% end %> + +<%= link_to 'Editar', edit_requirement_path(@requirement) %> | +<%= link_to 'Voltar', requirements_path %> diff --git a/app/views/requirements/show.json.jbuilder b/app/views/requirements/show.json.jbuilder new file mode 100644 index 00000000..1fba56ef --- /dev/null +++ b/app/views/requirements/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "requirements/requirement", requirement: @requirement diff --git a/app/views/sei_processes/_form_edit.html.erb b/app/views/sei_processes/_form_edit.html.erb new file mode 100644 index 00000000..26dbe0a2 --- /dev/null +++ b/app/views/sei_processes/_form_edit.html.erb @@ -0,0 +1,23 @@ +<%= form_with(model: sei_process, local: true) do |form| %> + <% if sei_process.errors.any? %> +
+

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

+ +
    + <% sei_process.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.label :status, "Avaliar" %> + <%= form.radio_button :status, 'Aprovado', id: 'Aprovado', :checked => true %> Aprovado + <%= form.radio_button :status, 'Rejeitado', id: 'Rejeitado' %> Rejeitado +
+ +
+ <%= form.submit "Enviar" %> +
+<% end %> diff --git a/app/views/sei_processes/_form_new.html.erb b/app/views/sei_processes/_form_new.html.erb new file mode 100644 index 00000000..476bfb59 --- /dev/null +++ b/app/views/sei_processes/_form_new.html.erb @@ -0,0 +1,34 @@ +<%= form_with(model: sei_process, local: true) do |form| %> + <% if sei_process.errors.any? %> +
+

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

+ +
    + <% sei_process.errors.full_messages.each do |message| %> +
  • <%= message %>
  • + <% end %> +
+
+ <% end %> + +
+ <%= form.hidden_field :user_id %> +
+ +
+ <%= form.hidden_field :status %> +
+ +
+ <%= form.hidden_field :code %> +
+ +
+ <%= form.label :documents, "Documentos" %> + <%= form.file_field :documents, multiple: true %> +
+ +
+ <%= form.submit "Enviar" %> +
+<% end %> diff --git a/app/views/sei_processes/_sei_process.json.jbuilder b/app/views/sei_processes/_sei_process.json.jbuilder new file mode 100644 index 00000000..5a74a2cc --- /dev/null +++ b/app/views/sei_processes/_sei_process.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! sei_process, :id, :user_id, :status, :code, :created_at, :updated_at +json.url sei_process_url(sei_process, format: :json) diff --git a/app/views/sei_processes/edit.html.erb b/app/views/sei_processes/edit.html.erb new file mode 100644 index 00000000..892f934d --- /dev/null +++ b/app/views/sei_processes/edit.html.erb @@ -0,0 +1,25 @@ +

<%= "Processo #{@sei_process.id}" %>

+ +

+ Nome: + <%= @sei_process.user.full_name %> +

+

+ Matrícula: + <%= @sei_process.user.registration %> +

+ +<% if @sei_process.documents.attached? %> +

+ Documentos anexados: + <% @sei_process.documents.each do | document | %> +

+ <%= link_to document.filename, rails_blob_path(document, disposition: 'attachment') %> +
+ <% end %> +

+<% end %> + +<%= render 'form_edit', sei_process: @sei_process %> + +<%= link_to 'Voltar', sei_processes_path %> diff --git a/app/views/sei_processes/index.html.erb b/app/views/sei_processes/index.html.erb new file mode 100644 index 00000000..c09b65bc --- /dev/null +++ b/app/views/sei_processes/index.html.erb @@ -0,0 +1,67 @@ +

+ +

SEI Processos

+ +<%= form_tag sei_processes_path, :method => :get, id: 'statuses_form' do %> + <% @all_statuses.each do |status| %> + <%= check_box_tag "statuses[#{status}]", 'yes', @status_filter.include?(status), id: "statuses_#{status}" %> + <%= status %> + <% end %> + <%= submit_tag "Atualizar", id: 'statuses_submit' %> +<% end %> +
+ +<% if current_user.role == "administrator" %> + + + + + + + + + + + + + <% @sei_processes.each do |sei_process| %> + + + + + + <% if sei_process.status != 'Espera' %> + + <% else %> + + <% end %> + + <% end %> + +
NomeMatrículaCódigo do ProcessoStatus
<%= sei_process.user.full_name %><%= sei_process.user.registration %><%= sei_process.id %><%= sei_process.status %><%= link_to 'Mostrar', sei_process_path(sei_process) %><%= link_to 'Avaliar', edit_sei_process_path(sei_process) %>
+ +<% else %> + + + + + + + + + + + <% @my_processes.each do |sei_process| %> + + + + + <% end %> + +
Código do ProcessoStatus
<%= sei_process.id %><%= sei_process.status %>
+<% end %> + +
+<%= link_to 'Abrir Novo Processo', new_sei_process_path %> +
+<%= link_to 'Página Inicial', home_index_path %> diff --git a/app/views/sei_processes/index.json.jbuilder b/app/views/sei_processes/index.json.jbuilder new file mode 100644 index 00000000..a270b389 --- /dev/null +++ b/app/views/sei_processes/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @sei_processes, partial: "sei_processes/sei_process", as: :sei_process diff --git a/app/views/sei_processes/new.html.erb b/app/views/sei_processes/new.html.erb new file mode 100644 index 00000000..d2a98d86 --- /dev/null +++ b/app/views/sei_processes/new.html.erb @@ -0,0 +1,21 @@ +

Abrir Processo

+ +<% if @requirements != nil %> +

<%= @requirements.title %>

+ <%= @requirements.content %> + + <% if @requirements.documents.attached? %> +

+ Documentos Necessários: + <% @requirements.documents.each do | document | %> +

+ <%= link_to document.filename, rails_blob_path(document, disposition: 'attachment') %> +
+ <% end %> +

+ <% end %> +<% end %> + +<%= render 'form_new', sei_process: @sei_process %> + +<%= link_to 'Voltar', sei_processes_path %> diff --git a/app/views/sei_processes/show.html.erb b/app/views/sei_processes/show.html.erb new file mode 100644 index 00000000..6dc27079 --- /dev/null +++ b/app/views/sei_processes/show.html.erb @@ -0,0 +1,28 @@ +

<%= "Processo #{@sei_process.id}" %>

+ +

+ Nome: + <%= @sei_process.user.full_name %> +

+

+ Matrícula: + <%= @sei_process.user.registration %> +

+ +<% if @sei_process.documents.attached? %> +

+ Documentos anexados: + <% @sei_process.documents.each do | document | %> +

+ <%= link_to document.filename, rails_blob_path(document, disposition: 'attachment') %> +
+ <% end %> +

+<% end %> + +

+ Status: + <%= @sei_process.status %> +

+ +<%= link_to 'Voltar', sei_processes_path %> diff --git a/app/views/sei_processes/show.json.jbuilder b/app/views/sei_processes/show.json.jbuilder new file mode 100644 index 00000000..7a81fbf8 --- /dev/null +++ b/app/views/sei_processes/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "sei_processes/sei_process", sei_process: @sei_process diff --git a/config/database.yml b/config/database.yml index bbc24623..9930ddf5 100644 --- a/config/database.yml +++ b/config/database.yml @@ -82,4 +82,4 @@ production: <<: *default database: secretaria_ppgi_production username: secretaria_ppgi - password: <%= ENV['SECRETARIA_PPGI_DATABASE_PASSWORD'] %> + password: <%= ENV['SECRETARIA_PPGI_DATABASE_PASSWORD'] %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f33f7f68..e0f4a3df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,15 @@ # frozen_string_literal: true Rails.application.routes.draw do + resources :accreditations + resources :sei_processes + + resources :requirements do + member do + delete :delete_document_attachment + end + end + get 'home/index' devise_for :users # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html diff --git a/cucumber.yaml b/cucumber.yaml new file mode 100644 index 00000000..2a5fdc5d --- /dev/null +++ b/cucumber.yaml @@ -0,0 +1,6 @@ +--- +default: -p html -p bdd -p json +html: --format html --out=features.html +dot: --format progress +bdd: --format pretty +json: --format json -o "report.json" diff --git a/db/migrate/20201113221041_create_requirements.rb b/db/migrate/20201113221041_create_requirements.rb new file mode 100644 index 00000000..bb94ff67 --- /dev/null +++ b/db/migrate/20201113221041_create_requirements.rb @@ -0,0 +1,10 @@ +class CreateRequirements < ActiveRecord::Migration[5.2] + def change + create_table :requirements do |t| + t.string :title + t.text :content + + t.timestamps + end + end +end diff --git a/db/migrate/20201113222004_create_sei_processes.rb b/db/migrate/20201113222004_create_sei_processes.rb new file mode 100644 index 00000000..35886acf --- /dev/null +++ b/db/migrate/20201113222004_create_sei_processes.rb @@ -0,0 +1,11 @@ +class CreateSeiProcesses < ActiveRecord::Migration[5.2] + def change + create_table :sei_processes do |t| + t.belongs_to :user, foreign_key: true + t.integer :status + t.string :code + + t.timestamps + end + end +end diff --git a/db/migrate/20201113222556_create_active_storage_tables.active_storage.rb b/db/migrate/20201113222556_create_active_storage_tables.active_storage.rb new file mode 100644 index 00000000..0b2ce257 --- /dev/null +++ b/db/migrate/20201113222556_create_active_storage_tables.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20170806125915) +class CreateActiveStorageTables < ActiveRecord::Migration[5.2] + def change + create_table :active_storage_blobs do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.bigint :byte_size, null: false + t.string :checksum, null: false + t.datetime :created_at, null: false + + t.index [ :key ], unique: true + end + + create_table :active_storage_attachments do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false + t.references :blob, null: false + + t.datetime :created_at, null: false + + t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end +end diff --git a/db/migrate/20201114202425_create_accreditations.rb b/db/migrate/20201114202425_create_accreditations.rb new file mode 100644 index 00000000..7de196f9 --- /dev/null +++ b/db/migrate/20201114202425_create_accreditations.rb @@ -0,0 +1,12 @@ +class CreateAccreditations < ActiveRecord::Migration[5.2] + def change + create_table :accreditations do |t| + t.belongs_to :user, foreign_key: true + t.date :start_date + t.date :end_date + t.references :sei_process, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 96d61d72..f4d4f7ca 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,11 +10,59 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2019_11_14_163205) do +ActiveRecord::Schema.define(version: 2020_11_14_202425) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "accreditations", force: :cascade do |t| + t.bigint "user_id" + t.date "start_date" + t.date "end_date" + t.bigint "sei_process_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["sei_process_id"], name: "index_accreditations_on_sei_process_id" + t.index ["user_id"], name: "index_accreditations_on_user_id" + end + + create_table "active_storage_attachments", force: :cascade do |t| + t.string "name", null: false + t.string "record_type", null: false + t.bigint "record_id", null: false + t.bigint "blob_id", null: false + t.datetime "created_at", null: false + t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" + t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true + end + + create_table "active_storage_blobs", force: :cascade do |t| + t.string "key", null: false + t.string "filename", null: false + t.string "content_type" + t.text "metadata" + t.bigint "byte_size", null: false + t.string "checksum", null: false + t.datetime "created_at", null: false + t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true + end + + create_table "requirements", force: :cascade do |t| + t.string "title" + t.text "content" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "sei_processes", force: :cascade do |t| + t.bigint "user_id" + t.integer "status" + t.string "code" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id"], name: "index_sei_processes_on_user_id" + end + create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false @@ -30,4 +78,8 @@ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end + add_foreign_key "accreditations", "sei_processes" + add_foreign_key "accreditations", "users" + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "sei_processes", "users" end diff --git a/db/seeds.rb b/db/seeds.rb index a5ddd2f6..8cccea57 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -11,4 +11,8 @@ User.create(full_name: "Administrador", email: "admin@admin.com", password: "admin123", role: "administrator", registration: "000000000") User.create(full_name: "Secretário", email: "secretary@secretary.com", password: "admin123", role: "secretary", registration: "000000000") User.create(full_name: "Professor", email: "professor@professor.com", password: "admin123", role: "professor", registration: "000000000") -User.create(full_name: "Aluno", email: "student@student.com", password: "admin123", role: "student", registration: "000000000") \ No newline at end of file +User.create(full_name: "Aluno", email: "student@student.com", password: "admin123", role: "student", registration: "000000000") + +Accreditation.destroy_all +Requirement.destroy_all +SeiProcess.destroy_all diff --git a/features.html b/features.html new file mode 100644 index 00000000..cf25f8dd --- /dev/null +++ b/features.html @@ -0,0 +1,763 @@ + + + + Cucumber + + + + +
+
+ + + + diff --git a/features/.DS_Store b/features/.DS_Store new file mode 100644 index 00000000..7f9634a1 Binary files /dev/null and b/features/.DS_Store differ diff --git a/features/abrir_solicitacao_credenciamento.feature b/features/abrir_solicitacao_credenciamento.feature new file mode 100644 index 00000000..590e7173 --- /dev/null +++ b/features/abrir_solicitacao_credenciamento.feature @@ -0,0 +1,22 @@ +#language: pt +#encoding: utf-8 + +Funcionalidade: Abrir solicitação de credenciamento + Como um professor autenticado no sistema, + Quero poder abrir uma solicitação de credenciamento + Para que eu possa ser um professor credenciado + + Contexto: + Dado que eu esteja cadastrado e logado como "Lucas", "lucas@professor.com", "lucas123", "professor", "200000000" + E que eu esteja na página de solicitações de credenciamento + Quando eu clico em 'Abrir Novo Processo' + + Cenário: Solicitação enviada com sucesso + Quando eu anexo o arquivo "features/resources/Formulário de Credenciamento.doc" em 'Documentos' + E eu anexo o arquivo "features/resources/ship.jpg" em 'Documentos' + E eu aperto 'Enviar' + Então eu devo receber uma mensagem de sucesso + + Cenário: Solicitação não enviada (campo obrigatório em branco) + Quando eu aperto 'Enviar' + Então eu devo receber uma mensagem de erro diff --git a/features/credenciamento_periodo.feature b/features/credenciamento_periodo.feature new file mode 100644 index 00000000..da34d837 --- /dev/null +++ b/features/credenciamento_periodo.feature @@ -0,0 +1,29 @@ +#language: pt +#encoding: utf-8 + +Funcionalidade: credenciar de credenciamento dos professores + Como um administrador autenticado no sistema, + Quero visualizar professores com credenciamento aprovado + Para credenciar de credenciamento dos professores + + Contexto: + Dado que existam os seguintes credenciamentos sem prazo definido: + | user_full_name | + | Alvin | + | Simon | + | Theodore | + + E que eu esteja cadastrado e logado como "Aécio", "aecio@admin.com", "aecio123", "administrator", "200000000" + E que eu esteja na página de credenciamentos + + Cenário: Definir prazo inserindo uma data válida + Quando eu escolho credenciar "Simon" + E eu seleciono uma data final posterior a data inicial + E eu aperto 'Salvar' + Então eu devo receber uma mensagem de sucesso + + Cenário: Definir prazo inserindo data inválida + Quando eu escolho credenciar "Theodore" + E eu seleciono uma data final anterior a data inicial + E eu aperto 'Salvar' + Então eu devo receber uma mensagem de erro diff --git a/features/gerenciar_solicitacoes_credenciamento.feature b/features/gerenciar_solicitacoes_credenciamento.feature new file mode 100644 index 00000000..b1723abd --- /dev/null +++ b/features/gerenciar_solicitacoes_credenciamento.feature @@ -0,0 +1,37 @@ +#language: pt +#encoding: utf-8 + +Funcionalidade: Gerenciar solicitações de credenciamento + Como um admnistrador autenticado no sistema, + Quero visualizar uma solicitação de credencimento em aberto + Para decidir se vou aceitar ou recusar tal solicitação + + Contexto: + Dado que existam as seguintes solicitações: + | user_full_name | status | + | Alvin | Espera | + | Simon | Espera | + | Theodore | Espera | + + E que eu esteja cadastrado e logado como "Gabriel", "gabriel@admin.com", "gabriel123", "administrator", "200000000" + E que eu esteja na página de solicitações de credenciamento + + Cenário: Aceitar uma solicitação de credenciamento + Quando eu escolho avaliar "Alvin" + E eu escolho 'Aprovado' + E eu aperto 'Enviar' + Então eu devo estar na página de solicitações de credenciamento + Quando eu desmarco os seguintes estados: Espera, Rejeitado + E eu marco os seguintes estados: Aprovado + E eu aperto 'Atualizar' + Então eu devo ver "Alvin" + + Cenário: Recusar uma solicitação de credenciamento + Quando eu escolho avaliar "Simon" + E eu escolho 'Rejeitado' + E eu aperto 'Enviar' + Então eu devo estar na página de solicitações de credenciamento + Quando eu desmarco os seguintes estados: Espera, Aprovado + E eu marco os seguintes estados: Rejeitado + E eu aperto 'Atualizar' + Então eu devo ver "Simon" diff --git a/features/requisitos_necessarios.feature b/features/requisitos_necessarios.feature new file mode 100644 index 00000000..6609b475 --- /dev/null +++ b/features/requisitos_necessarios.feature @@ -0,0 +1,18 @@ +#language: pt +#encoding: utf-8 + +Funcionalidade: Disponibilizar os requisitos para o credenciamento + Como um administrador autenticado no sistema, + Para que os professores possam abrir solicitações de credenciamento + Quero poder disponibilizar os requisitos necessários para o credenciamento + + Contexto: + Dado que eu esteja cadastrado e logado como "Preihs", "preihs@admin.com", "preihs123", "administrator", "200000000" + E que eu esteja na página de requisitos para o credenciamento + + Cenário: Modificar os requisitos necessários para o credenciamento + Quando eu clico em 'Adicionar Informação de Requisitos' + E eu preencho com "Requisitos de Credenciamento" em 'Título' + E eu anexo o arquivo "features/resources/Formulário de Credenciamento.doc" em 'Documentos' + E eu aperto 'Enviar' + Então eu devo receber uma mensagem de sucesso diff --git "a/features/resources/Formul\303\241rio de Credenciamento.doc" "b/features/resources/Formul\303\241rio de Credenciamento.doc" new file mode 100644 index 00000000..015b6122 Binary files /dev/null and "b/features/resources/Formul\303\241rio de Credenciamento.doc" differ diff --git a/features/resources/ship.jpg b/features/resources/ship.jpg new file mode 100644 index 00000000..fdcf848a Binary files /dev/null and b/features/resources/ship.jpg differ diff --git a/features/step_definitions/credenciamento_professores_steps.rb b/features/step_definitions/credenciamento_professores_steps.rb new file mode 100644 index 00000000..336da4c8 --- /dev/null +++ b/features/step_definitions/credenciamento_professores_steps.rb @@ -0,0 +1,155 @@ +require 'uri' +require 'cgi' +require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths")) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors")) + +module WithinHelpers + def with_scope(locator) + locator ? within(*selector_for(locator)) { yield } : yield + end +end +World(WithinHelpers) + +Dado "que existam as seguintes solicitações:" do |table| + User.destroy_all + file = fixture_file_upload(Rails.root.join('public', 'TestImage.png'), 'image/png') + table.hashes.each do |row| + name = row['user_full_name'] + user = User.create!(full_name: name, email: name+'@professor.com', password: name+'123', role: 'professor', registration: '200000000') + SeiProcess.create!(user_id: user.id, status: row['status'], code: 0, documents: [file]) + end +end + +Dado "que existam os seguintes credenciamentos sem prazo definido:" do |table| + User.destroy_all + file = fixture_file_upload(Rails.root.join('public', 'TestImage.png'), 'image/png') + table.hashes.each do |row| + name = row['user_full_name'] + user = User.create!(full_name: name, email: name+'@professor.com', password: name+'123', role: 'professor', registration: '200000000') + sei_process = SeiProcess.create!(user_id: user.id, status: 'Aprovado', code: 0, documents: [file]) + Accreditation.create!(user_id: user.id, sei_process_id: sei_process.id, start_date: row['start_date']) + end +end + +Dado /^que eu esteja cadastrado e logado como (.*)$/ do |input| + user_props = [:full_name, :email, :password, :role, :registration] + + values = input.gsub!(/"/,'').split(/,\s?/) + record = Hash[user_props.zip(values)] + User.create!(record) + + steps %( + Dado que eu esteja logado como "#{record[:email]}", "#{record[:password]}" + ) +end + +Dado /^que eu esteja logado como (.*)$/ do |input| + fields = ['email', 'password'] + values = Hash[fields.zip input.gsub!(/"/,'').split(/,\s?/)] + + visit new_user_session_path + fill_in("Email", :with => values['email']) + fill_in("Password", :with => values['password']) + click_button("Log in") +end + +Dado /^que eu esteja na página (.+)$/ do |page_name| + visit path_to(page_name) +end + +Quando /^eu escolho avaliar "([^"]*)"$/ do |name| + user_id = User.find_by(full_name: name).id + process_id = SeiProcess.find_by(user_id: user_id).id + visit "/sei_processes/#{process_id}/edit" +end + +Quando /^eu escolho credenciar "([^"]*)"$/ do |name| + user_id = User.find_by(full_name: name).id + accreditation_id = Accreditation.find_by(user_id: user_id).id + visit "/accreditations/#{accreditation_id}/edit" +end + +Quando /^eu anexo o arquivo "([^"]*)" em '([^']*)'$/ do |path, field| + attach_file(field, File.expand_path(path)) +end + +Quando /^eu clico em '([^']*)'$/ do |link| + click_link(link) +end + +Então /^eu devo estar na página (.+)$/ do |page_name| + current_path = URI.parse(current_url).path + if current_path.respond_to? :should + current_path.should == path_to(page_name) + else + assert_equal path_to(page_name), current_path + end +end + +Quando /^eu escolho '([^']*)'$/ do |option| + choose(option) +end + +Quando /^eu marco os seguintes estados: (.*)$/ do |statuses| + statuses.split(/,[ ]*/).each do |status| + check("statuses[#{status}]") + end +end + +Quando /^eu desmarco os seguintes estados: (.*)$/ do |statuses| + statuses.split(/,[ ]*/).each do |status| + uncheck("statuses[#{status}]") + end +end + +Quando /^eu preencho em '([^']*)' com/m do |field, text| + fill_in(field, :with => text) +end + +Quando /^eu preencho com "([^"]*)" em '([^']*)'$/ do |text, field| + fill_in(field, :with => text) +end + +Quando /^eu seleciono uma data final (posterior|anterior) a data inicial$/ do |status| + if status == 'posterior' + season = 5 + elsif status == 'anterior' + season = -5 + end + date1 = (Date.current+season).strftime("%Y-%m-%e") + date2 = (Date.current).strftime("%Y-%m-%e") + fill_in 'Data final', with: date1 + fill_in 'Data inicial', with: date2 + # select_date(date1, :from => 'Data Final') + # select_date(date2, :from => 'Data Inicial') +end + +Quando /^eu aperto '([^']*)'$/ do |button| + click_button(button) +end + +Então /^eu devo ver "([^"]*)"$/ do |text| + if page.respond_to? :should + page.should have_content(text) + else + assert page.has_content?(text) + end +end + +Então /^eu não devo ver "([^"]*)"$/ do |text| + if page.respond_to? :should + page.should have_no_content(text) + else + assert page.has_no_content?(text) + end +end + +Então /^eu devo receber uma mensagem de (sucesso|erro)$/ do |status| + if status == 'sucesso' + find(".notice", text: /sucesso!$/) + elsif status == 'erro' + find("#error_explanation") + else + raise StandardError.new('Mensagem não encontrada') + end +end diff --git a/features/support/hooks.rb b/features/support/hooks.rb new file mode 100644 index 00000000..3c8ec40c --- /dev/null +++ b/features/support/hooks.rb @@ -0,0 +1,41 @@ +After do |scenario| + add_screenshot(scenario) + + if scenario.failed? + add_browser_logs + end + end + + def add_screenshot(scenario) + nome_cenario = scenario.name.gsub(/[^A-Za-z0-9]/, '') + nome_cenario = nome_cenario.gsub(' ','_').downcase! + screenshot = "log/screenshots/#{nome_cenario}.png" + # page.save_screenshot(screenshot) + attach(screenshot, 'image/png') + end + + def add_browser_logs + time_now = Time.now + # Getting current URL + current_url = Capybara.current_url.to_s + # Gather browser logs + logs = page.driver.browser.manage.logs.get(:browser).map {|line| [line.level, line.message]} + # Remove warnings and info messages + logs.reject! { |line| ['WARNING', 'INFO'].include?(line.first) } + logs.any? == true + embed(time_now.strftime('%Y-%m-%d-%H-%M-%S' + "\n") + ( "Current URL: " + current_url + "\n") + logs.join("\n"), 'text/plain', 'BROWSER ERROR') +end + +at_exit do + time = Time.now.getutc + ReportBuilder.configure do |config| + config.json_path = 'report.json' + config.report_path = 'cucumber_web_report' + config.report_types = [:html] + config.report_tabs = %w[Overview Features Scenarios Errors] + config.report_title = 'Cucumber Report Builder web automation test results' + config.compress_images = false + config.additional_info = { 'Project name' => 'Test', 'Platform' => 'Integration', 'Report generated' => time } + end + ReportBuilder.build_report +end diff --git a/features/support/paths.rb b/features/support/paths.rb new file mode 100644 index 00000000..89eff6d3 --- /dev/null +++ b/features/support/paths.rb @@ -0,0 +1,42 @@ +module NavigationHelpers + # Maps a name to a path. Used by the + # + # When /^I go to (.+)$/ do |page_name| + # + # step definition in web_steps.rb + # + def path_to(page_name) + case page_name + + when /^the home\s?page$/ + '/' + + when /^de requisitos para o credenciamento$/ + '/requirements' + + when /^de solicitações de credenciamento$/ + '/sei_processes' + + when /^de credenciamentos$/ + '/accreditations' + + # Add more mappings here. + # Here is an example that pulls values out of the Regexp: + # + # when /^(.*)'s profile page$/i + # user_profile_path(User.find_by_login($1)) + + else + begin + page_name =~ /^the (.*) page$/ + path_components = $1.split(/\s+/) + self.send(path_components.push('path').join('_').to_sym) + rescue NoMethodError, ArgumentError + raise "Can't find mapping from \"#{page_name}\" to a path.\n" + + "Now, go and add a mapping in #{__FILE__}" + end + end + end +end + +World(NavigationHelpers) diff --git a/features/support/selectors.rb b/features/support/selectors.rb new file mode 100644 index 00000000..33bebc1d --- /dev/null +++ b/features/support/selectors.rb @@ -0,0 +1,44 @@ +# TL;DR: YOU SHOULD DELETE THIS FILE +# +# This file is used by web_steps.rb, which you should also delete +# +# You have been warned +module HtmlSelectorsHelpers + # Maps a name to a selector. Used primarily by the + # + # When /^(.+) within (.+)$/ do |step, scope| + # + # step definitions in web_steps.rb + # + def selector_for(locator) + case locator + + when "the page" + "html > body" + + # Add more mappings here. + # Here is an example that pulls values out of the Regexp: + # + # when /^the (notice|error|info) flash$/ + # ".flash.#{$1}" + + # You can also return an array to use a different selector + # type, like: + # + # when /the header/ + # [:xpath, "//header"] + + # This allows you to provide a quoted selector as the scope + # for "within" steps as was previously the default for the + # web steps: + when /^"(.+)"$/ + $1 + + else + raise "Can't find mapping from \"#{locator}\" to a selector.\n" + + "Now, go and add a mapping in #{__FILE__}" + end + end +end + +World(HtmlSelectorsHelpers) diff --git a/public/TestImage.png b/public/TestImage.png new file mode 100644 index 00000000..b379c072 Binary files /dev/null and b/public/TestImage.png differ diff --git a/public/credenciamento_mer8.png b/public/credenciamento_mer8.png new file mode 100644 index 00000000..0b7083e7 Binary files /dev/null and b/public/credenciamento_mer8.png differ diff --git a/report.json b/report.json new file mode 100644 index 00000000..39293e55 --- /dev/null +++ b/report.json @@ -0,0 +1 @@ +[{"id":"abrir-solicitação-de-credenciamento","uri":"features/abrir_solicitacao_credenciamento.feature","keyword":"Funcionalidade","name":"Abrir solicitação de credenciamento","description":" Como um professor autenticado no sistema,\n Quero poder abrir uma solicitação de credenciamento\n Para que eu possa ser um professor credenciado","line":4,"elements":[{"keyword":"Contexto","name":"","description":"","line":9,"type":"background","before":[{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:14"},"result":{"status":"passed","duration":20500}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:22"},"result":{"status":"passed","duration":11600}}],"steps":[{"keyword":"Dado ","name":"que eu esteja cadastrado e logado como \"Lucas\", \"lucas@professor.com\", \"lucas123\", \"professor\", \"200000000\"","line":10,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:34"},"result":{"status":"passed","duration":417911100}},{"keyword":"E ","name":"que eu esteja na página de solicitações de credenciamento","line":11,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:56"},"result":{"status":"passed","duration":27141000}},{"keyword":"Quando ","name":"eu clico em 'Abrir Novo Processo'","line":12,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:76"},"result":{"status":"passed","duration":34618900}}]},{"id":"abrir-solicitação-de-credenciamento;solicitação-enviada-com-sucesso","keyword":"Cenário","name":"Solicitação enviada com sucesso","description":"","line":14,"type":"scenario","steps":[{"keyword":"Quando ","name":"eu anexo o arquivo \"features/resources/Formulário de Credenciamento.doc\" em 'Documentos'","line":15,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:72"},"result":{"status":"passed","duration":1695000}},{"keyword":"E ","name":"eu anexo o arquivo \"features/resources/ship.jpg\" em 'Documentos'","line":16,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:72"},"result":{"status":"passed","duration":1005600}},{"keyword":"E ","name":"eu aperto 'Enviar'","line":17,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:127"},"result":{"status":"passed","duration":154366700}},{"keyword":"Então ","name":"eu devo receber uma mensagem de sucesso","line":18,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:147"},"result":{"status":"passed","duration":1695400}}],"after":[{"embeddings":[{"mime_type":"image/png","data":"bG9nL3NjcmVlbnNob3RzL3NvbGljaXRhb2VudmlhZGFjb21zdWNlc3NvLnBuZw=="}],"match":{"location":"features/support/hooks.rb:1"},"result":{"status":"passed","duration":509900}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:10"},"result":{"status":"passed","duration":25500}}]},{"keyword":"Contexto","name":"","description":"","line":9,"type":"background","before":[{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:14"},"result":{"status":"passed","duration":26000}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:22"},"result":{"status":"passed","duration":36200}}],"steps":[{"keyword":"Dado ","name":"que eu esteja cadastrado e logado como \"Lucas\", \"lucas@professor.com\", \"lucas123\", \"professor\", \"200000000\"","line":10,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:34"},"result":{"status":"passed","duration":33426400}},{"keyword":"E ","name":"que eu esteja na página de solicitações de credenciamento","line":11,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:56"},"result":{"status":"passed","duration":9814800}},{"keyword":"Quando ","name":"eu clico em 'Abrir Novo Processo'","line":12,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:76"},"result":{"status":"passed","duration":9402700}}]},{"id":"abrir-solicitação-de-credenciamento;solicitação-não-enviada-(campo-obrigatório-em-branco)","keyword":"Cenário","name":"Solicitação não enviada (campo obrigatório em branco)","description":"","line":20,"type":"scenario","steps":[{"keyword":"Quando ","name":"eu aperto 'Enviar'","line":21,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:127"},"result":{"status":"passed","duration":14018700}},{"keyword":"Então ","name":"eu devo receber uma mensagem de erro","line":22,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:147"},"result":{"status":"passed","duration":1214500}}],"after":[{"embeddings":[{"mime_type":"image/png","data":"bG9nL3NjcmVlbnNob3RzL3NvbGljaXRhb25vZW52aWFkYWNhbXBvb2JyaWdhdHJpb2VtYnJhbmNvLnBuZw=="}],"match":{"location":"features/support/hooks.rb:1"},"result":{"status":"passed","duration":321800}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:10"},"result":{"status":"passed","duration":18000}}]}]},{"id":"credenciar-de-credenciamento-dos-professores","uri":"features/credenciamento_periodo.feature","keyword":"Funcionalidade","name":"credenciar de credenciamento dos professores","description":" Como um administrador autenticado no sistema,\n Quero visualizar professores com credenciamento aprovado\n Para credenciar de credenciamento dos professores","line":4,"elements":[{"keyword":"Contexto","name":"","description":"","line":9,"type":"background","before":[{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:14"},"result":{"status":"passed","duration":22800}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:22"},"result":{"status":"passed","duration":16800}}],"steps":[{"keyword":"Dado ","name":"que existam os seguintes credenciamentos sem prazo definido:","line":10,"rows":[{"cells":["user_full_name"]},{"cells":["Alvin"]},{"cells":["Simon"]},{"cells":["Theodore"]}],"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:23"},"result":{"status":"passed","duration":232243500}},{"keyword":"E ","name":"que eu esteja cadastrado e logado como \"Aécio\", \"aecio@admin.com\", \"aecio123\", \"administrator\", \"200000000\"","line":16,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:34"},"result":{"status":"passed","duration":36796800}},{"keyword":"E ","name":"que eu esteja na página de credenciamentos","line":17,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:56"},"result":{"status":"passed","duration":23694700}}]},{"id":"credenciar-de-credenciamento-dos-professores;definir-prazo-inserindo-uma-data-válida","keyword":"Cenário","name":"Definir prazo inserindo uma data válida","description":"","line":19,"type":"scenario","steps":[{"keyword":"Quando ","name":"eu escolho credenciar \"Simon\"","line":20,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:66"},"result":{"status":"passed","duration":38072400}},{"keyword":"E ","name":"eu seleciono uma data final posterior a data inicial","line":21,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:113"},"result":{"status":"passed","duration":3709400}},{"keyword":"E ","name":"eu aperto 'Salvar'","line":22,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:127"},"result":{"status":"passed","duration":32784000}},{"keyword":"Então ","name":"eu devo receber uma mensagem de sucesso","line":23,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:147"},"result":{"status":"passed","duration":2137700}}],"after":[{"embeddings":[{"mime_type":"image/png","data":"bG9nL3NjcmVlbnNob3RzL2RlZmluaXJwcmF6b2luc2VyaW5kb3VtYWRhdGF2bGlkYS5wbmc="}],"match":{"location":"features/support/hooks.rb:1"},"result":{"status":"passed","duration":1681300}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:10"},"result":{"status":"passed","duration":53700}}]},{"keyword":"Contexto","name":"","description":"","line":9,"type":"background","before":[{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:14"},"result":{"status":"passed","duration":28900}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:22"},"result":{"status":"passed","duration":31800}}],"steps":[{"keyword":"Dado ","name":"que existam os seguintes credenciamentos sem prazo definido:","line":10,"rows":[{"cells":["user_full_name"]},{"cells":["Alvin"]},{"cells":["Simon"]},{"cells":["Theodore"]}],"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:23"},"result":{"status":"passed","duration":384377200}},{"keyword":"E ","name":"que eu esteja cadastrado e logado como \"Aécio\", \"aecio@admin.com\", \"aecio123\", \"administrator\", \"200000000\"","line":16,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:34"},"result":{"status":"passed","duration":53291700}},{"keyword":"E ","name":"que eu esteja na página de credenciamentos","line":17,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:56"},"result":{"status":"passed","duration":14425400}}]},{"id":"credenciar-de-credenciamento-dos-professores;definir-prazo-inserindo-data-inválida","keyword":"Cenário","name":"Definir prazo inserindo data inválida","description":"","line":25,"type":"scenario","steps":[{"keyword":"Quando ","name":"eu escolho credenciar \"Theodore\"","line":26,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:66"},"result":{"status":"passed","duration":22751000}},{"keyword":"E ","name":"eu seleciono uma data final anterior a data inicial","line":27,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:113"},"result":{"status":"passed","duration":4165300}},{"keyword":"E ","name":"eu aperto 'Salvar'","line":28,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:127"},"result":{"status":"passed","duration":29248900}},{"keyword":"Então ","name":"eu devo receber uma mensagem de erro","line":29,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:147"},"result":{"status":"passed","duration":980100}}],"after":[{"embeddings":[{"mime_type":"image/png","data":"bG9nL3NjcmVlbnNob3RzL2RlZmluaXJwcmF6b2luc2VyaW5kb2RhdGFpbnZsaWRhLnBuZw=="}],"match":{"location":"features/support/hooks.rb:1"},"result":{"status":"passed","duration":379600}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:10"},"result":{"status":"passed","duration":22300}}]}]},{"id":"gerenciar-solicitações-de-credenciamento","uri":"features/gerenciar_solicitacoes_credenciamento.feature","keyword":"Funcionalidade","name":"Gerenciar solicitações de credenciamento","description":" Como um admnistrador autenticado no sistema,\n Quero visualizar uma solicitação de credencimento em aberto\n Para decidir se vou aceitar ou recusar tal solicitação","line":4,"elements":[{"keyword":"Contexto","name":"","description":"","line":9,"type":"background","before":[{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:14"},"result":{"status":"passed","duration":19400}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:22"},"result":{"status":"passed","duration":25200}}],"steps":[{"keyword":"Dado ","name":"que existam as seguintes solicitações:","line":10,"rows":[{"cells":["user_full_name","status"]},{"cells":["Alvin","Espera"]},{"cells":["Simon","Espera"]},{"cells":["Theodore","Espera"]}],"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:13"},"result":{"status":"passed","duration":82938000}},{"keyword":"E ","name":"que eu esteja cadastrado e logado como \"Gabriel\", \"gabriel@admin.com\", \"gabriel123\", \"administrator\", \"200000000\"","line":16,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:34"},"result":{"status":"passed","duration":25951500}},{"keyword":"E ","name":"que eu esteja na página de solicitações de credenciamento","line":17,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:56"},"result":{"status":"passed","duration":8906500}}]},{"id":"gerenciar-solicitações-de-credenciamento;aceitar-uma-solicitação-de-credenciamento","keyword":"Cenário","name":"Aceitar uma solicitação de credenciamento","description":"","line":19,"type":"scenario","steps":[{"keyword":"Quando ","name":"eu escolho avaliar \"Alvin\"","line":20,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:60"},"result":{"status":"passed","duration":25411800}},{"keyword":"E ","name":"eu escolho 'Aprovado'","line":21,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:89"},"result":{"status":"passed","duration":1547200}},{"keyword":"E ","name":"eu aperto 'Enviar'","line":22,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:127"},"result":{"status":"passed","duration":25355900}},{"keyword":"Então ","name":"eu devo estar na página de solicitações de credenciamento","line":23,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:80"},"result":{"status":"passed","duration":3621200}},{"keyword":"Quando ","name":"eu desmarco os seguintes estados: Espera, Rejeitado","line":24,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:99"},"result":{"status":"passed","duration":2812200}},{"keyword":"E ","name":"eu marco os seguintes estados: Aprovado","line":25,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:93"},"result":{"status":"passed","duration":737300}},{"keyword":"E ","name":"eu aperto 'Atualizar'","line":26,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:127"},"result":{"status":"passed","duration":12149100}},{"keyword":"Então ","name":"eu devo ver \"Alvin\"","line":27,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:131"},"result":{"status":"passed","duration":1366400}}],"after":[{"embeddings":[{"mime_type":"image/png","data":"bG9nL3NjcmVlbnNob3RzL2FjZWl0YXJ1bWFzb2xpY2l0YW9kZWNyZWRlbmNpYW1lbnRvLnBuZw=="}],"match":{"location":"features/support/hooks.rb:1"},"result":{"status":"passed","duration":284700}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:10"},"result":{"status":"passed","duration":17500}}]},{"keyword":"Contexto","name":"","description":"","line":9,"type":"background","before":[{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:14"},"result":{"status":"passed","duration":17100}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:22"},"result":{"status":"passed","duration":21400}}],"steps":[{"keyword":"Dado ","name":"que existam as seguintes solicitações:","line":10,"rows":[{"cells":["user_full_name","status"]},{"cells":["Alvin","Espera"]},{"cells":["Simon","Espera"]},{"cells":["Theodore","Espera"]}],"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:13"},"result":{"status":"passed","duration":71727400}},{"keyword":"E ","name":"que eu esteja cadastrado e logado como \"Gabriel\", \"gabriel@admin.com\", \"gabriel123\", \"administrator\", \"200000000\"","line":16,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:34"},"result":{"status":"passed","duration":23772700}},{"keyword":"E ","name":"que eu esteja na página de solicitações de credenciamento","line":17,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:56"},"result":{"status":"passed","duration":9016500}}]},{"id":"gerenciar-solicitações-de-credenciamento;recusar-uma-solicitação-de-credenciamento","keyword":"Cenário","name":"Recusar uma solicitação de credenciamento","description":"","line":29,"type":"scenario","steps":[{"keyword":"Quando ","name":"eu escolho avaliar \"Simon\"","line":30,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:60"},"result":{"status":"passed","duration":12279700}},{"keyword":"E ","name":"eu escolho 'Rejeitado'","line":31,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:89"},"result":{"status":"passed","duration":1122000}},{"keyword":"E ","name":"eu aperto 'Enviar'","line":32,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:127"},"result":{"status":"passed","duration":19598500}},{"keyword":"Então ","name":"eu devo estar na página de solicitações de credenciamento","line":33,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:80"},"result":{"status":"passed","duration":122800}},{"keyword":"Quando ","name":"eu desmarco os seguintes estados: Espera, Aprovado","line":34,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:99"},"result":{"status":"passed","duration":2546000}},{"keyword":"E ","name":"eu marco os seguintes estados: Rejeitado","line":35,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:93"},"result":{"status":"passed","duration":2226900}},{"keyword":"E ","name":"eu aperto 'Atualizar'","line":36,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:127"},"result":{"status":"passed","duration":7423700}},{"keyword":"Então ","name":"eu devo ver \"Simon\"","line":37,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:131"},"result":{"status":"passed","duration":1532800}}],"after":[{"embeddings":[{"mime_type":"image/png","data":"bG9nL3NjcmVlbnNob3RzL3JlY3VzYXJ1bWFzb2xpY2l0YW9kZWNyZWRlbmNpYW1lbnRvLnBuZw=="}],"match":{"location":"features/support/hooks.rb:1"},"result":{"status":"passed","duration":335300}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:10"},"result":{"status":"passed","duration":28700}}]}]},{"id":"disponibilizar-os-requisitos-para-o-credenciamento","uri":"features/requisitos_necessarios.feature","keyword":"Funcionalidade","name":"Disponibilizar os requisitos para o credenciamento","description":" Como um administrador autenticado no sistema,\n Para que os professores possam abrir solicitações de credenciamento\n Quero poder disponibilizar os requisitos necessários para o credenciamento","line":4,"elements":[{"keyword":"Contexto","name":"","description":"","line":9,"type":"background","before":[{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:14"},"result":{"status":"passed","duration":13300}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:22"},"result":{"status":"passed","duration":9900}}],"steps":[{"keyword":"Dado ","name":"que eu esteja cadastrado e logado como \"Preihs\", \"preihs@admin.com\", \"preihs123\", \"administrator\", \"200000000\"","line":10,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:34"},"result":{"status":"passed","duration":27956800}},{"keyword":"E ","name":"que eu esteja na página de requisitos para o credenciamento","line":11,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:56"},"result":{"status":"passed","duration":59374600}}]},{"id":"disponibilizar-os-requisitos-para-o-credenciamento;modificar-os-requisitos-necessários-para-o-credenciamento","keyword":"Cenário","name":"Modificar os requisitos necessários para o credenciamento","description":"","line":13,"type":"scenario","steps":[{"keyword":"Quando ","name":"eu clico em 'Adicionar Informação de Requisitos'","line":14,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:76"},"result":{"status":"passed","duration":59351300}},{"keyword":"E ","name":"eu preencho com \"Requisitos de Credenciamento\" em 'Título'","line":15,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:109"},"result":{"status":"passed","duration":3401000}},{"keyword":"E ","name":"eu anexo o arquivo \"features/resources/Formulário de Credenciamento.doc\" em 'Documentos'","line":16,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:72"},"result":{"status":"passed","duration":1061500}},{"keyword":"E ","name":"eu aperto 'Enviar'","line":17,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:127"},"result":{"status":"passed","duration":306489800}},{"keyword":"Então ","name":"eu devo receber uma mensagem de sucesso","line":18,"match":{"location":"features/step_definitions/credenciamento_professores_steps.rb:147"},"result":{"status":"passed","duration":2899900}}],"after":[{"embeddings":[{"mime_type":"image/png","data":"bG9nL3NjcmVlbnNob3RzL21vZGlmaWNhcm9zcmVxdWlzaXRvc25lY2Vzc3Jpb3NwYXJhb2NyZWRlbmNpYW1lbnRvLnBuZw=="}],"match":{"location":"features/support/hooks.rb:1"},"result":{"status":"passed","duration":625000}},{"match":{"location":"capybara-3.33.0/lib/capybara/cucumber.rb:10"},"result":{"status":"passed","duration":42700}}]}]}] \ No newline at end of file diff --git a/spec/.DS_Store b/spec/.DS_Store new file mode 100644 index 00000000..b6ed5336 Binary files /dev/null and b/spec/.DS_Store differ diff --git a/spec/controllers/accreditations_controller_spec.rb b/spec/controllers/accreditations_controller_spec.rb new file mode 100644 index 00000000..74a354df --- /dev/null +++ b/spec/controllers/accreditations_controller_spec.rb @@ -0,0 +1,141 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify 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. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. +# +# Also compared to earlier versions of this generator, there are no longer any +# expectations of assigns and templates rendered. These features have been +# removed from Rails core in Rails 5, but can be added back in via the +# `rails-controller-testing` gem. + +RSpec.describe AccreditationsController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # Accreditation. As you add validations to Accreditation, 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") + } + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # AccreditationsController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET #index" do + it "returns a success response" do + Accreditation.create! valid_attributes + get :index, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #show" do + it "returns a success response" do + accreditation = Accreditation.create! valid_attributes + get :show, params: {id: accreditation.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #new" do + it "returns a success response" do + get :new, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #edit" do + it "returns a success response" do + accreditation = Accreditation.create! valid_attributes + get :edit, params: {id: accreditation.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "POST #create" do + context "with valid params" do + it "creates a new Accreditation" do + expect { + post :create, params: {accreditation: valid_attributes}, session: valid_session + }.to change(Accreditation, :count).by(1) + end + + it "redirects to the created accreditation" do + post :create, params: {accreditation: valid_attributes}, session: valid_session + expect(response).to redirect_to(Accreditation.last) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'new' template)" do + post :create, params: {accreditation: invalid_attributes}, session: valid_session + expect(response).to be_successful + end + end + end + + describe "PUT #update" do + context "with valid params" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested accreditation" do + accreditation = Accreditation.create! valid_attributes + put :update, params: {id: accreditation.to_param, accreditation: new_attributes}, session: valid_session + accreditation.reload + skip("Add assertions for updated state") + end + + it "redirects to the accreditation" do + accreditation = Accreditation.create! valid_attributes + put :update, params: {id: accreditation.to_param, accreditation: valid_attributes}, session: valid_session + expect(response).to redirect_to(accreditation) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'edit' template)" do + accreditation = Accreditation.create! valid_attributes + put :update, params: {id: accreditation.to_param, accreditation: invalid_attributes}, session: valid_session + expect(response).to be_successful + end + end + end + + describe "DELETE #destroy" do + it "destroys the requested accreditation" do + accreditation = Accreditation.create! valid_attributes + expect { + delete :destroy, params: {id: accreditation.to_param}, session: valid_session + }.to change(Accreditation, :count).by(-1) + end + + it "redirects to the accreditations list" do + accreditation = Accreditation.create! valid_attributes + delete :destroy, params: {id: accreditation.to_param}, session: valid_session + expect(response).to redirect_to(accreditations_url) + end + end + +end diff --git a/spec/controllers/requirements_controller_spec.rb b/spec/controllers/requirements_controller_spec.rb new file mode 100644 index 00000000..ee3eb7f9 --- /dev/null +++ b/spec/controllers/requirements_controller_spec.rb @@ -0,0 +1,153 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify 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. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. +# +# Also compared to earlier versions of this generator, there are no longer any +# expectations of assigns and templates rendered. These features have been +# removed from Rails core in Rails 5, but can be added back in via the +# `rails-controller-testing` gem. + +RSpec.describe RequirementsController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # Requirement. As you add validations to Requirement, be sure to + # adjust the attributes here as well. + let(:valid_attributes) { + file = fixture_file_upload(Rails.root.join('public', 'TestImage.png'), 'image/png') + {"title" => "test", "content" => "", "documents" => [file]} + } + + let(:invalid_attributes) { + {"title" => ""} + } + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # RequirementsController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET #index" do + it "returns a success response" do + Requirement.create! valid_attributes + get :index, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #show" do + it "returns a success response" do + requirement = Requirement.create! valid_attributes + get :show, params: {id: requirement.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #new" do + it "returns a success response" do + get :new, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #edit" do + it "returns a success response" do + requirement = Requirement.create! valid_attributes + get :edit, params: {id: requirement.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "POST #create" do + context "with valid params" do + it "creates a new Requirement" do + expect { + post :create, params: {requirement: valid_attributes}, session: valid_session + }.to change(Requirement, :count).by(1) + end + + it "redirects to the created requirement" do + post :create, params: {requirement: valid_attributes}, session: valid_session + expect(response).to redirect_to(Requirement.last) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'new' template)" do + post :create, params: {requirement: invalid_attributes}, session: valid_session + expect(response).to be_successful + end + end + end + + describe "PUT #update" do + context "with valid params" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested requirement" do + requirement = Requirement.create! valid_attributes + put :update, params: {id: requirement.to_param, requirement: new_attributes}, session: valid_session + requirement.reload + skip("Add assertions for updated state") + end + + it "redirects to the requirement" do + requirement = Requirement.create! valid_attributes + put :update, params: {id: requirement.to_param, requirement: valid_attributes}, session: valid_session + expect(response).to redirect_to(requirement) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'edit' template)" do + requirement = Requirement.create! valid_attributes + put :update, params: {id: requirement.to_param, requirement: invalid_attributes}, session: valid_session + expect(response).to be_successful + end + end + end + + describe "Documents Management"do + it 'purges a specific file' do + requirement = Requirement.create! valid_attributes + requirement.documents.each do | document | + expect { + delete :delete_document_attachment, params: { id: document.id, requirement_id: requirement.id } + }.to change(ActiveStorage::Attachment, :count).by(-1) + end + end + end + + describe "DELETE #destroy" do + it "destroys the requested requirement" do + requirement = Requirement.create! valid_attributes + expect { + delete :destroy, params: {id: requirement.to_param}, session: valid_session + }.to change(Requirement, :count).by(-1) + end + + it "redirects to the requirements list" do + requirement = Requirement.create! valid_attributes + delete :destroy, params: {id: requirement.to_param}, session: valid_session + expect(response).to redirect_to(requirements_url) + end + end + +end diff --git a/spec/controllers/sei_processes_controller_spec.rb b/spec/controllers/sei_processes_controller_spec.rb new file mode 100644 index 00000000..c6745941 --- /dev/null +++ b/spec/controllers/sei_processes_controller_spec.rb @@ -0,0 +1,141 @@ +require 'rails_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify 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. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. +# +# Also compared to earlier versions of this generator, there are no longer any +# expectations of assigns and templates rendered. These features have been +# removed from Rails core in Rails 5, but can be added back in via the +# `rails-controller-testing` gem. + +RSpec.describe SeiProcessesController, type: :controller do + + # This should return the minimal set of attributes required to create a valid + # SeiProcess. As you add validations to SeiProcess, 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") + } + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # SeiProcessesController. Be sure to keep this updated too. + let(:valid_session) { {} } + + describe "GET #index" do + it "returns a success response" do + SeiProcess.create! valid_attributes + get :index, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #show" do + it "returns a success response" do + sei_process = SeiProcess.create! valid_attributes + get :show, params: {id: sei_process.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #new" do + it "returns a success response" do + get :new, params: {}, session: valid_session + expect(response).to be_successful + end + end + + describe "GET #edit" do + it "returns a success response" do + sei_process = SeiProcess.create! valid_attributes + get :edit, params: {id: sei_process.to_param}, session: valid_session + expect(response).to be_successful + end + end + + describe "POST #create" do + context "with valid params" do + it "creates a new SeiProcess" do + expect { + post :create, params: {sei_process: valid_attributes}, session: valid_session + }.to change(SeiProcess, :count).by(1) + end + + it "redirects to the created sei_process" do + post :create, params: {sei_process: valid_attributes}, session: valid_session + expect(response).to redirect_to(SeiProcess.last) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'new' template)" do + post :create, params: {sei_process: invalid_attributes}, session: valid_session + expect(response).to be_successful + end + end + end + + describe "PUT #update" do + context "with valid params" do + let(:new_attributes) { + skip("Add a hash of attributes valid for your model") + } + + it "updates the requested sei_process" do + sei_process = SeiProcess.create! valid_attributes + put :update, params: {id: sei_process.to_param, sei_process: new_attributes}, session: valid_session + sei_process.reload + skip("Add assertions for updated state") + end + + it "redirects to the sei_process" do + sei_process = SeiProcess.create! valid_attributes + put :update, params: {id: sei_process.to_param, sei_process: valid_attributes}, session: valid_session + expect(response).to redirect_to(sei_process) + end + end + + context "with invalid params" do + it "returns a success response (i.e. to display the 'edit' template)" do + sei_process = SeiProcess.create! valid_attributes + put :update, params: {id: sei_process.to_param, sei_process: invalid_attributes}, session: valid_session + expect(response).to be_successful + end + end + end + + describe "DELETE #destroy" do + it "destroys the requested sei_process" do + sei_process = SeiProcess.create! valid_attributes + expect { + delete :destroy, params: {id: sei_process.to_param}, session: valid_session + }.to change(SeiProcess, :count).by(-1) + end + + it "redirects to the sei_processes list" do + sei_process = SeiProcess.create! valid_attributes + delete :destroy, params: {id: sei_process.to_param}, session: valid_session + expect(response).to redirect_to(sei_processes_url) + end + end + +end diff --git a/spec/helpers/accreditations_helper_spec.rb b/spec/helpers/accreditations_helper_spec.rb new file mode 100644 index 00000000..ef5ec4f9 --- /dev/null +++ b/spec/helpers/accreditations_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the AccreditationsHelper. For example: +# +# describe AccreditationsHelper 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 AccreditationsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/requirements_helper_spec.rb b/spec/helpers/requirements_helper_spec.rb new file mode 100644 index 00000000..56f186ef --- /dev/null +++ b/spec/helpers/requirements_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the RequirementsHelper. For example: +# +# describe RequirementsHelper 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 RequirementsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/sei_processes_helper_spec.rb b/spec/helpers/sei_processes_helper_spec.rb new file mode 100644 index 00000000..5bdfa905 --- /dev/null +++ b/spec/helpers/sei_processes_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the SeiProcessesHelper. For example: +# +# describe SeiProcessesHelper 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 SeiProcessesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/accreditation_spec.rb b/spec/models/accreditation_spec.rb new file mode 100644 index 00000000..64cf38c7 --- /dev/null +++ b/spec/models/accreditation_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Accreditation, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/requirement_spec.rb b/spec/models/requirement_spec.rb new file mode 100644 index 00000000..73bc0c89 --- /dev/null +++ b/spec/models/requirement_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Requirement, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/sei_process_spec.rb b/spec/models/sei_process_spec.rb new file mode 100644 index 00000000..afb8155d --- /dev/null +++ b/spec/models/sei_process_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SeiProcess, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b06351ba..00345af7 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,9 +1,7 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' - require File.expand_path('../config/environment', __dir__) - # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? require 'rspec/rails' @@ -22,7 +20,7 @@ # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. # -# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f } +# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } # Checks for pending migrations and applies them before tests are run. # If you are not using ActiveRecord, you can remove these lines. @@ -41,6 +39,9 @@ # 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 can automatically mix in different behaviours to your tests # based on their file location, for example enabling you to call `get` and # `post` in specs under `spec/controllers`. @@ -48,7 +49,7 @@ # You can disable this behaviour by removing the line below, and instead # explicitly tag your specs with their type, e.g.: # - # RSpec.describe UsersController, :type => :controller do + # RSpec.describe UsersController, type: :controller do # # ... # end # diff --git a/spec/requests/accreditations_spec.rb b/spec/requests/accreditations_spec.rb new file mode 100644 index 00000000..d3bfc23d --- /dev/null +++ b/spec/requests/accreditations_spec.rb @@ -0,0 +1,129 @@ + 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 "/accreditations", type: :request do + # Accreditation. As you add validations to Accreditation, 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 + Accreditation.create! valid_attributes + get accreditations_url + expect(response).to be_successful + end + end + + describe "GET /show" do + it "renders a successful response" do + accreditation = Accreditation.create! valid_attributes + get accreditation_url(accreditation) + expect(response).to be_successful + end + end + + describe "GET /new" do + it "renders a successful response" do + get new_accreditation_url + expect(response).to be_successful + end + end + + describe "GET /edit" do + it "render a successful response" do + accreditation = Accreditation.create! valid_attributes + get edit_accreditation_url(accreditation) + expect(response).to be_successful + end + end + + describe "POST /create" do + context "with valid parameters" do + it "creates a new Accreditation" do + expect { + post accreditations_url, params: { accreditation: valid_attributes } + }.to change(Accreditation, :count).by(1) + end + + it "redirects to the created accreditation" do + post accreditations_url, params: { accreditation: valid_attributes } + expect(response).to redirect_to(accreditation_url(Accreditation.last)) + end + end + + context "with invalid parameters" do + it "does not create a new Accreditation" do + expect { + post accreditations_url, params: { accreditation: invalid_attributes } + }.to change(Accreditation, :count).by(0) + end + + it "renders a successful response (i.e. to display the 'new' template)" do + post accreditations_url, params: { accreditation: invalid_attributes } + expect(response).to be_successful + 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 accreditation" do + accreditation = Accreditation.create! valid_attributes + patch accreditation_url(accreditation), params: { accreditation: new_attributes } + accreditation.reload + skip("Add assertions for updated state") + end + + it "redirects to the accreditation" do + accreditation = Accreditation.create! valid_attributes + patch accreditation_url(accreditation), params: { accreditation: new_attributes } + accreditation.reload + expect(response).to redirect_to(accreditation_url(accreditation)) + end + end + + context "with invalid parameters" do + it "renders a successful response (i.e. to display the 'edit' template)" do + accreditation = Accreditation.create! valid_attributes + patch accreditation_url(accreditation), params: { accreditation: invalid_attributes } + expect(response).to be_successful + end + end + end + + describe "DELETE /destroy" do + it "destroys the requested accreditation" do + accreditation = Accreditation.create! valid_attributes + expect { + delete accreditation_url(accreditation) + }.to change(Accreditation, :count).by(-1) + end + + it "redirects to the accreditations list" do + accreditation = Accreditation.create! valid_attributes + delete accreditation_url(accreditation) + expect(response).to redirect_to(accreditations_url) + end + end +end diff --git a/spec/requests/requirements_spec.rb b/spec/requests/requirements_spec.rb new file mode 100644 index 00000000..8385b9f4 --- /dev/null +++ b/spec/requests/requirements_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "Requirements", type: :request do + describe "GET /requirements" do + it "works! (now write some real specs)" do + get requirements_path + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/requests/sei_processes_spec.rb b/spec/requests/sei_processes_spec.rb new file mode 100644 index 00000000..a68a3630 --- /dev/null +++ b/spec/requests/sei_processes_spec.rb @@ -0,0 +1,10 @@ +require 'rails_helper' + +RSpec.describe "SeiProcesses", type: :request do + describe "GET /sei_processes" do + it "works! (now write some real specs)" do + get sei_processes_path + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/routing/accreditations_routing_spec.rb b/spec/routing/accreditations_routing_spec.rb new file mode 100644 index 00000000..e77cf77a --- /dev/null +++ b/spec/routing/accreditations_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe AccreditationsController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(get: "/accreditations").to route_to("accreditations#index") + end + + it "routes to #new" do + expect(get: "/accreditations/new").to route_to("accreditations#new") + end + + it "routes to #show" do + expect(get: "/accreditations/1").to route_to("accreditations#show", id: "1") + end + + it "routes to #edit" do + expect(get: "/accreditations/1/edit").to route_to("accreditations#edit", id: "1") + end + + + it "routes to #create" do + expect(post: "/accreditations").to route_to("accreditations#create") + end + + it "routes to #update via PUT" do + expect(put: "/accreditations/1").to route_to("accreditations#update", id: "1") + end + + it "routes to #update via PATCH" do + expect(patch: "/accreditations/1").to route_to("accreditations#update", id: "1") + end + + it "routes to #destroy" do + expect(delete: "/accreditations/1").to route_to("accreditations#destroy", id: "1") + end + end +end diff --git a/spec/routing/requirements_routing_spec.rb b/spec/routing/requirements_routing_spec.rb new file mode 100644 index 00000000..8ce5d654 --- /dev/null +++ b/spec/routing/requirements_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe RequirementsController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(:get => "/requirements").to route_to("requirements#index") + end + + it "routes to #new" do + expect(:get => "/requirements/new").to route_to("requirements#new") + end + + it "routes to #show" do + expect(:get => "/requirements/1").to route_to("requirements#show", :id => "1") + end + + it "routes to #edit" do + expect(:get => "/requirements/1/edit").to route_to("requirements#edit", :id => "1") + end + + + it "routes to #create" do + expect(:post => "/requirements").to route_to("requirements#create") + end + + it "routes to #update via PUT" do + expect(:put => "/requirements/1").to route_to("requirements#update", :id => "1") + end + + it "routes to #update via PATCH" do + expect(:patch => "/requirements/1").to route_to("requirements#update", :id => "1") + end + + it "routes to #destroy" do + expect(:delete => "/requirements/1").to route_to("requirements#destroy", :id => "1") + end + end +end diff --git a/spec/routing/sei_processes_routing_spec.rb b/spec/routing/sei_processes_routing_spec.rb new file mode 100644 index 00000000..d7e8e8cc --- /dev/null +++ b/spec/routing/sei_processes_routing_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe SeiProcessesController, type: :routing do + describe "routing" do + it "routes to #index" do + expect(:get => "/sei_processes").to route_to("sei_processes#index") + end + + it "routes to #new" do + expect(:get => "/sei_processes/new").to route_to("sei_processes#new") + end + + it "routes to #show" do + expect(:get => "/sei_processes/1").to route_to("sei_processes#show", :id => "1") + end + + it "routes to #edit" do + expect(:get => "/sei_processes/1/edit").to route_to("sei_processes#edit", :id => "1") + end + + + it "routes to #create" do + expect(:post => "/sei_processes").to route_to("sei_processes#create") + end + + it "routes to #update via PUT" do + expect(:put => "/sei_processes/1").to route_to("sei_processes#update", :id => "1") + end + + it "routes to #update via PATCH" do + expect(:patch => "/sei_processes/1").to route_to("sei_processes#update", :id => "1") + end + + it "routes to #destroy" do + expect(:delete => "/sei_processes/1").to route_to("sei_processes#destroy", :id => "1") + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ce33d66d..75cc2ced 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -66,6 +66,10 @@ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode config.disable_monkey_patching! + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + # 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. diff --git a/spike.rb b/spike.rb new file mode 100644 index 00000000..c6d4f6d5 --- /dev/null +++ b/spike.rb @@ -0,0 +1,4 @@ +require 'date' + +datedate = Date.today.strftime("%Y-%m-%e") +p datedate \ No newline at end of file