From 69773833749649c1a368a64b24df30434be32d78 Mon Sep 17 00:00:00 2001 From: Joao Viktor Date: Sun, 15 Nov 2020 20:23:05 -0300 Subject: [PATCH 1/8] Implementando RSpec da feature #8 --- app/models/status.rb | 3 +++ features/cadastrostatus.feature | 5 ++-- .../step_definitions/cadastrostatus_steps.rb | 4 +++ spec/models/status_spec.rb | 25 +++++++++++++++++++ spec/rails_helper.rb | 9 +++++++ spec/support/database_cleaner.rb | 22 ++++++++++++++++ 6 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 app/models/status.rb create mode 100644 spec/models/status_spec.rb create mode 100644 spec/support/database_cleaner.rb diff --git a/app/models/status.rb b/app/models/status.rb new file mode 100644 index 00000000..9df38890 --- /dev/null +++ b/app/models/status.rb @@ -0,0 +1,3 @@ +class Status < ApplicationRecord + validates :name_status, presence: true +end \ No newline at end of file diff --git a/features/cadastrostatus.feature b/features/cadastrostatus.feature index d6bf9367..0bd902e1 100644 --- a/features/cadastrostatus.feature +++ b/features/cadastrostatus.feature @@ -20,5 +20,6 @@ Funcionalidade: Como um secretário, Dado que estou na pagina de cadastrar um status Quando preencher em "Nome do Status:" com "Novo" E clicar em "Concluir" - Então deveria estar de volta na pagina de cadastrar um status - E deveria aparecer "Erro ao Cadastrar Status!" \ No newline at end of file + Então deveria estar de volta na pagina de secretário + E deveria aparecer "Erro ao Cadastrar Status!" + \ No newline at end of file diff --git a/features/step_definitions/cadastrostatus_steps.rb b/features/step_definitions/cadastrostatus_steps.rb index c721c250..31abd0a6 100644 --- a/features/step_definitions/cadastrostatus_steps.rb +++ b/features/step_definitions/cadastrostatus_steps.rb @@ -26,6 +26,10 @@ visit path_to(page_cadastro_status) end +Então('deveria estar de volta na pagina de secretario') do |page_secretario| + visit path_to(page_secretario) +end + Então('deveria aparecer {string}') do |string| @expected_message = string end \ No newline at end of file diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb new file mode 100644 index 00000000..83922a1c --- /dev/null +++ b/spec/models/status_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +describe Status, type: :model do + it "Válido quando nome esta presente" do + status = Status.new( name_status: 'Novo') + expect(status).to be_valid + end +end + +describe Status, type: :model do + it "Invalido sem o nome" do + status = Status.new( name_status: nil) + status.valid? + expect(status.errors[:name_status]).to include("Não pode deixar espaço de nome em branco.") + end +end + +describe Status, type: :model do + it "é inválido caso já exista um e-mail igual" do + status = Status.create( name_status: 'Em espera') + status = Status.new( name_status: 'Em espera') + status.valid? + expect(status.errors[:name_status]).to include('Status Repetido') + end +end \ No newline at end of file diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b06351ba..305764ba 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -58,6 +58,15 @@ # Filter lines from Rails gems in backtraces. config.filter_rails_from_backtrace! + config.use_transactional_fixtures = false # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") end +require 'shoulda/matchers' + +Shoulda::Matchers.configure do |config| + config.integrate do |with| + with.test_framework :rspec + with.library :rails + end +end \ No newline at end of file diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb new file mode 100644 index 00000000..84219341 --- /dev/null +++ b/spec/support/database_cleaner.rb @@ -0,0 +1,22 @@ +RSpec.configure do |config| + + config.before(:suite) do + DatabaseCleaner.clean_with(:truncation) + end + + config.before(:each) do + DatabaseCleaner.strategy = :transaction + end + + config.before(:each, :js => true) do + DatabaseCleaner.strategy = :truncation + end + + config.before(:each) do + DatabaseCleaner.start + end + + config.after(:each) do + DatabaseCleaner.clean + end + end \ No newline at end of file From ff99599a807572ef369a6b67ac78716cc0d99c6f Mon Sep 17 00:00:00 2001 From: Joao Viktor Date: Sun, 15 Nov 2020 21:47:04 -0300 Subject: [PATCH 2/8] Implementando migrate da feature #8 --- db/migrate/20201116004137_create_status.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/migrate/20201116004137_create_status.rb diff --git a/db/migrate/20201116004137_create_status.rb b/db/migrate/20201116004137_create_status.rb new file mode 100644 index 00000000..a934ff82 --- /dev/null +++ b/db/migrate/20201116004137_create_status.rb @@ -0,0 +1,7 @@ +class CreateStatus < ActiveRecord::Migration[5.2] + def change + create_table :statuses do |t| + t.string :status_name + end + end +end From b8aafb8f50a92bd5a2a42e1a6e7132abf0d38d43 Mon Sep 17 00:00:00 2001 From: Joao Viktor Date: Sun, 15 Nov 2020 21:56:58 -0300 Subject: [PATCH 3/8] Implementando RSpec da feature #8 --- spec/models/status_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index 83922a1c..efa7d771 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Status, type: :model do - it "Válido quando nome esta presente" do + it "Valido quando nome esta presente" do status = Status.new( name_status: 'Novo') expect(status).to be_valid end @@ -11,12 +11,12 @@ it "Invalido sem o nome" do status = Status.new( name_status: nil) status.valid? - expect(status.errors[:name_status]).to include("Não pode deixar espaço de nome em branco.") + expect(status.errors[:name_status]).to include("Nao pode deixar espaço de nome em branco.") end end describe Status, type: :model do - it "é inválido caso já exista um e-mail igual" do + it "Invalido caso ja exista um e-mail igual" do status = Status.create( name_status: 'Em espera') status = Status.new( name_status: 'Em espera') status.valid? From 67f476e948e315854d0d451b6b11df089547907e Mon Sep 17 00:00:00 2001 From: Joao Viktor Date: Sun, 15 Nov 2020 23:01:08 -0300 Subject: [PATCH 4/8] Implementando RSpec e Migrate feature #8 --- app/models/status.rb | 4 ++-- db/migrate/20201116004137_create_status.rb | 7 ------- .../20201116015420_create_process_statuses.rb | 9 +++++++++ spec/models/status_spec.rb | 18 +++++++++--------- 4 files changed, 20 insertions(+), 18 deletions(-) delete mode 100644 db/migrate/20201116004137_create_status.rb create mode 100644 db/migrate/20201116015420_create_process_statuses.rb diff --git a/app/models/status.rb b/app/models/status.rb index 9df38890..8e14d385 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -1,3 +1,3 @@ -class Status < ApplicationRecord - validates :name_status, presence: true +class ProcessStatus < ApplicationRecord + validates :title, presence: true end \ No newline at end of file diff --git a/db/migrate/20201116004137_create_status.rb b/db/migrate/20201116004137_create_status.rb deleted file mode 100644 index a934ff82..00000000 --- a/db/migrate/20201116004137_create_status.rb +++ /dev/null @@ -1,7 +0,0 @@ -class CreateStatus < ActiveRecord::Migration[5.2] - def change - create_table :statuses do |t| - t.string :status_name - end - end -end diff --git a/db/migrate/20201116015420_create_process_statuses.rb b/db/migrate/20201116015420_create_process_statuses.rb new file mode 100644 index 00000000..67f3f321 --- /dev/null +++ b/db/migrate/20201116015420_create_process_statuses.rb @@ -0,0 +1,9 @@ +class CreateProcessStatuses < ActiveRecord::Migration[5.2] + def change + create_table :process_statuses do |t| + t.string :title + + t.timestamps + end + end +end diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index efa7d771..f3e83570 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -1,25 +1,25 @@ require 'rails_helper' -describe Status, type: :model do +describe ProcessStatus, type: :model do it "Valido quando nome esta presente" do - status = Status.new( name_status: 'Novo') + status = Status.new( title: 'Novo') expect(status).to be_valid end end -describe Status, type: :model do +describe ProcessStatus, type: :model do it "Invalido sem o nome" do - status = Status.new( name_status: nil) + status = Status.new( title: nil) status.valid? - expect(status.errors[:name_status]).to include("Nao pode deixar espaço de nome em branco.") + expect(status.errors[:title]).to include("Nao pode deixar espaço de nome em branco.") end end -describe Status, type: :model do +describe ProcessStatus, type: :model do it "Invalido caso ja exista um e-mail igual" do - status = Status.create( name_status: 'Em espera') - status = Status.new( name_status: 'Em espera') + status = Status.create( title: 'Em espera') + status = Status.new( title: 'Em espera') status.valid? - expect(status.errors[:name_status]).to include('Status Repetido') + expect(status.errors[:title]).to include('Status Repetido') end end \ No newline at end of file From b4cbe7715ca55a234dad3573da16e63253cbac3f Mon Sep 17 00:00:00 2001 From: Joao Viktor Date: Sun, 15 Nov 2020 23:23:32 -0300 Subject: [PATCH 5/8] Atualizando RSpec e Migrate de Processo e ProcessStatus --- app/models/{status.rb => process_status.rb} | 0 app/models/processo.rb | 2 ++ db/migrate/20201116021025_create_processos.rb | 12 ++++++++++++ .../{status_spec.rb => process_status_spec.rb} | 0 spec/models/processo_spec.rb | 5 +++++ 5 files changed, 19 insertions(+) rename app/models/{status.rb => process_status.rb} (100%) create mode 100644 app/models/processo.rb create mode 100644 db/migrate/20201116021025_create_processos.rb rename spec/models/{status_spec.rb => process_status_spec.rb} (100%) create mode 100644 spec/models/processo_spec.rb diff --git a/app/models/status.rb b/app/models/process_status.rb similarity index 100% rename from app/models/status.rb rename to app/models/process_status.rb diff --git a/app/models/processo.rb b/app/models/processo.rb new file mode 100644 index 00000000..ca45fc26 --- /dev/null +++ b/app/models/processo.rb @@ -0,0 +1,2 @@ +class Processo < ApplicationRecord +end \ No newline at end of file diff --git a/db/migrate/20201116021025_create_processos.rb b/db/migrate/20201116021025_create_processos.rb new file mode 100644 index 00000000..397b00ae --- /dev/null +++ b/db/migrate/20201116021025_create_processos.rb @@ -0,0 +1,12 @@ +class CreateProcessos < ActiveRecord::Migration[5.2] + def change + create_table :processos do |t| + t.integer :user_id + t.integer :process_status_id + t.string :sei_process_code + t.binary :documents + + t.timestamps + end + end +end diff --git a/spec/models/status_spec.rb b/spec/models/process_status_spec.rb similarity index 100% rename from spec/models/status_spec.rb rename to spec/models/process_status_spec.rb diff --git a/spec/models/processo_spec.rb b/spec/models/processo_spec.rb new file mode 100644 index 00000000..510e6660 --- /dev/null +++ b/spec/models/processo_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Processo, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end \ No newline at end of file From f9121a779c5018b520cd22a1ccbbcb2cf0ad202f Mon Sep 17 00:00:00 2001 From: Joao Viktor Date: Sun, 15 Nov 2020 23:42:38 -0300 Subject: [PATCH 6/8] Activity_Type models --- app/models/activity_type.rb | 2 ++ db/migrate/20201116023448_create_activity_types.rb | 9 +++++++++ spec/models/activity_type_spec.rb | 5 +++++ 3 files changed, 16 insertions(+) create mode 100644 app/models/activity_type.rb create mode 100644 db/migrate/20201116023448_create_activity_types.rb create mode 100644 spec/models/activity_type_spec.rb diff --git a/app/models/activity_type.rb b/app/models/activity_type.rb new file mode 100644 index 00000000..2df72c0f --- /dev/null +++ b/app/models/activity_type.rb @@ -0,0 +1,2 @@ +class ActivityType < ApplicationRecord +end \ No newline at end of file diff --git a/db/migrate/20201116023448_create_activity_types.rb b/db/migrate/20201116023448_create_activity_types.rb new file mode 100644 index 00000000..5bd3eaeb --- /dev/null +++ b/db/migrate/20201116023448_create_activity_types.rb @@ -0,0 +1,9 @@ +class CreateActivityTypes < ActiveRecord::Migration[5.2] + def change + create_table :activity_types do |t| + t.string :title + + t.timestamps + end + end +end diff --git a/spec/models/activity_type_spec.rb b/spec/models/activity_type_spec.rb new file mode 100644 index 00000000..d32fd2d7 --- /dev/null +++ b/spec/models/activity_type_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ActivityType, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end \ No newline at end of file From 61c00345b39b7eb1216b150d6bbddc0dda54674c Mon Sep 17 00:00:00 2001 From: Joao Viktor Date: Sun, 15 Nov 2020 23:55:48 -0300 Subject: [PATCH 7/8] WikiEntry e WikiEntryComment migrate --- app/models/wiki_entry.rb | 2 ++ app/models/wiki_entry_comment.rb | 2 ++ db/migrate/20201116025101_create_wiki_entries.rb | 11 +++++++++++ .../20201116025343_create_wiki_entry_comments.rb | 10 ++++++++++ spec/models/wiki_entry_comment_spec.rb | 5 +++++ spec/models/wiki_entry_spec.rb | 5 +++++ 6 files changed, 35 insertions(+) create mode 100644 app/models/wiki_entry.rb create mode 100644 app/models/wiki_entry_comment.rb create mode 100644 db/migrate/20201116025101_create_wiki_entries.rb create mode 100644 db/migrate/20201116025343_create_wiki_entry_comments.rb create mode 100644 spec/models/wiki_entry_comment_spec.rb create mode 100644 spec/models/wiki_entry_spec.rb diff --git a/app/models/wiki_entry.rb b/app/models/wiki_entry.rb new file mode 100644 index 00000000..c5076026 --- /dev/null +++ b/app/models/wiki_entry.rb @@ -0,0 +1,2 @@ +class WikiEntry < ApplicationRecord +end \ No newline at end of file diff --git a/app/models/wiki_entry_comment.rb b/app/models/wiki_entry_comment.rb new file mode 100644 index 00000000..c6b9cb47 --- /dev/null +++ b/app/models/wiki_entry_comment.rb @@ -0,0 +1,2 @@ +class WikiEntryComment < ApplicationRecord +end \ No newline at end of file diff --git a/db/migrate/20201116025101_create_wiki_entries.rb b/db/migrate/20201116025101_create_wiki_entries.rb new file mode 100644 index 00000000..d4443592 --- /dev/null +++ b/db/migrate/20201116025101_create_wiki_entries.rb @@ -0,0 +1,11 @@ +class CreateWikiEntries < ActiveRecord::Migration[5.2] + def change + create_table :wiki_entries do |t| + t.string :title + t.text :content + t.binary :documents + + t.timestamps + end + end +end diff --git a/db/migrate/20201116025343_create_wiki_entry_comments.rb b/db/migrate/20201116025343_create_wiki_entry_comments.rb new file mode 100644 index 00000000..f20f5557 --- /dev/null +++ b/db/migrate/20201116025343_create_wiki_entry_comments.rb @@ -0,0 +1,10 @@ +class CreateWikiEntryComments < ActiveRecord::Migration[5.2] + def change + create_table :wiki_entry_comments do |t| + t.integer :wiki_entry_id + t.text :content + + t.timestamps + end + end +end diff --git a/spec/models/wiki_entry_comment_spec.rb b/spec/models/wiki_entry_comment_spec.rb new file mode 100644 index 00000000..6cda1c0d --- /dev/null +++ b/spec/models/wiki_entry_comment_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe WikiEntryComment, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end \ No newline at end of file diff --git a/spec/models/wiki_entry_spec.rb b/spec/models/wiki_entry_spec.rb new file mode 100644 index 00000000..3abb4dc3 --- /dev/null +++ b/spec/models/wiki_entry_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe WikiEntry, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 42775de2aa0e7b550e0fe799dabaf1409c6d0717 Mon Sep 17 00:00:00 2001 From: rafaelmdalmoro Date: Sun, 15 Nov 2020 23:58:34 -0300 Subject: [PATCH 8/8] Wiki models correction --- app/models/wiki_entry.rb | 3 --- app/models/wiki_entry_comment.rb | 2 -- spec/models/wiki_entry_comment_spec.rb | 5 ----- spec/models/wiki_entry_spec.rb | 5 ----- 4 files changed, 15 deletions(-) delete mode 100644 app/models/wiki_entry.rb delete mode 100644 app/models/wiki_entry_comment.rb delete mode 100644 spec/models/wiki_entry_comment_spec.rb delete mode 100644 spec/models/wiki_entry_spec.rb diff --git a/app/models/wiki_entry.rb b/app/models/wiki_entry.rb deleted file mode 100644 index dadef092..00000000 --- a/app/models/wiki_entry.rb +++ /dev/null @@ -1,3 +0,0 @@ -class WikiEntry < ApplicationRecord - has_one :wiki_entry_comment -end diff --git a/app/models/wiki_entry_comment.rb b/app/models/wiki_entry_comment.rb deleted file mode 100644 index 19e4d31c..00000000 --- a/app/models/wiki_entry_comment.rb +++ /dev/null @@ -1,2 +0,0 @@ -class WikiEntryComment < ApplicationRecord -end diff --git a/spec/models/wiki_entry_comment_spec.rb b/spec/models/wiki_entry_comment_spec.rb deleted file mode 100644 index 6cda1c0d..00000000 --- a/spec/models/wiki_entry_comment_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe WikiEntryComment, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end \ No newline at end of file diff --git a/spec/models/wiki_entry_spec.rb b/spec/models/wiki_entry_spec.rb deleted file mode 100644 index 51d66ee1..00000000 --- a/spec/models/wiki_entry_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe WikiEntry, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end \ No newline at end of file