-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require "test_helper" | ||
|
||
class Kiqr::CurrentHelperTest < ActionView::TestCase | ||
attr_reader :current_user | ||
|
||
setup do | ||
@current_user = create(:user) | ||
@team_account = create(:account, name: "Company 1") | ||
@alien_account = create(:account, name: "Someone else's account") | ||
@current_user.account_users << AccountUser.new(account: @team_account, owner: true) | ||
|
||
Current.user = @current_user | ||
end | ||
|
||
test "current_account returns the personal account by default" do | ||
assert_equal @current_user.personal_account, current_account | ||
end | ||
|
||
test "current_account can be a team account" do | ||
Current.account = @team_account | ||
assert_equal @team_account, current_account | ||
end | ||
|
||
test "current_account can't be another users account" do | ||
assert_raise { Current.account = @alien_account } | ||
end | ||
|
||
test "personal_account is always the users personal account" do | ||
Current.account = @team_account | ||
assert_equal @current_user.personal_account, personal_account | ||
end | ||
end |