1
0
Fork 0

Remove membership applications

This commit is contained in:
Alex Kotov 2019-05-03 12:42:44 +05:00
parent d00efc38a0
commit 325fe233ed
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
43 changed files with 0 additions and 996 deletions

View File

@ -1,56 +0,0 @@
# frozen_string_literal: true
class MembershipAppsController < ApplicationController
before_action :set_membership_app, only: :show
before_action :verify_joined, only: :show
before_action :verify_not_joined, only: :new
# GET /membership_app
def show
authorize @membership_app
end
# GET /join
def new
@membership_app = MembershipApp.new
authorize @membership_app
end
# POST /join
def create
@membership_app = MembershipApp.new permitted_attributes MembershipApp
authorize @membership_app
@membership_app.account = current_account || Account.new
return render :new unless @membership_app.save
ProcessNewMembershipApp.call membership_app: @membership_app
remember_if_guest_account @membership_app.account
redirect_to application_url guest_token: @membership_app.account.guest_token
end
private
def set_membership_app
@membership_app = current_account&.own_membership_app
end
def verify_joined
return if current_account&.own_membership_app
skip_authorization
redirect_to join_url
end
def verify_not_joined
return if current_account&.own_membership_app.nil?
skip_authorization
redirect_to application_url
end
end

View File

@ -1,25 +0,0 @@
# frozen_string_literal: true
class Staffs::MembershipAppsController < ApplicationController
before_action :set_membership_app, except: :index
# GET /staff/membership_apps
def index
authorize %i[staff membership_app]
@membership_apps = policy_scope(
MembershipApp,
policy_scope_class: Staff::MembershipAppPolicy::Scope,
)
end
# GET /staff/membership_apps/:id
def show
authorize [:staff, @membership_app]
end
private
def set_membership_app
@membership_app = MembershipApp.find params[:id]
end
end

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class ProcessNewMembershipApp
include Interactor
def call
MembershipAppMailer.with(context).tracking.deliver_now
end
end

View File

@ -1,18 +0,0 @@
# frozen_string_literal: true
class MembershipAppMailer < ApplicationMailer
before_action :set_membership_app
def tracking
mail(
to: @membership_app.email,
subject: translate('membership_app_mailer.tracking.subject'),
)
end
private
def set_membership_app
@membership_app = params[:membership_app]
end
end

View File

@ -35,10 +35,6 @@ class Account < ApplicationRecord
has_one :user, dependent: :restrict_with_exception
has_one :own_membership_app,
class_name: 'MembershipApp',
dependent: :restrict_with_exception
has_many :passport_confirmations, dependent: :restrict_with_exception
#############

View File

@ -7,8 +7,6 @@ class CountryState < ApplicationRecord
has_one :regional_office, dependent: :restrict_with_exception
has_many :membership_apps, dependent: :restrict_with_exception
###############
# Validations #
###############

View File

@ -1,40 +0,0 @@
# frozen_string_literal: true
class MembershipApp < ApplicationRecord
################
# Associations #
################
belongs_to :account, inverse_of: :own_membership_app
belongs_to :country_state, optional: true
has_one :regional_office, through: :country_state
has_one :person, through: :account, inverse_of: :own_membership_app
###############
# Validations #
###############
validates :email, presence: true, format: Devise.email_regexp
validates :first_name, presence: true
validates :last_name, presence: true
validates :date_of_birth, presence: true
validates :phone_number, presence: true
validates :account, uniqueness: true
#############
# Callbacks #
#############
before_validation do
email&.strip!
self.middle_name = nil if middle_name.blank?
self.occupation = nil if occupation.blank?
self.telegram_username = nil if telegram_username.blank?
self.organization_membership = nil if organization_membership.blank?
self.comment = nil if comment.blank?
end
end

View File

@ -25,12 +25,6 @@ class Person < ApplicationRecord
has_many :resident_registrations, dependent: :restrict_with_exception
has_one :own_membership_app,
class_name: 'MembershipApp',
inverse_of: :person,
through: :account,
source: :own_membership_app
###############
# Validations #
###############

View File

