diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-02-03 00:51:03 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-02-03 00:51:03 +0300 |
commit | 648826721f13ee4309a11638e538d96006648b39 (patch) | |
tree | 9e2cb1b728208671c4d653d32223a02d19f3fe82 /spec/helpers/user_callouts_helper_spec.rb | |
parent | 838cc0907c963a025553d639283b3bbf8140dae8 (diff) |
Rename Callout to UserCallout
Diffstat (limited to 'spec/helpers/user_callouts_helper_spec.rb')
-rw-r--r-- | spec/helpers/user_callouts_helper_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/helpers/user_callouts_helper_spec.rb b/spec/helpers/user_callouts_helper_spec.rb new file mode 100644 index 00000000000..42c2e7827b2 --- /dev/null +++ b/spec/helpers/user_callouts_helper_spec.rb @@ -0,0 +1,55 @@ +require "spec_helper" + +describe UserCalloutsHelper do + let(:user) { create(:user) } + + before do + allow(helper).to receive(:current_user).and_return(user) + end + + describe '.show_gke_cluster_integration_callout?' do + let(:project) { create(:project) } + + subject { helper.show_gke_cluster_integration_callout?(project) } + + context 'when user has not dismissed' do + before do + allow(helper).to receive(:user_dismissed?).and_return(false) + end + + context 'when user can create a cluster' do + before do + allow(helper).to receive(:can?).with(anything, :create_cluster, anything) + .and_return(true) + end + + it { is_expected.to be true } + end + + context 'when user can not create a cluster' do + before do + allow(helper).to receive(:can?).with(anything, :create_cluster, anything) + .and_return(false) + end + + it { is_expected.to be false } + end + end + + context 'when user dismissed' do + before do + allow(helper).to receive(:user_dismissed?).and_return(true) + end + + it { is_expected.to be false } + end + + context 'when the user is not logged in' do + before do + allow(helper).to receive(:current_user).and_return(nil) + end + + it { is_expected.to be_falsey } + end + end +end |