Skip to content

Commit

Permalink
test: copy helpers test
Browse files Browse the repository at this point in the history
  • Loading branch information
kjellberg committed Jun 10, 2024
1 parent f26f11c commit aef6b6f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ gem "sprockets-rails"
# Start debugger with binding.b [https://github.com/ruby/debug]
# gem "debug", ">= 1.0.0"


group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
# gem "brakeman", "~> 6.1"
# gem "debug", platforms: %i[mri windows]

# Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/]
gem "rubocop-rails-omakase", require: false
gem 'rails-controller-testing'
gem "rails-controller-testing"

# gem "standard", require: false
# gem "erb_lint", require: false
Expand Down
Empty file added test/helpers/.keep
Empty file.
32 changes: 32 additions & 0 deletions test/helpers/kiqr/current_helper_test.rb
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

0 comments on commit aef6b6f

Please sign in to comment.