diff --git a/app/controllers/verification/sms_controller.rb b/app/controllers/verification/sms_controller.rb index e0080753e..9e18453ad 100644 --- a/app/controllers/verification/sms_controller.rb +++ b/app/controllers/verification/sms_controller.rb @@ -6,11 +6,11 @@ class Verification::SmsController < ApplicationController skip_authorization_check def new - @sms = Sms.new(phone: params[:phone]) + @sms = Verification::Sms.new(phone: params[:phone]) end def create - @sms = Sms.new(sms_params.merge(user: current_user)) + @sms = Verification::Sms.new(sms_params.merge(user: current_user)) if @sms.save redirect_to edit_sms_path, notice: t('verification.sms.create.flash.success') else @@ -19,11 +19,11 @@ class Verification::SmsController < ApplicationController end def edit - @sms = Sms.new + @sms = Verification::Sms.new end def update - @sms = Sms.new(sms_params.merge(user: current_user)) + @sms = Verification::Sms.new(sms_params.merge(user: current_user)) if @sms.verify? current_user.update(confirmed_phone: current_user.unconfirmed_phone) diff --git a/app/models/sms.rb b/app/models/verification/sms.rb similarity index 97% rename from app/models/sms.rb rename to app/models/verification/sms.rb index 61b06a091..f280f115e 100644 --- a/app/models/sms.rb +++ b/app/models/verification/sms.rb @@ -1,4 +1,4 @@ -class Sms +class Verification::Sms include ActiveModel::Model attr_accessor :user, :phone, :confirmation_code diff --git a/app/views/verification/sms/_form.html.erb b/app/views/verification/sms/_form.html.erb index efa0f74b8..9aaaa1495 100644 --- a/app/views/verification/sms/_form.html.erb +++ b/app/views/verification/sms/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_for sms, url: sms_path do |f| %> +<%= form_for sms, as: "sms", url: sms_path do |f| %> <%= render 'shared/errors', resource: sms %> <%= f.hidden_field :phone %> <%= f.submit t('verification.sms.form.submit_button') %> diff --git a/app/views/verification/sms/edit.html.erb b/app/views/verification/sms/edit.html.erb index 89fbef5ff..7432af7eb 100644 --- a/app/views/verification/sms/edit.html.erb +++ b/app/views/verification/sms/edit.html.erb @@ -3,7 +3,7 @@

<%= t('verification.sms.edit.title') %>

- <%= form_for @sms, url: sms_path, method: :put do |f| %> + <%= form_for @sms, as: "sms", url: sms_path, method: :put do |f| %>

<%= @error %>

<%= f.text_field :confirmation_code %> diff --git a/app/views/verification/sms/new.html.erb b/app/views/verification/sms/new.html.erb index eec63f6c6..8050c0f90 100644 --- a/app/views/verification/sms/new.html.erb +++ b/app/views/verification/sms/new.html.erb @@ -3,7 +3,7 @@

<%= t('verification.sms.new.title') %>

- <%= form_for @sms, url: sms_path do |f| %> + <%= form_for @sms, as: "sms", url: sms_path do |f| %> <%= render 'shared/errors', resource: @sms %> <%= f.text_field :phone %> diff --git a/app/views/verification/verified_user/show.html.erb b/app/views/verification/verified_user/show.html.erb index bb61e8546..53f871c76 100644 --- a/app/views/verification/verified_user/show.html.erb +++ b/app/views/verification/verified_user/show.html.erb @@ -32,7 +32,7 @@ <%= verified_user.phone %> - <%= render '/verification/sms/form', sms: Sms.new(phone: verified_user.phone) %> + <%= render '/verification/sms/form', sms: Verification::Sms.new(phone: verified_user.phone) %>


diff --git a/spec/factories.rb b/spec/factories.rb index 1745c0427..578d7b250 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -27,7 +27,7 @@ FactoryGirl.define do postal_code "28013" end - factory :sms do + factory :verification_sms, class: Verification::Sms do phone "699999999" end diff --git a/spec/models/sms_spec.rb b/spec/models/sms_spec.rb index bdcd2d739..f52ff3c6e 100644 --- a/spec/models/sms_spec.rb +++ b/spec/models/sms_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -describe Sms do +describe Verification::Sms do it "should be valid" do - sms = build(:sms) + sms = build(:verification_sms) expect(sms).to be_valid end it "should validate uniqness of phone" do user = create(:user, confirmed_phone: "699999999") - sms = Sms.new(phone: "699999999") + sms = Verification::Sms.new(phone: "699999999") expect(sms).to_not be_valid end