Skip to content

Fix regression switching between organizations #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class OrganizationsController < ApplicationController
before_filter :load_resource, only: [:show, :edit, :update, :destroy]
before_filter :load_resource, only: [:show, :edit, :update, :destroy, :set_current]

def new
@organization = Organization.new
Expand Down Expand Up @@ -41,6 +41,8 @@ def destroy
redirect_to organizations_path, notice: "deleted"
end

# POST /organizations/:organization_id/set_current
#
def set_current
if current_user
session[:current_organization_id] = @organization.id
Expand Down
18 changes: 15 additions & 3 deletions spec/controllers/organizations_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
require 'spec_helper'

describe OrganizationsController do
describe '#show' do
let(:organization) { Fabricate(:organization) }
RSpec.describe OrganizationsController do
let(:organization) { Fabricate(:organization) }
let(:member) { Fabricate(:member, organization: organization) }
let(:user) { member.user }

describe '#show' do
it 'links to new_transfer_path' do
get 'show', id: organization.id
expect(response.body).to include(
"<a href=\"/transfers/new?destination_account_id=#{organization.account.id}&amp;id=#{organization.id}\">"
)
end
end

describe '#set_current' do
before { login(user) }

it 'stores the given organization as current organization in session' do
post 'set_current', id: organization.id

expect(session[:current_organization_id]).to eq(organization.id)
end
end
end