@ -7,8 +7,6 @@ class RegionalOffice < ApplicationRecord
belongs_to :country_state
has_many :membership_apps, through: :country_state
has_many :people, dependent: :restrict_with_exception
has_many :relationships, dependent: :restrict_with_exception

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
class MembershipAppPolicy < ApplicationPolicy
def show?
!create?
end
def create?
account.nil? || account.own_membership_app.nil?
end
def permitted_attributes_for_create
%i[
first_name last_name middle_name date_of_birth occupation email
phone_number telegram_username organization_membership comment
country_state_id
]
end
end

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
class Staff::MembershipAppPolicy < ApplicationPolicy
def index?
account&.is_superuser?
end
def show?
account&.is_superuser?
end
class Scope < Scope
def resolve
return scope.all if account&.is_superuser?
scope.none
end
end
end

View File

@ -6,18 +6,6 @@
<p class="lead">
<%= translate '.description' %>
</p>
<% if policy(:membership_app).new? %>
<a role="button" class="btn btn-primary btn-lg" href="<%= join_path %>">
<%= translate '.join' %>
</a>
<% end %>
<% if policy(:membership_app).show? %>
<a role="button" class="btn btn-success btn-lg" href="<%= application_path %>">
<%= translate '.tracking' %>
</a>
<% end %>
</div>
</div>
<% end %>

View File

@ -1,4 +0,0 @@
<p><%= translate '.lead_text' %></p>
<%= link_to application_url(guest_token: @membership_app.account.guest_token),
application_url(guest_token: @membership_app.account.guest_token) %>

View File

@ -1,18 +0,0 @@
<div class="container">
<%= simple_form_for @membership_app, url: join_path do |f| %>
<%= f.input :last_name %>
<%= f.input :first_name %>
<%= f.input :middle_name %>
<%= f.input :date_of_birth, start_year: Date.today.year - 150,
end_year: Date.today.year %>
<%= f.association :country_state, collection: CountryState.all %>
<%= f.input :occupation %>
<%= f.input :email %>
<%= f.input :phone_number %>
<%= f.input :telegram_username %>
<%= f.input :organization_membership %>
<%= f.input :comment %>
<%= f.button :submit %>
<% end %>
</div>

View File

@ -1,16 +0,0 @@
<div class="container">
<% if @membership_app.person&.party_member? %>
<h1><%= translate '.congratulations' %></h1>
<p class="lead"><%= translate '.lead_congratulations_member' %></p>
<% elsif @membership_app.person&.party_supporter? %>
<h1><%= translate '.congratulations' %></h1>
<p class="lead"><%= translate '.lead_congratulations_supporter' %></p>
<% elsif @membership_app.person&.excluded_from_party? %>
<h1><%= translate '.excluded' %></h1>
<p class="lead"><%= translate '.lead_excluded' %></p>
<% else %>
<h1><%= translate '.header' %></h1>
<p class="lead"><%= translate '.lead_text' %></p>
<hr/>
<% end %>
</div>

View File

@ -11,12 +11,5 @@
<%= link_to Passport.model_name.human(count: 0), staff_passports_path %>
</li>
<% end %>
<% if policy([:staff, :membership_app]).index? %>
<li>
<%= link_to MembershipApp.model_name.human(count: 0),
staff_membership_apps_path %>
</li>
<% end %>
</ul>
</div>

View File

@ -1,40 +0,0 @@
<div class="container">
<table class="table">
<thead>
<tr>
<th scope="col">
<%= MembershipApp.human_attribute_name :id %>
</th>
<th scope="col">
<%= MembershipApp.human_attribute_name :last_name %>
</th>
<th scope="col">
<%= MembershipApp.human_attribute_name :first_name %>
</th>
<th scope="col">
<%= MembershipApp.human_attribute_name :middle_name %>
</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<% @membership_apps.each do |membership_app| %>
<tr>
<td scope="row"><%= membership_app.id %></td>
<td><%= truncate membership_app.last_name, length: 20 %></td>
<td><%= truncate membership_app.first_name, length: 20 %></td>
<td><%= truncate membership_app.middle_name, length: 20 %></td>
<td>
<% if policy([:staff, membership_app]).show? %>
<%= link_to [:staff, membership_app],
role: :button, class: 'btn btn-light btn-sm' do %>
<i class="far fa-eye"></i>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@ -1,12 +0,0 @@
<div class="container">
<dl>
<dt><%= MembershipApp.human_attribute_name :last_name %></dt>
<dd><%= truncate @membership_app.last_name %></dd>
<dt><%= MembershipApp.human_attribute_name :first_name %></dt>
<dd><%= truncate @membership_app.first_name %></dd>
<dt><%= MembershipApp.human_attribute_name :middle_name %></dt>
<dd><%= truncate @membership_app.middle_name %></dd>
</dl>
</div>

