diff --git a/config/initializers/fluentd_ui_update_check.rb b/config/initializers/fluentd_ui_update_check.rb index ec79a81..820a475 100644 --- a/config/initializers/fluentd_ui_update_check.rb +++ b/config/initializers/fluentd_ui_update_check.rb @@ -1,4 +1,6 @@ -unless FluentdUI.td_agent_ui? - # td-agent-ui shouldn't auto update - FluentdUiUpdateCheck.new.async.perform +unless Rails.env.test? + unless FluentdUI.td_agent_ui? + # td-agent-ui shouldn't auto update + FluentdUiUpdateCheck.new.async.perform + end end diff --git a/spec/features/fluentd_ui_update_available_spec.rb b/spec/features/fluentd_ui_update_available_spec.rb new file mode 100644 index 0000000..963a913 --- /dev/null +++ b/spec/features/fluentd_ui_update_available_spec.rb @@ -0,0 +1,33 @@ +require "spec_helper" + +describe "fluentd-ui updates checking" do + let(:exists_user) { build(:user) } + before { login_with(exists_user) } + + describe "Show popup if newer version is available" do + let(:version) { "9999.99" } + let(:message) { I18n.t("messages.available_new_fluentd_ui", version: FluentdUI.latest_version, update_url: misc_information_path, title: "dummy") } + before { FluentdUI.latest_version = version } + after { FluentdUI.latest_version = ::FluentdUI::VERSION } + + it do + visit root_path + page.should have_css('.alert-info') + page.should have_content(version) + page.body.should include(message) + end + end + + describe "Not shown popup if newer version is not available" do + let(:version) { ::FluentdUI::VERSION } + let(:message) { I18n.t("messages.available_new_fluentd_ui", version: FluentdUI.latest_version, update_url: misc_information_path, title: "dummy") } + + it do + visit root_path + page.should_not have_css('.alert-info') + page.should_not have_content(version) + page.body.should_not include(message) + end + end + +end diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 68146de..5eeb8a2 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -1,6 +1,6 @@ -describe "users" do - let(:exists_user) { create(:user) } +require "spec_helper" +describe "users" do describe "edit" do let(:url) { user_path } it_should_behave_like "login required" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d6f90d4..603e70f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -33,6 +33,7 @@ RSpec.configure do |config| # Syntax sugar to use the FactoryGirl methods directly instead FactoryGirl.create ete. config.include FactoryGirl::Syntax::Methods + config.include LoginMacro # If true, the base class of anonymous controllers will be inferred # automatically. This will be the default behavior in future versions of diff --git a/spec/support/login_macro.rb b/spec/support/login_macro.rb new file mode 100644 index 0000000..4bea86f --- /dev/null +++ b/spec/support/login_macro.rb @@ -0,0 +1,10 @@ +module LoginMacro + def login_with(user) + visit '/sessions/new' + within("form") do + fill_in 'session_name', :with => exists_user.name + fill_in 'session_password', :with => exists_user.password + end + click_button I18n.t("terms.sign_in") + end +end