Add specs for newer fluentd-ui available check and popup

This commit is contained in:
uu59 2014-11-06 14:29:31 +09:00
parent 844d867a52
commit e79ebf7da0
5 changed files with 51 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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