View File

@ -7,9 +7,6 @@ en:
country_state:
one: State
many: States
membership_app:
one: Membership application
many: Membership applications
passport:
one: Passport
many: Passports
@ -40,22 +37,8 @@ en:
avatar: Avatar
country_state:
id: ID
membership_apps: Membership applications
english_name: Name
native_name: Name
membership_app:
id: ID
country_state: State
first_name: First name
last_name: Last name
middle_name: Middle name
date_of_birth: Date of birth
occupation: Occupation
email: Email
phone_number: Phone number
telegram_username: Telegram username
organization_membership: Membership in other social organizations
comment: Comment
passport:
id: ID
confirmed: Confirmed?

View File

@ -7,9 +7,6 @@ ru:
country_state:
one: Регион
many: Регионы
membership_app:
one: Заявление на вступление
many: Заявления на вступление
passport:
one: Паспорт
many: Паспорта
@ -40,22 +37,8 @@ ru:
avatar: Аватар
country_state:
id: ID
membership_apps: Заявления на вступление
english_name: Название
native_name: Название
membership_app:
id: ID
country_state: Регион
first_name: Имя
last_name: Фамилия
middle_name: Отчество
date_of_birth: Дата рождения
occupation: Профессия или род деятельности
email: Адрес электронной почты
phone_number: Телефонный номер
telegram_username: Имя пользователя в Telegram
organization_membership: Членство в других общественных организациях
comment: Комментарий
passport:
id: ID
confirmed: Подтверждён?

View File

@ -1,8 +1,5 @@
en:
helpers:
submit:
membership_app:
create: Send application
person_status:
not_in_party: Is not related to the party
supporter: Party supporter

View File

@ -1,8 +1,5 @@
ru:
helpers:
submit:
membership_app:
create: Отправить заявление
person_status:
not_in_party: Не относится к партии
supporter: Сторонник партии

View File

@ -10,11 +10,3 @@ en:
# html: '<abbr title="required">*</abbr>'
error_notification:
default_message: 'Please review the problems below:'
labels:
membership_app:
country_state:
Main region of residence
hints:
membership_app:
country_state:
If the appropriate option is not listed, enter it in the comment

View File

@ -10,11 +10,3 @@ ru:
# html: '<abbr title="обязательно">*</abbr>'
error_notification:
default_message: 'Пожалуйста, исправьте следующие ошибки:'
labels:
membership_app:
country_state:
Регион преимущественного проживания
hints:
membership_app:
country_state:
Если подходящего варианта нет в списке, укажите его в комментарии

View File

@ -7,29 +7,6 @@ en:
We stand for a free market and freedom of government intervention
in the economy, for the principle of self-ownership and self-value
of the human person.
membership_apps:
show:
congratulations: Congratulations!
excluded: You are excluded from party
header: Your application is being processed
lead_congratulations_supporter: >
You are already a supporter of the Libertarian party of Russia!
lead_congratulations_member: >
You are already a member of the Libertarian party of Russia!
lead_excluded:
You was excluded from Libertarian party of Russia
and can not apply for entry.
lead_text: >
You can track the status of your application on this page. Save it
to browser bookmarks. Also the link to this page was sent to email
address which you have provided. You will be contacted by provided
contacts soon.
membership_app_mailer:
tracking:
subject: Your application is being processed
lead_text: >
You can track the status of your application by the following link.
You will be contacted by provided contacts soon.
passports:
show:
confirm: Confirm

View File

@ -7,30 +7,6 @@ ru:
Мы выступаем за свободный рынок и государственное невмешательство
в экономику, за принцип самопринадлежности и самоценности человеческой
личности.
membership_apps:
show:
congratulations: Поздравляем!
excluded: Вы исключены из партии
header: Ваше заявление в обработке
lead_congratulations_supporter: >
Вы уже являетесь сторонником Либертарианской партии России!
lead_congratulations_member: >
Вы уже являетесь членом Либертарианской партии России!
lead_excluded:
Вы были исключены из Либертарианской партии России
и не можете подать заявление на вступление.
lead_text: >
На данной странице вы можете отслеживать статус вашего заявления.
Сохраните её в закладки браузера. Также на указанный вами адрес
электронной почты была отправлена ссылка на данную страницу.
В ближайшее время с вами свяжутся по указанным вами контактам.
membership_app_mailer:
tracking:
subject: Ваше заявление в обработке
lead_text: >
По приведённой ниже ссылке вы можете отслеживать статус вашего
заявления. В ближайшее время с вами свяжутся по указанным вами
контактам.
passports:
show:
confirm: Подтвердить

