Skip to content

Commit 516bd35

Browse files
authored
Merge pull request #382 from coopdevs/fix/set-current-org
Fix regression switching between organizations
2 parents 8614f55 + 54f0ead commit 516bd35

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

app/controllers/organizations_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class OrganizationsController < ApplicationController
2-
before_filter :load_resource, only: [:show, :edit, :update, :destroy]
2+
before_filter :load_resource, only: [:show, :edit, :update, :destroy, :set_current]
33

44
def new
55
@organization = Organization.new
@@ -41,6 +41,8 @@ def destroy
4141
redirect_to organizations_path, notice: "deleted"
4242
end
4343

44+
# POST /organizations/:organization_id/set_current
45+
#
4446
def set_current
4547
if current_user
4648
session[:current_organization_id] = @organization.id
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
require 'spec_helper'
22

3-
describe OrganizationsController do
4-
describe '#show' do
5-
let(:organization) { Fabricate(:organization) }
3+
RSpec.describe OrganizationsController do
4+
let(:organization) { Fabricate(:organization) }
5+
let(:member) { Fabricate(:member, organization: organization) }
6+
let(:user) { member.user }
67

8+
describe '#show' do
79
it 'links to new_transfer_path' do
810
get 'show', id: organization.id
911
expect(response.body).to include(
1012
"<a href=\"/transfers/new?destination_account_id=#{organization.account.id}&amp;id=#{organization.id}\">"
1113
)
1214
end
1315
end
16+
17+
describe '#set_current' do
18+
before { login(user) }
19+
20+
it 'stores the given organization as current organization in session' do
21+
post 'set_current', id: organization.id
22+
23+
expect(session[:current_organization_id]).to eq(organization.id)
24+
end
25+
end
1426
end

0 commit comments

Comments
 (0)