Skip to content

Commit b27d0d0

Browse files
committed
Do not fetch destination when the user is guest
1 parent 49aaef0 commit b27d0d0

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

app/controllers/offers_controller.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ def dashboard
2121

2222
def show
2323
super
24-
@destination_account = @offer
25-
.user
26-
.members
27-
.find_by(organization: current_organization)
28-
.account
24+
25+
if current_user
26+
@destination_account = @offer
27+
.user
28+
.members
29+
.find_by(organization: current_organization)
30+
.account
31+
end
2932
end
3033
end

spec/controllers/offers_controller_spec.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,22 @@
6262
describe "GET #show" do
6363
context "with valid params" do
6464
context "with a logged user" do
65-
it "assigns the requested offer to @offer" do
66-
login(another_member.user)
65+
before { login(another_member.user) }
6766

68-
get "show", id: offer.id
67+
it "assigns the requested offer to @offer" do
68+
get :show, id: offer.id
6969
expect(assigns(:offer)).to eq(offer)
7070
end
7171

7272
it 'assigns the account destination of the transfer' do
73-
login(another_member.user)
74-
7573
get :show, id: offer.id
7674
expect(assigns(:destination_account)).to eq(member.account)
7775
end
7876
end
7977

8078
context "without a logged in user" do
8179
it "assigns the requested offer to @offer" do
82-
get "show", id: offer.id
80+
get :show, id: offer.id
8381
expect(assigns(:offer)).to eq(offer)
8482
end
8583
end

0 commit comments

Comments
 (0)