View File

@ -9,10 +9,6 @@ Rails.application.routes.draw do
root to: 'home#show'
get :application, to: 'membership_apps#show'
get :join, to: 'membership_apps#new'
post :join, to: 'membership_apps#create'
resources :accounts, param: :nickname, only: :show
resources :country_states, only: %i[index show]
@ -68,7 +64,5 @@ Rails.application.routes.draw do
controller: 'passports/passport_confirmations',
only: %i[index create]
end
resources :membership_apps, only: %i[index show]
end
end

View File

@ -1,19 +0,0 @@
# frozen_string_literal: true
FactoryBot.define do
factory :membership_app do
association :account, factory: :guest_account
association :country_state
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
middle_name { Faker::Name.first_name }
date_of_birth { Faker::Date.backward }
occupation { Faker::Company.profession }
email { Faker::Internet.email }
phone_number { Faker::PhoneNumber.phone_number }
telegram_username { Faker::Internet.username }
organization_membership { Faker::Lorem.paragraph }
comment { Faker::Lorem.paragraph }
end
end

View File

@ -1,7 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ProcessNewMembershipApp do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,7 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe MembershipAppMailer do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,10 +0,0 @@
# frozen_string_literal: true
class MembershipAppPreview < ActionMailer::Preview
# http://localhost:3000/rails/mailers/membership_app/tracking
def tracking
membership_app = MembershipApp.find params[:id]
MembershipAppMailer.with(membership_app: membership_app).tracking
end
end

View File

@ -26,13 +26,6 @@ RSpec.describe Account do
.through(:account_roles)
end
it do
is_expected.to \
have_one(:own_membership_app)
.class_name('MembershipApp')
.dependent(:restrict_with_exception)
end
it do
is_expected.to \
have_many(:passport_confirmations)

View File

@ -11,12 +11,6 @@ RSpec.describe CountryState do
.dependent(:restrict_with_exception)
end
it do
is_expected.to \
have_many(:membership_apps)
.dependent(:restrict_with_exception)
end
it { is_expected.not_to validate_presence_of :regional_office }
it { is_expected.to validate_presence_of :english_name }

View File

@ -1,143 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe MembershipApp do
subject { create :membership_app }
it { is_expected.to belong_to(:account).inverse_of(:own_membership_app) }
it { is_expected.to belong_to(:country_state).optional }
it { is_expected.to have_one(:regional_office).through(:country_state) }
it do
is_expected.to \
have_one(:person)
.through(:account)
.inverse_of(:own_membership_app)
end
it { is_expected.to validate_presence_of(:account).with_message(:required) }
it { is_expected.not_to validate_presence_of :country_state }
it { is_expected.to validate_presence_of :first_name }
it { is_expected.to validate_presence_of :last_name }
it { is_expected.not_to validate_presence_of :middle_name }
it { is_expected.to validate_presence_of :date_of_birth }
it { is_expected.not_to validate_presence_of :occupation }
it { is_expected.to validate_presence_of :email }
it { is_expected.to validate_presence_of :phone_number }
it { is_expected.not_to validate_presence_of :telegram_username }
it { is_expected.not_to validate_presence_of :organization_membership }
it { is_expected.not_to validate_presence_of :comment }
it { is_expected.to validate_uniqueness_of :account }
describe '#email' do
def allow_value(*)
super.for :email
end
it { is_expected.to allow_value Faker::Internet.email }
it { is_expected.not_to allow_value Faker::Internet.username }
context 'when it has extra spaces' do
subject { create :membership_app, email: " #{email} " }
let(:email) { Faker::Internet.email }
specify do
expect(subject.email).to eq email
end
end
end
describe '#middle_name' do
context 'when it is empty' do
subject { create :membership_app, middle_name: '' }
specify do
expect(subject.middle_name).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, middle_name: ' ' }
specify do
expect(subject.middle_name).to eq nil
end
end
end
describe '#occupation' do
context 'when it is empty' do
subject { create :membership_app, occupation: '' }
specify do
expect(subject.occupation).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, occupation: ' ' }
specify do
expect(subject.occupation).to eq nil
end
end
end
describe '#telegram_username' do
context 'when it is empty' do
subject { create :membership_app, telegram_username: '' }
specify do
expect(subject.telegram_username).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, telegram_username: ' ' }
specify do
expect(subject.telegram_username).to eq nil
end
end
end
describe '#organization_membership' do
context 'when it is empty' do
subject { create :membership_app, organization_membership: '' }
specify do
expect(subject.organization_membership).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, organization_membership: ' ' }
specify do
expect(subject.organization_membership).to eq nil
end
end
end
describe '#comment' do
context 'when it is empty' do
subject { create :membership_app, comment: '' }
specify do
expect(subject.comment).to eq nil
end
end
context 'when it is blank' do
subject { create :membership_app, comment: ' ' }
specify do
expect(subject.comment).to eq nil
end
end
end
end

