File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,14 @@ def show_banners?(feature: nil)
53
53
end
54
54
end
55
55
56
+ def banner_type_for ( feature :)
57
+ if !active?
58
+ :no_token
59
+ elsif !allows_to? ( feature )
60
+ :upsell
61
+ end
62
+ end
63
+
56
64
def set_current_token
57
65
token = EnterpriseToken . order ( Arel . sql ( "created_at DESC" ) ) . first
58
66
Original file line number Diff line number Diff line change 118
118
end
119
119
end
120
120
121
+ describe ".banner_type_for" do
122
+ before do
123
+ allow ( described_class ) . to receive ( :allows_to? ) . with ( :active_feature ) . and_return ( true )
124
+ allow ( described_class ) . to receive ( :allows_to? ) . with ( :inactive_feature ) . and_return ( false )
125
+ end
126
+
127
+ context "without an EnterpriseToken" do
128
+ before do
129
+ allow ( described_class ) . to receive ( :active? ) . and_return ( false )
130
+ end
131
+
132
+ it "returns :no_token" do
133
+ expect ( described_class . banner_type_for ( feature : :active_feature ) ) . to eq ( :no_token )
134
+ end
135
+ end
136
+
137
+ context "with a feature that is included in the EnterpriseToken" do
138
+ before do
139
+ allow ( described_class ) . to receive ( :active? ) . and_return ( true )
140
+ end
141
+
142
+ it "returns nil" do
143
+ expect ( described_class . banner_type_for ( feature : :active_feature ) ) . to be_nil
144
+ end
145
+ end
146
+
147
+ context "with a feature that is not included in the EnterpriseToken" do
148
+ before do
149
+ allow ( described_class ) . to receive ( :active? ) . and_return ( true )
150
+ end
151
+
152
+ it "returns :upsell" do
153
+ expect ( described_class . banner_type_for ( feature : :inactive_feature ) ) . to eq ( :upsell )
154
+ end
155
+ end
156
+ end
157
+
121
158
describe "existing token" do
122
159
before do
123
160
allow_any_instance_of ( EnterpriseToken ) . to receive ( :token_object ) . and_return ( object )
You can’t perform that action at this time.
0 commit comments