Commit 374ee3fa authored by mateus ravedutti's avatar mateus ravedutti

Fix current tests

parent 93e56b24
Pipeline #7153 failed with stage
in 10 seconds
......@@ -80,6 +80,7 @@ module Api::V1
:address_number,
:address_street,
:cep,
:city_id,
:cpf,
:email,
:neighborhood,
......
......@@ -22,6 +22,7 @@ protected
:address_number,
:address_street,
:cep,
:city_id,
:cpf,
:email,
:neighborhood,
......
......@@ -43,6 +43,7 @@ class Citizen < ApplicationRecord
:address_number,
:address_street,
:cep,
:city_id,
:cpf,
:email,
:neighborhood,
......
class CitizenSerializer < ActiveModel::Serializer
attributes :id, :birth_date, :name, :rg,
:address_complement, :address_number,
:address_street, :cep, :cpf, :email,
:neighborhood, :note, :pcd, :phone1,
:phone2, :photo_content_type,
:address_street, :cep, :city_id, :cpf,
:email, :neighborhood, :note, :pcd,
:phone1, :phone2, :photo_content_type,
:photo_file_name, :photo_file_size,
:photo_update_at, :active
......
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161005141323) do
ActiveRecord::Schema.define(version: 20161007130605) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -83,6 +83,7 @@ ActiveRecord::Schema.define(version: 20161005141323) do
t.integer "account_id"
t.boolean "active"
t.integer "city_id"
t.integer "responsible_id"
t.index ["account_id"], name: "index_citizens_on_account_id", using: :btree
t.index ["city_id"], name: "index_citizens_on_city_id", using: :btree
end
......@@ -154,6 +155,27 @@ ActiveRecord::Schema.define(version: 20161005141323) do
t.boolean "active", default: true, null: false
end
create_table "schedules", force: :cascade do |t|
t.integer "shift_id", null: false
t.integer "situation_id", null: false
t.integer "service_place_id", null: false
t.integer "account_id"
t.integer "citizen_ajax_read", null: false
t.integer "professional_ajax_read", null: false
t.integer "reminder_read", null: false
t.datetime "service_start_time", null: false
t.datetime "service_end_time", null: false
t.string "note"
t.integer "reminder_email_sent"
t.integer "remainder_time"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_schedules_on_account_id", using: :btree
t.index ["service_place_id"], name: "index_schedules_on_service_place_id", using: :btree
t.index ["shift_id"], name: "index_schedules_on_shift_id", using: :btree
t.index ["situation_id"], name: "index_schedules_on_situation_id", using: :btree
end
create_table "sectors", force: :cascade do |t|
t.integer "city_hall_id", null: false
t.boolean "active"
......@@ -200,6 +222,28 @@ ActiveRecord::Schema.define(version: 20161005141323) do
t.index ["sector_id"], name: "index_service_types_on_sector_id", using: :btree
end
create_table "shifts", force: :cascade do |t|
t.integer "service_place_id", null: false
t.integer "service_type_id", null: false
t.integer "next_shift_id"
t.integer "professional_performer_id"
t.integer "professional_responsible_id"
t.datetime "execution_start_time"
t.datetime "execution_end_time"
t.integer "service_amount"
t.text "notes"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["service_place_id"], name: "index_shifts_on_service_place_id", using: :btree
t.index ["service_type_id"], name: "index_shifts_on_service_type_id", using: :btree
end
create_table "situations", force: :cascade do |t|
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "solicitations", force: :cascade do |t|
t.integer "city_id"
t.string "name"
......
......@@ -8,6 +8,17 @@ class Api::V1::Accounts::RegistrationsControllerTest < ActionDispatch::Integrati
@number_of_accounts = Account.count
@number_of_citizens = Citizen.count
@santa_catarina = State.new(abbreviation: "SC",
ibge_code: "42",
name: "Santa Catarina")
@santa_catarina.save!
@joinville = City.new(ibge_code: "4209102",
name: "Joinville",
state_id: @santa_catarina.id)
@joinville.save!
post '/v1/auth', params: {
birth_date: "Apr 18 1997",
cep: "81530-110",
......@@ -15,6 +26,7 @@ class Api::V1::Accounts::RegistrationsControllerTest < ActionDispatch::Integrati
email: "test@example.com",
name: "Test Example",
phone1: "121212-1212",
city_id: @joinville.id,
rg: "1234567",
password: "123mudar",
password_confirmation: "123mudar"
......
......@@ -4,6 +4,17 @@ class Api::V1::Accounts::SessionsControllerTest < ActionDispatch::IntegrationTes
describe Api::V1::Accounts::SessionsController do
describe "Token access" do
before do
@santa_catarina = State.new(abbreviation: "SC",
ibge_code: "42",
name: "Santa Catarina")
@santa_catarina.save!
@joinville = City.new(ibge_code: "4209102",
name: "Joinville",
state_id: @santa_catarina.id)
@joinville.save!
post '/v1/auth', params: {
birth_date: "Apr 18 1997",
cep: "81530-110",
......@@ -12,6 +23,7 @@ class Api::V1::Accounts::SessionsControllerTest < ActionDispatch::IntegrationTes
name: "Test Example",
phone1: "121212-1212",
rg: "1234567",
city_id: @joinville.id,
password: "123mudar",
password_confirmation: "123mudar"
}
......
......@@ -12,6 +12,7 @@ class Api::V1::CitizensControllerTest < ActionDispatch::IntegrationTest
name: "Curitiba",
state_id: @parana.id)
@curitiba.save!
@citizen = Citizen.new(cpf: "10845922904",
birth_date: "Apr 18 1997",
cep: "1234567",
......@@ -19,10 +20,12 @@ class Api::V1::CitizensControllerTest < ActionDispatch::IntegrationTest
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567",
city_id: @curitiba)
city_id: @curitiba.id)
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@citizen.active = true
@account.save!
@citizen.account_id = @account.id
......
......@@ -3,17 +3,6 @@ require 'test_helper'
class CityHallsControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@citizen = Citizen.new(cpf: "10845922904",
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567")
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
......@@ -42,6 +31,21 @@ class CityHallsControllerTest < ActionDispatch::IntegrationTest
active: true,
block_text: "Test block text");
@citizen = Citizen.new(cpf: "10845922904",
active: true,
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567",
city_id: @joinville.id)
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@citizen.active = true
@account.save!
@citizen.account_id = @account.id
......
......@@ -3,16 +3,30 @@ require 'test_helper'
class Api::V1::DependantsControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@santa_catarina = State.new(abbreviation: "SC",
ibge_code: "42",
name: "Santa Catarina")
@santa_catarina.save!
@joinville = City.new(ibge_code: "4209102",
name: "Joinville",
state_id: @santa_catarina.id)
@joinville.save!
@citizen= Citizen.new(cpf: "10845922904",
birth_date: "18/04/1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
city_id: @joinville.id,
rg: "1234567")
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@dependant = Dependant.new(active: true)
@account.save!
......
......@@ -3,27 +3,29 @@ require 'test_helper'
class OccupationsControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
@parana.save!
@curitiba = City.new(ibge_code: "4106902",
name: "Curitiba",
state_id: @parana.id)
@curitiba.save!
@citizen = Citizen.new(cpf: "10845922904",
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
city_id: @curitiba.id,
rg: "1234567")
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
@parana.save!
@curitiba = City.new(ibge_code: "4106902",
name: "Curitiba",
state_id: @parana.id)
@curitiba.save!
@curitiba_city_hall = CityHall.new(name: "Prefeitura de Curitiba",
cep: "1234567",
neighborhood: "Test neighborhood",
......
......@@ -3,27 +3,29 @@ require 'test_helper'
class Api::V1::ProfessionalsControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
@parana.save!
@curitiba = City.new(ibge_code: "4106902",
name: "Curitiba",
state_id: @parana.id)
@curitiba.save!
@citizen= Citizen.new(cpf: "10845922904",
birth_date: "18/04/1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567")
rg: "1234567",
city_id: @curitiba.id)
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
@parana.save!
@curitiba = City.new(ibge_code: "4106902",
name: "Curitiba",
state_id: @parana.id)
@curitiba.save!
@curitiba_city_hall = CityHall.new(name: "Prefeitura de Curitiba",
cep: "1234567",
neighborhood: "Test neighborhood",
......
......@@ -4,32 +4,44 @@ class Api::V1::SchedulesControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@citizen= Citizen.new(cpf: "10845922904",
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567")
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@professional = Professional.new(active: true,
registration: "123")
@city_hall = CityHall.new(name: "Prefeitura de Curitiba",
cep: "81530110",
neighborhood: "random",
address_street: "unknown",
address_number: "99",
city_id: 4001,
phone1: "321312",
active: true,
block_text: "hi"
)
@santa_catarina = State.new(abbreviation: "SC",
ibge_code: "42",
name: "Santa Catarina")
@santa_catarina.save!
@joinville = City.new(ibge_code: "4209102",
name: "Joinville",
state_id: @santa_catarina.id)
@joinville.save!
@citizen = Citizen.new(cpf: "10845922904",
active: true,
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567",
city_id: @joinville.id)
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@city_hall = CityHall.new(name: "Prefeitura de Joinville",
cep: "81530110",
neighborhood: "Aasdsd",
address_street: "asdasd",
address_number: "100",
city_id: @joinville.id,
phone1: "12121212",
active: true,
block_text: "hello")
@occupation = Occupation.new(description: "Cargo",
name: "Teste",
active: true)
@sector = Sector.new(active: true,
name: "Setor 1",
......@@ -38,15 +50,23 @@ class Api::V1::SchedulesControllerTest < ActionDispatch::IntegrationTest
cancel_limit: 3,
description: "number one",
schedules_by_sector: 3)
@professional = Professional.new(active: true,
registration: "123")
@account.save!
@citizen.account_id = @account.id
@citizen.save!
@city_hall.save!
@occupation.city_hall_id = @city_hall.id
@occupation.save!
@professional.account_id = @account.id
@professional.occupation_id = @occupation.id
@professional.save!
@city_hall.save!
@sector.city_hall = @city_hall
@sector.save!
......
......@@ -3,39 +3,41 @@ require 'test_helper'
class SectorsControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@santa_catarina = State.new(abbreviation: "SC",
ibge_code: "42",
name: "Santa Catarina")
@santa_catarina.save!
@joinville = City.new(ibge_code: "4209102",
name: "Joinville",
state_id: @santa_catarina.id)
@joinville.save!
@citizen = Citizen.new(cpf: "10845922904",
active: true,
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567")
rg: "1234567",
city_id: @joinville.id)
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@santa_catarina = State.new(abbreviation: "SC",
ibge_code: "42",
name: "Santa Catarina")
@santa_catarina.save!
@joinville = City.new(ibge_code: "4209102",
name: "Joinville",
state_id: @santa_catarina.id)
@joinville.save!
@city_hall = CityHall.new(name: "Prefeitura de Curitiba",
cep: "81530110",
neighborhood: "Aasdsd",
address_street: "asdasd",
address_number: "100",
city_id: @joinville.id,
phone1: "12121212",
active: true,
block_text: "hello")
@city_hall = CityHall.new(name: "Prefeitura de Joinville",
cep: "81530110",
neighborhood: "Aasdsd",
address_street: "asdasd",
address_number: "100",
city_id: @joinville.id,
phone1: "12121212",
active: true,
block_text: "hello")
@city_hall.save!
@citizen.active = true
@account.save!
@citizen.account_id = @account.id
@citizen.save!
......@@ -51,15 +53,15 @@ class SectorsControllerTest < ActionDispatch::IntegrationTest
before do
@number_of_sectors = Sector.count
post '/v1/sectors', params: { sector: {
active: true,
city_hall_id: @city_hall.id,
name: "Setor 1",
absence_max: 1,
blocking_days: 2,
cancel_limit: 3,
description: "the number one",
schedules_by_sector: 3
}}, headers: @auth_headers
active: true,
city_hall_id: @city_hall.id,
name: "Setor 1",
absence_max: 1,
blocking_days: 2,
cancel_limit: 3,
description: "the number one",
schedules_by_sector: 3
}}, headers: @auth_headers
@body = JSON.parse(response.body)
@resp_token = response.headers['access-token']
@resp_client_id = response.headers['client']
......
......@@ -4,29 +4,30 @@ class Api::V1::ServicePlacesControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
@parana.save!
@curitiba = City.new(ibge_code: "4106902",
name: "Curitiba",
state_id: @parana.id)
@curitiba.save!
@citizen= Citizen.new(cpf: "10845922904",
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
city_id: @curitiba.id,
rg: "1234567")
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
@parana.save!
@curitiba = City.new(ibge_code: "4106902",
name: "Curitiba",
state_id: @parana.id)
@curitiba.save!
@city_hall = CityHall.new(name: "Prefeitura de Curitiba",
cep: "81530110",
neighborhood: "random",
......
......@@ -3,49 +3,55 @@ require 'test_helper'
class ServiceTypesControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
@parana.save!
@curitiba = City.new(ibge_code: "4106902",
name: "Curitiba",
state_id: @parana.id)
@curitiba.save!
@citizen = Citizen.new(cpf: "10845922904",
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
city_id: @curitiba.id,
rg: "1234567")
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@parana = State.new(abbreviation: "PR",
ibge_code: "41",
name: "Paraná")
@parana.save!
@curitiba = City.new(ibge_code: "4106902",
name: "Curitiba",
state_id: @parana.id)
@curitiba.save!
@city_hall = CityHall.new(name: "Prefeitura de Curitiba",
cep: "81530110",
neighborhood: "Aasdsd",
address_street: "asdasd",
address_number: "100",
city_id: @curitiba.id,
phone1: "12121212",
active: true,
block_text: "hello")
cep: "81530110",
neighborhood: "Aasdsd",
address_street: "asdasd",
address_number: "100",
city_id: @curitiba.id,
phone1: "12121212",
active: true,
block_text: "hello")
@sector = Sector.new(active: true,
name: "Setor 1",
absence_max: 1,
blocking_days: 2,
cancel_limit: 3,
description: "number one",
schedules_by_sector: 3)
name: "Setor 1",
absence_max: 1,
blocking_days: 2,
cancel_limit: 3,
description: "number one",
schedules_by_sector: 3)
@city_hall.save!
@sector.city_hall = @city_hall
@sector.save!
@citizen.active = true
@account.save!
@citizen.active = true
@citizen.account_id = @account.id
@citizen.save!
......
......@@ -4,34 +4,46 @@ class Api::V1::ShiftsControllerTest < ActionDispatch::IntegrationTest
describe "Token access" do
before do
@citizen= Citizen.new(cpf: "10845922904",
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567")
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@professional = Professional.new(active: true,
registration: "123")
@city_hall = CityHall.new(name: "Prefeitura de Curitiba",
cep: "81530110",
neighborhood: "random",
address_street: "unknown",
address_number: "99",
city_id: 4001,
phone1: "321312",
active: true,
block_text: "hi"
)
@sector = Sector.new(active: true,
@santa_catarina = State.new(abbreviation: "SC",
ibge_code: "42",
name: "Santa Catarina")
@santa_catarina.save!
@joinville = City.new(ibge_code: "4209102",
name: "Joinville",
state_id: @santa_catarina.id)
@joinville.save!
@citizen = Citizen.new(cpf: "10845922904",
active: true,
birth_date: "Apr 18 1997",
cep: "1234567",
email: "test@example.com",
name: "Test Example",
phone1: "(12)1212-1212",
rg: "1234567",
city_id: @joinville.id)
@account = Account.new(uid: @citizen.cpf,
password: "123mudar",
password_confirmation: "123mudar")
@city_hall = CityHall.new(name: "Prefeitura de Joinville",
cep: "81530110",
neighborhood: "Aasdsd",
address_street: "asdasd",
address_number: "100",
city_id: @joinville.id,
phone1: "12121212",
active: true,