Skip to content

Commit 8f3ca51

Browse files
committed
Only logged in users can access the payments page
1 parent ae7dbad commit 8f3ca51

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

app/controllers/payments_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class PaymentsController < ApplicationController
2+
before_action :is_logged_in?
3+
24
def new; end
35

46
def create

spec/features/payments_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require 'spec_helper'
2+
3+
RSpec.feature 'Payments', type: :feature do
4+
context 'a visitor to the website' do
5+
scenario 'cannot access the payments page' do
6+
visit new_payment_path
7+
8+
expect(page).to have_content('You must be logged in to access this page')
9+
end
10+
end
11+
12+
context 'a logged in user' do
13+
let(:member) { Fabricate(:member) }
14+
15+
before do
16+
login(member)
17+
end
18+
19+
scenario 'can access the payments page' do
20+
visit new_payment_path
21+
22+
expect(page).to have_content('Payments')
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)