service_types_controller_test.rb 2.44 KB
Newer Older
Rafael Ravedutti's avatar
Rafael Ravedutti committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# This file is part of Agendador.
#
# Agendador is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Agendador is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Agendador.  If not, see <https://www.gnu.org/licenses/>.

Mateus Ravedutti's avatar
Mateus Ravedutti committed
16 17
require 'test_helper'

Mateus Ravedutti's avatar
Mateus Ravedutti committed
18
class ServiceTypesControllerTest < ActionDispatch::IntegrationTest
Mateus Ravedutti's avatar
Mateus Ravedutti committed
19 20
  describe "Token access" do
    before do
21 22 23 24 25
      @parana = State.new(
        abbreviation: "PR",
        ibge_code: "41",
        name: "Paraná"
      )
mateus ravedutti's avatar
mateus ravedutti committed
26 27
      @parana.save!

28 29 30 31 32
      @curitiba = City.new(
        ibge_code: "4106902",
        name: "Curitiba",
        state_id: @parana.id
      )
mateus ravedutti's avatar
mateus ravedutti committed
33 34
      @curitiba.save!

35
      @citizen = Citizen.new(
36
        cpf: "10845922904",
37
        active: true,
38 39
        birth_date: "Apr 18 1997",
        cep: "81530110",
40
        email: "test@example.com",
41
        name: "Test Example",
42
        phone1: "(12)1212-1212",
43 44
        address_street: "Street from Curitiba",
        address_number: "4121",
45 46 47
        city_id: @curitiba.id,
        rg: "1234567"
      )
mateus ravedutti's avatar
mateus ravedutti committed
48

49 50 51 52 53 54 55 56
      @account = Account.new(
        uid: @citizen.cpf,
        password: "123mudar",
        password_confirmation: "123mudar"
      )
      @account.save!
      @citizen.account_id = @account.id
      @citizen.save!
Mateus Ravedutti's avatar
Mateus Ravedutti committed
57

58 59
      @city_hall = CityHall.new(
        name: "Prefeitura de Curitiba",
Bruno Freitas Tissei's avatar
Bruno Freitas Tissei committed
60 61 62 63 64 65 66 67
        cep: "81530110",
        neighborhood: "Aasdsd",
        address_street: "asdasd",
        address_number: "100",
        city_id: @curitiba.id,
        phone1: "12121212",
        active: true,
        block_text: "hello"
68
      )
Mateus Ravedutti's avatar
Mateus Ravedutti committed
69
      @city_hall.save!
mateus ravedutti's avatar
mateus ravedutti committed
70

71
      @sector = Sector.new(
72 73 74 75 76 77
        active: true,
        name: "Setor 1",
        absence_max: 1,
        blocking_days: 2,
        cancel_limit: 3,
        description: "number one",
Bruno Freitas Tissei's avatar
Bruno Freitas Tissei committed
78
        schedules_by_sector: 3
79
      )
Mateus Ravedutti's avatar
Mateus Ravedutti committed
80 81
      @sector.city_hall = @city_hall
      @sector.save!
mateus ravedutti's avatar
mateus ravedutti committed
82

Mateus Ravedutti's avatar
Mateus Ravedutti committed
83 84 85 86 87 88 89 90
      @auth_headers = @account.create_new_auth_token

      @token     = @auth_headers['access-token']
      @client_id = @auth_headers['client']
      @expiry    = @auth_headers['expiry']
    end
  end
end