Change MembershipAppsController#show
This commit is contained in:
parent
0f18566c88
commit
98ed8f1cc8
8 changed files with 18 additions and 15 deletions
|
@ -2,9 +2,10 @@
|
|||
|
||||
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_apps/:id
|
||||
# GET /membership_app
|
||||
def show
|
||||
authorize @membership_app
|
||||
end
|
||||
|
@ -31,7 +32,6 @@ class MembershipAppsController < ApplicationController
|
|||
remember_if_guest_account @membership_app.account
|
||||
|
||||
redirect_to membership_app_url(
|
||||
@membership_app,
|
||||
guest_token: @membership_app.account.guest_token,
|
||||
)
|
||||
end
|
||||
|
@ -39,7 +39,14 @@ class MembershipAppsController < ApplicationController
|
|||
private
|
||||
|
||||
def set_membership_app
|
||||
@membership_app = MembershipApp.find params[:id]
|
||||
@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
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<% end %>
|
||||
|
||||
<% unless current_account&.own_membership_app.nil? %>
|
||||
<a role="button" class="btn btn-success btn-lg" href="<%= membership_app_path current_account.own_membership_app %>">
|
||||
<a role="button" class="btn btn-success btn-lg" href="<%= membership_app_path %>">
|
||||
<%= translate '.tracking' %>
|
||||
</a>
|
||||
<% end %>
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<p><%= translate '.lead_text' %></p>
|
||||
|
||||
<%= link_to membership_app_url(
|
||||
@membership_app,
|
||||
guest_token: @membership_app.account.guest_token,
|
||||
),
|
||||
membership_app_url(
|
||||
@membership_app,
|
||||
guest_token: @membership_app.account.guest_token,
|
||||
) %>
|
||||
|
|
|
@ -12,7 +12,7 @@ Rails.application.routes.draw do
|
|||
get :join, to: 'membership_apps#new'
|
||||
post :join, to: 'membership_apps#create'
|
||||
|
||||
resources :membership_apps, only: :show
|
||||
resource :membership_app, only: :show
|
||||
|
||||
###############
|
||||
# User routes #
|
||||
|
|
|
@ -16,5 +16,5 @@ Feature: Membership application
|
|||
| Членство в других общественных организациях | Не скажу |
|
||||
| Комментарий | Примите, плиз |
|
||||
And I click the form button "Отправить заявление"
|
||||
Then I am at "/membership_apps/\d+"
|
||||
Then I am at "/membership_app"
|
||||
And I see text "Ваше заявление в обработке"
|
||||
|
|
|
@ -9,7 +9,7 @@ Then 'I see membership application creation form' do
|
|||
end
|
||||
|
||||
Then 'I see the membership application tracking page' do
|
||||
expect(page.current_path).to match %r{\A/membership_apps/\d+\z}
|
||||
expect(page.current_path).to eq '/membership_app'
|
||||
expect(page).to have_css 'h2', text: 'Ваше заявление в обработке'
|
||||
end
|
||||
|
||||
|
|
|
@ -97,7 +97,6 @@ RSpec.describe 'POST /join' do
|
|||
membership_app = MembershipApp.last
|
||||
|
||||
expect(response).to redirect_to membership_app_url(
|
||||
membership_app,
|
||||
guest_token: membership_app.account.guest_token,
|
||||
)
|
||||
end
|
||||
|
@ -142,7 +141,6 @@ RSpec.describe 'POST /join' do
|
|||
membership_app = MembershipApp.last
|
||||
|
||||
expect(response).to redirect_to membership_app_url(
|
||||
membership_app,
|
||||
guest_token: membership_app.account.guest_token,
|
||||
)
|
||||
end
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'GET /membership_apps/:id' do
|
||||
let :membership_app do
|
||||
RSpec.describe 'GET /membership_app' do
|
||||
let! :membership_app do
|
||||
create :membership_app, account: owner
|
||||
end
|
||||
|
||||
|
@ -11,7 +11,7 @@ RSpec.describe 'GET /membership_apps/:id' do
|
|||
|
||||
before do
|
||||
sign_in current_account&.user if current_account&.user
|
||||
get "/membership_apps/#{membership_app.id}"
|
||||
get '/membership_app'
|
||||
end
|
||||
|
||||
context 'when owner is authenticated' do
|
||||
|
@ -24,7 +24,7 @@ RSpec.describe 'GET /membership_apps/:id' do
|
|||
|
||||
for_account_types nil, :guest, :usual, :superuser do
|
||||
specify do
|
||||
expect(response).to have_http_status :unauthorized
|
||||
expect(response).to redirect_to join_url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Reference in a new issue