Provide destination_account to offers show view
This commit is contained in:
@ -18,4 +18,13 @@ class OffersController < PostsController
|
||||
offers[category] = list if list.present?
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
super
|
||||
@destination_account = @offer
|
||||
.user
|
||||
.members
|
||||
.find_by(organization: current_organization)
|
||||
.account
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe OffersController, type: :controller do
|
||||
let (:test_organization) { Fabricate(:organization) }
|
||||
let (:member) { Fabricate(:member, organization: test_organization) }
|
||||
let (:another_member) { Fabricate(:member, organization: test_organization) }
|
||||
let (:yet_another_member) { Fabricate(:member) }
|
||||
let (:test_category) { Fabricate(:category) }
|
||||
let! (:offer) do
|
||||
let(:test_organization) { Fabricate(:organization) }
|
||||
let(:member) { Fabricate(:member, organization: test_organization) }
|
||||
let(:another_member) { Fabricate(:member, organization: test_organization) }
|
||||
let(:yet_another_member) { Fabricate(:member) }
|
||||
let(:test_category) { Fabricate(:category) }
|
||||
let!(:offer) do
|
||||
Fabricate(:offer,
|
||||
user: member.user,
|
||||
organization: test_organization,
|
||||
category: test_category)
|
||||
end
|
||||
|
||||
include_context "stub browser locale"
|
||||
|
||||
before { set_browser_locale("ca") }
|
||||
|
||||
describe "GET #index" do
|
||||
@ -66,7 +68,15 @@ describe OffersController, type: :controller do
|
||||
get "show", id: offer.id
|
||||
expect(assigns(:offer)).to eq(offer)
|
||||
end
|
||||
|
||||
it 'assigns the account destination of the transfer' do
|
||||
login(another_member.user)
|
||||
|
||||
get :show, id: offer.id
|
||||
expect(assigns(:destination_account)).to eq(member.account)
|
||||
end
|
||||
end
|
||||
|
||||
context "without a logged in user" do
|
||||
it "assigns the requested offer to @offer" do
|
||||
get "show", id: offer.id
|
||||
|
||||
Reference in New Issue
Block a user