moves Residence model to Verification namespace

This commit is contained in:
Juanjo Bazán
2015-08-29 12:38:07 +02:00
parent e33723635b
commit e8463d1372
5 changed files with 10 additions and 10 deletions

View File

@@ -4,11 +4,11 @@ class Verification::ResidenceController < ApplicationController
skip_authorization_check skip_authorization_check
def new def new
@residence = Residence.new @residence = Verification::Residence.new
end end
def create def create
@residence = Residence.new(residence_params.merge(user: current_user)) @residence = Verification::Residence.new(residence_params.merge(user: current_user))
if @residence.save if @residence.save
redirect_to verified_user_path, notice: t('verification.residence.create.flash.success') redirect_to verified_user_path, notice: t('verification.residence.create.flash.success')
else else

View File

@@ -1,4 +1,4 @@
class Residence class Verification::Residence
include ActiveModel::Model include ActiveModel::Model
include ActiveModel::Dates include ActiveModel::Dates

View File

@@ -3,7 +3,7 @@
<h1 class="inline-block"><%= t('verification.residence.new.title') %></h1> <h1 class="inline-block"><%= t('verification.residence.new.title') %></h1>
<%= form_for @residence, url: residence_path do |f| %> <%= form_for @residence, as: "residence", url: residence_path do |f| %>
<%= render 'errors' %> <%= render 'errors' %>
<%= f.select :document_type, document_types, prompt: "" %> <%= f.select :document_type, document_types, prompt: "" %>

View File

@@ -20,7 +20,7 @@ FactoryGirl.define do
uid "MyString" uid "MyString"
end end
factory :residence do factory :verification_residence, class: Verification::Residence do
document_number '12345678Z' document_number '12345678Z'
document_type 1 document_type 1
date_of_birth Date.new(1980, 12, 31) date_of_birth Date.new(1980, 12, 31)

View File

@@ -1,8 +1,8 @@
require 'rails_helper' require 'rails_helper'
describe Residence do describe Verification::Residence do
let(:residence) { build(:residence) } let(:residence) { build(:verification_residence) }
describe "validations" do describe "validations" do
@@ -12,12 +12,12 @@ describe Residence do
describe "dates" do describe "dates" do
it "should be valid with a valid date of birth" do it "should be valid with a valid date of birth" do
residence = Residence.new({"date_of_birth(3i)"=>"1", "date_of_birth(2i)"=>"1", "date_of_birth(1i)"=>"1980"}) residence = Verification::Residence.new({"date_of_birth(3i)"=>"1", "date_of_birth(2i)"=>"1", "date_of_birth(1i)"=>"1980"})
expect(residence.errors[:date_of_birth].size).to eq(0) expect(residence.errors[:date_of_birth].size).to eq(0)
end end
it "should not be valid without a date of birth" do it "should not be valid without a date of birth" do
residence = Residence.new({"date_of_birth(3i)"=>"", "date_of_birth(2i)"=>"", "date_of_birth(1i)"=>""}) residence = Verification::Residence.new({"date_of_birth(3i)"=>"", "date_of_birth(2i)"=>"", "date_of_birth(1i)"=>""})
residence.valid? residence.valid?
expect(residence.errors[:date_of_birth]).to include("can't be blank") expect(residence.errors[:date_of_birth]).to include("can't be blank")
end end
@@ -28,7 +28,7 @@ describe Residence do
residence.user = user residence.user = user
residence.save residence.save
residence2 = build(:residence) residence2 = build(:verification_residence)
residence.valid? residence.valid?
expect(residence.errors[:document_number]).to include("Already in use") expect(residence.errors[:document_number]).to include("Already in use")