View File

@ -39,15 +39,6 @@ RSpec.describe Person do
.dependent(:restrict_with_exception)
end
it do
is_expected.to \
have_one(:own_membership_app)
.class_name('MembershipApp')
.inverse_of(:person)
.through(:account)
.source(:own_membership_app)
end
it { is_expected.not_to validate_presence_of :regional_office }
describe '#relationships' do

View File

@ -7,8 +7,6 @@ RSpec.describe RegionalOffice do
it { is_expected.to belong_to :country_state }
it { is_expected.to have_many(:membership_apps).through(:country_state) }
it { is_expected.to have_many(:people).dependent(:restrict_with_exception) }
it do

View File

@ -1,37 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe MembershipAppPolicy do
subject { described_class.new account, record }
let :resolved_scope do
described_class::Scope.new(account, MembershipApp.all).resolve
end
let!(:record) { create :membership_app, account: owner }
let!(:other_record) { create :membership_app }
let(:owner) { create %i[guest_account usual_account].sample }
context 'when owner is authenticated' do
let(:account) { owner }
it { is_expected.to permit_action :show }
it { is_expected.to forbid_new_and_create_actions }
it { is_expected.to forbid_actions %i[index destroy] }
it { is_expected.to forbid_edit_and_update_actions }
specify { expect(resolved_scope).to be_empty }
end
for_account_types nil, :guest, :usual, :superuser do
it { is_expected.to permit_new_and_create_actions }
it { is_expected.to forbid_actions %i[index show destroy] }
it { is_expected.to forbid_edit_and_update_actions }
specify { expect(resolved_scope).to be_empty }
end
end

View File

@ -1,49 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Staff::MembershipAppPolicy do
subject { described_class.new account, record }
let :resolved_scope do
described_class::Scope.new(account, MembershipApp.all).resolve
end
let!(:record) { create :membership_app, account: owner }
let!(:other_record) { create :membership_app }
before { create_list :membership_app, 3 }
let(:owner) { create %i[guest_account usual_account].sample }
context 'when owner is authenticated' do
let(:account) { owner }
it { is_expected.to forbid_actions %i[index show destroy] }
it { is_expected.to forbid_new_and_create_actions }
it { is_expected.to forbid_edit_and_update_actions }
specify { expect(resolved_scope).to be_empty }
end
for_account_types nil, :guest, :usual do
it { is_expected.to forbid_actions %i[index show destroy] }
it { is_expected.to forbid_new_and_create_actions }
it { is_expected.to forbid_edit_and_update_actions }
specify { expect(resolved_scope).to be_empty }
end
for_account_types :superuser do
it { is_expected.to permit_actions %i[index show] }
it { is_expected.to forbid_new_and_create_actions }
it { is_expected.to forbid_edit_and_update_actions }
it { is_expected.to forbid_action :destroy }
specify { expect(resolved_scope).to eq MembershipApp.all }
specify { expect(resolved_scope).to include record }
specify { expect(resolved_scope).to include other_record }
end
end

View File

