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