spec/flipper/ui_spec.rb in flipper-ui-0.14.0 vs spec/flipper/ui_spec.rb in flipper-ui-0.15.0
- old
+ new
@@ -9,10 +9,11 @@
end
end
let(:session) do
{ :csrf => token, 'csrf' => token, '_csrf_token' => token }
end
+ let(:configuration) { described_class.configuration }
describe 'Initializing middleware with flipper instance' do
let(:app) { build_app(flipper) }
it 'works' do
@@ -57,98 +58,31 @@
'rack.session' => session
expect(last_response.status).to be(302)
expect(last_response.headers['Location']).to eq('/features/refactor-images')
end
- it 'does not have an application_breadcrumb_href by default' do
- expect(described_class.application_breadcrumb_href).to be(nil)
- end
-
- context 'with application_breadcrumb_href not set' do
- before do
- @original_application_breadcrumb_href = described_class.application_breadcrumb_href
- described_class.application_breadcrumb_href = nil
+ describe "application_breadcrumb_href" do
+ it "raises an exception since it is deprecated" do
+ expect { described_class.application_breadcrumb_href }
+ .to raise_error(Flipper::ConfigurationDeprecated)
end
-
- after do
- described_class.application_breadcrumb_href = @original_application_breadcrumb_href
- end
-
- it 'does not add App breadcrumb' do
- get '/features'
- expect(last_response.body).not_to include('<a href="/myapp">App</a>')
- end
end
- context 'with application_breadcrumb_href set' do
- before do
- @original_application_breadcrumb_href = described_class.application_breadcrumb_href
- described_class.application_breadcrumb_href = '/myapp'
+ describe "feature_creation_enabled" do
+ it "raises an exception since it is deprecated" do
+ expect { described_class.feature_creation_enabled }
+ .to raise_error(Flipper::ConfigurationDeprecated)
end
-
- after do
- described_class.application_breadcrumb_href = @original_application_breadcrumb_href
- end
-
- it 'does add App breadcrumb' do
- get '/features'
- expect(last_response.body).to include('<a href="/myapp">App</a>')
- end
end
- context 'with application_breadcrumb_href set to full url' do
- before do
- @original_application_breadcrumb_href = described_class.application_breadcrumb_href
- described_class.application_breadcrumb_href = 'https://myapp.com/'
+ describe "feature_removal_enabled" do
+ it "raises an exception since it is deprecated" do
+ expect { described_class.feature_removal_enabled }
+ .to raise_error(Flipper::ConfigurationDeprecated)
end
-
- after do
- described_class.application_breadcrumb_href = @original_application_breadcrumb_href
- end
-
- it 'does add App breadcrumb' do
- get '/features'
- expect(last_response.body).to include('<a href="https://myapp.com/">App</a>')
- end
end
- it 'sets feature_creation_enabled to true by default' do
- expect(described_class.feature_creation_enabled).to be(true)
- end
-
- context 'with feature_creation_enabled set to true' do
- before do
- @original_feature_creation_enabled = described_class.feature_creation_enabled
- described_class.feature_creation_enabled = true
- end
-
- it 'has the add_feature button' do
- get '/features'
- expect(last_response.body).to include('Add Feature')
- end
-
- after do
- described_class.feature_creation_enabled = @original_feature_creation_enabled
- end
- end
-
- context 'with feature_creation_enabled set to false' do
- before do
- @original_feature_creation_enabled = described_class.feature_creation_enabled
- described_class.feature_creation_enabled = false
- end
-
- it 'does not have the add_feature button' do
- get '/features'
- expect(last_response.body).not_to include('Add Feature')
- end
-
- after do
- described_class.feature_creation_enabled = @original_feature_creation_enabled
- end
- end
-
describe 'configure' do
it 'yields configuration instance' do
described_class.configure do |config|
expect(config).to be_instance_of(Flipper::UI::Configuration)
end
@@ -172,9 +106,139 @@
end
it 'includes banner' do
get '/features'
expect(last_response.body).to include('Production Environment')
+ end
+ end
+ end
+
+ describe "application_breadcrumb_href" do
+ it 'does not have an application_breadcrumb_href by default' do
+ expect(configuration.application_breadcrumb_href).to be(nil)
+ end
+
+ context 'with application_breadcrumb_href not set' do
+ before do
+ @original_application_breadcrumb_href = configuration.application_breadcrumb_href
+ configuration.application_breadcrumb_href = nil
+ end
+
+ after do
+ configuration.application_breadcrumb_href = @original_application_breadcrumb_href
+ end
+
+ it 'does not add App breadcrumb' do
+ get '/features'
+ expect(last_response.body).not_to include('<a href="/myapp">App</a>')
+ end
+ end
+
+ context 'with application_breadcrumb_href set' do
+ before do
+ @original_application_breadcrumb_href = configuration.application_breadcrumb_href
+ configuration.application_breadcrumb_href = '/myapp'
+ end
+
+ after do
+ configuration.application_breadcrumb_href = @original_application_breadcrumb_href
+ end
+
+ it 'does add App breadcrumb' do
+ get '/features'
+ expect(last_response.body).to include('<a href="/myapp">App</a>')
+ end
+ end
+
+ context 'with application_breadcrumb_href set to full url' do
+ before do
+ @original_application_breadcrumb_href = configuration.application_breadcrumb_href
+ configuration.application_breadcrumb_href = 'https://myapp.com/'
+ end
+
+ after do
+ configuration.application_breadcrumb_href = @original_application_breadcrumb_href
+ end
+
+ it 'does add App breadcrumb' do
+ get '/features'
+ expect(last_response.body).to include('<a href="https://myapp.com/">App</a>')
+ end
+ end
+ end
+
+ describe "feature_creation_enabled" do
+ it 'sets feature_creation_enabled to true by default' do
+ expect(configuration.feature_creation_enabled).to be(true)
+ end
+
+ context 'with feature_creation_enabled set to true' do
+ before do
+ @original_feature_creation_enabled = configuration.feature_creation_enabled
+ configuration.feature_creation_enabled = true
+ end
+
+ it 'has the add_feature button' do
+ get '/features'
+ expect(last_response.body).to include('Add Feature')
+ end
+
+ after do
+ configuration.feature_creation_enabled = @original_feature_creation_enabled
+ end
+ end
+
+ context 'with feature_creation_enabled set to false' do
+ before do
+ @original_feature_creation_enabled = configuration.feature_creation_enabled
+ configuration.feature_creation_enabled = false
+ end
+
+ it 'does not have the add_feature button' do
+ get '/features'
+ expect(last_response.body).not_to include('Add Feature')
+ end
+
+ after do
+ configuration.feature_creation_enabled = @original_feature_creation_enabled
+ end
+ end
+ end
+
+ describe "feature_removal_enabled" do
+ it 'sets feature_removal_enabled to true by default' do
+ expect(configuration.feature_removal_enabled).to be(true)
+ end
+
+ context 'with feature_removal_enabled set to true' do
+ before do
+ @original_feature_removal_enabled = configuration.feature_removal_enabled
+ configuration.feature_removal_enabled = true
+ end
+
+ it 'has the add_feature button' do
+ get '/features/test'
+ expect(last_response.body).to include('Delete')
+ end
+
+ after do
+ configuration.feature_removal_enabled = @original_feature_removal_enabled
+ end
+ end
+
+ context 'with feature_removal_enabled set to false' do
+ before do
+ @original_feature_removal_enabled = configuration.feature_removal_enabled
+ configuration.feature_removal_enabled = false
+ end
+
+ it 'does not have the add_feature button' do
+ get '/features/test'
+ expect(last_response.body).not_to include('Delete')
+ end
+
+ after do
+ configuration.feature_removal_enabled = @original_feature_removal_enabled
end
end
end
end
end