Skip to content

Commit

Permalink
fix authorization mishap
Browse files Browse the repository at this point in the history
we did some authorization debugging earlier, and it
seems we left a line commented out by accident.
  • Loading branch information
Ivar Nymoen committed Jul 28, 2010
1 parent 92f3c9e commit dfe1647
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/vat_accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class VatAccountsController < ApplicationController
# GET /vat_accounts
# GET /vat_accounts.xml
def index
@vat_accounts = VatAccount.with_permissions_to(:index).all(:order => "accounts.number", :include => :target_account)
@vat_accounts = VatAccount.with_permissions_to(:index).where(:company_id => current_user.current_company.id).order("accounts.number").includes("target_account")

respond_to do |format|
format.html # index.html.erb
Expand Down
2 changes: 1 addition & 1 deletion config/authorization_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
has_permission_on :accounts, :to => :create

has_permission_on :vat_accounts, :to => :manage do
# if_attribute :company_id => is {user.current_company.id}
if_attribute :company_id => is {user.current_company.id}
end
has_permission_on :vat_accounts, :to => :create

Expand Down
17 changes: 16 additions & 1 deletion test/functional/vat_accounts_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
require 'test_helper'

class VATAccountsControllerTest < ActionController::TestCase
class VatAccountsControllerTest < ActionController::TestCase

setup do
log_in_as_bob
end

test "should not display other companies vat accounts" do
get :index

assert_response :success
assert_template :index

not_ours = assigns(:vat_accounts).select {|va| va.company != @company}
assert not_ours.empty?, "It seems we're listing #{not_ours.size} vat accounts which belong to another company."
end

end

0 comments on commit dfe1647

Please sign in to comment.