@ -1,160 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'POST /join' do
let(:current_account) { nil }
let :membership_app_plain_attributes do
attributes_for :membership_app
end
let :membership_app_all_attributes do
membership_app_plain_attributes.merge(
country_state_id: country_state&.id,
)
end
let(:country_state) { create :country_state }
before do
sign_in current_account.user if current_account&.user
if current_account&.guest?
get root_url guest_token: current_account.guest_token
end
end
def make_request
post '/join', params: {
membership_app: membership_app_all_attributes,
}
end
specify do
expect { make_request }.to \
change(MembershipApp, :count).from(0).to(1)
end
specify do
expect { make_request }.to \
change(Account, :count).from(0).to(1)
end
specify do
expect { make_request }.to \
change(ActionMailer::Base.deliveries, :count).from(0).to(1)
end
context 'when guest owner is authenticated' do
let!(:membership_app) { create :membership_app, account: owner }
let(:owner) { create :guest_account }
let(:current_account) { owner }
specify do
expect { make_request }.not_to change(MembershipApp, :count).from(1)
end
specify do
expect { make_request }.not_to change(Account, :count).from(1)
end
context 'after request' do
before { make_request }
specify do
expect(response).to have_http_status :forbidden
end
end
end
context 'when usual owner is authenticated' do
let!(:membership_app) { create :membership_app, account: owner }
let(:owner) { create :usual_account }
let(:current_account) { owner }
specify do
expect { make_request }.not_to change(MembershipApp, :count).from(1)
end
specify do
expect { make_request }.not_to change(Account, :count).from(2)
end
context 'after request' do
before { make_request }
specify do
expect(response).to have_http_status :forbidden
end
end
end
context 'after request' do
before { make_request }
specify do
membership_app = MembershipApp.last
expect(response).to redirect_to application_url(
guest_token: membership_app.account.guest_token,
)
end
specify do
expect(MembershipApp.last).to \
have_attributes membership_app_plain_attributes
end
specify do
expect(MembershipApp.last).to have_attributes(
country_state: country_state,
)
end
specify do
expect(ActionMailer::Base.deliveries.last).to have_attributes(
from: [Rails.application.config.noreply_email_address],
to: [MembershipApp.last.email],
subject: I18n.t('membership_app_mailer.tracking.subject'),
)
end
end
context 'when country state is not specified' do
let(:country_state) { nil }
specify do
expect { make_request }.to \
change(MembershipApp, :count).from(0).to(1)
end
specify do
expect { make_request }.to \
change(Account, :count).from(0).to(1)
end
context 'after request' do
before { make_request }
specify do
membership_app = MembershipApp.last
expect(response).to redirect_to application_url(
guest_token: membership_app.account.guest_token,
)
end
specify do
expect(MembershipApp.last).to \
have_attributes membership_app_plain_attributes
end
specify do
expect(MembershipApp.last).to have_attributes(
country_state: nil,
)
end
end
end
end

View File

@ -1,43 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'GET /join' do
let!(:membership_app) { create :membership_app, account: owner }
let(:owner) { create :guest_account }
before do
sign_in current_account.user if current_account&.user
if current_account&.guest?
get root_url guest_token: current_account.guest_token
end
get '/join'
end
for_account_types nil, :guest, :usual, :superuser do
specify do
expect(response).to have_http_status :ok
end
end
context 'when guest owner is authenticated' do
let(:owner) { create :guest_account }
let(:current_account) { owner }
specify do
expect(response).to redirect_to application_url
end
end
context 'when usual owner is authenticated' do
let(:owner) { create :usual_account }
let(:current_account) { owner }
specify do
expect(response).to redirect_to application_url
end
end
end

View File

@ -1,30 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'GET /application' do
let! :membership_app do
create :membership_app, account: owner
end
let(:owner) { create :usual_account }
before do
sign_in current_account&.user if current_account&.user
get '/application'
end
context 'when owner is authenticated' do
let(:current_account) { owner }
specify do
expect(response).to have_http_status :ok
end
end
for_account_types nil, :guest, :usual, :superuser do
specify do
expect(response).to redirect_to join_url
end
end
end

View File

@ -1,25 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'GET /staff/membership_apps' do
before do
sign_in current_account.user if current_account&.user
create_list :membership_app, 5
get '/staff/membership_apps'
end
for_account_types nil, :guest, :usual do
specify do
expect(response).to have_http_status :forbidden
end
end
for_account_types :superuser do
specify do
expect(response).to have_http_status :ok
end
end
end

View File

@ -1,24 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'GET /staff/membership_apps/:id' do
let!(:membership_app) { create :membership_app }
before do
sign_in current_account.user if current_account&.user
get "/staff/membership_apps/#{membership_app.id}"
end
for_account_types nil, :guest, :usual do
specify do
expect(response).to have_http_status :forbidden
end
end
for_account_types :superuser do
specify do
expect(response).to have_http_status :ok
end
end
end