Permalink
Browse files

Style the search field, and make existing tests pass

  • Loading branch information...
1 parent d0b92ec commit d44b887f18e583708369fbab2bff8dfaefed84d5 @elandesign elandesign committed Aug 14, 2012
View
20 app/assets/stylesheets/errbit.css
@@ -122,6 +122,26 @@ a.action { float: right; font-size: 0.9em;}
-webkit-border-top-right-radius: 12px;
border: 1px solid #bbb;
}
+#nav-bar li.search {
+ background-color: transparent;
+ border: none;
+ border-top-left-radius: 0;
+ border-top-right-radius: 0;
+ -moz-border-top-left-radius: 0;
+ -moz-border-top-right-radius: 0;
+ -webkit-border-top-left-radius: 0;
+ -webkit-border-top-right-radius: 0;
+}
+#nav-bar li.search input {
+ padding: 0 5px;
+ margin: 0;
+ width: auto;
+ border: none;
+ line-height: 34px;
+ position: relative;
+ top: -15px;
+ left: 15px;
+}
#nav-bar li.active {
border-color: #fff;
background: #FFF url(images/button-bg.png) 0 -2px repeat-x;
View
2 app/controllers/errs_controller.rb
@@ -21,7 +21,7 @@ def index
end
def search
- raise "Elastic Search is not enabled" unless Errbit::Config.elastic_search_enabled
+ raise "Elastic Search is not enabled" unless Errbit::Config.elasticsearch_enabled
visible_apps = current_user.admin? ? App.all : current_user.apps
if params[:app_id]
visible_apps = visible_apps.where(:_id => params[:app_id])
View
30 app/models/problem.rb
@@ -42,19 +42,23 @@ class Problem
scope :ordered, order_by(:last_notice_at.desc)
scope :for_apps, lambda {|apps| where(:app_id.in => apps.all.map(&:id))}
- if Errbit::Config.elastic_search_enabled
- include Tire::Model::Search
- include Tire::Model::Callbacks
- mapping do
- indexes :app_id, :index => :not_analyzed
- indexes :app_name, :index => :not_analyzed
- indexes :error_class, :analyzer => :snowball
- indexes :where, :analyzer => :snowball
- indexes :message, :analyzer => :snowball
- indexes :environment, :index => :not_analyzed
- indexes :resolved, :index => :not_analyzed
- indexes :last_notice_at, :index => :not_analyzed
- end
+ include Tire::Model::Search
+ mapping do
+ indexes :app_id, :index => :not_analyzed
+ indexes :app_name, :index => :not_analyzed
+ indexes :error_class, :analyzer => :snowball
+ indexes :where, :analyzer => :snowball
+ indexes :message, :analyzer => :snowball
+ indexes :environment, :index => :not_analyzed
+ indexes :resolved, :index => :not_analyzed
+ indexes :last_notice_at, :index => :not_analyzed
+ end
+
+ after_save :update_index, :if => lambda { Errbit::Config.elasticsearch_enabled }
+ after_destroy :update_index, :if => lambda { Errbit::Config.elasticsearch_enabled }
+
+ def update_index
+ tire.update_index
end
def self.in_env(env)
View
7 app/views/shared/_navigation.html.haml
@@ -5,6 +5,7 @@
%li.errs{:class => active_if_here(:errs)}= link_to 'Errors', errs_path
- if user_signed_in? && current_user.admin?
%li.users{:class => active_if_here(:users)}= link_to 'Users', users_path
- %div.clear
- = form_tag search_path, {:class => 'navbar-search pull-left', :method => :get} do
- %input{:type => 'text', :class => 'search-query span2', :placeholder => 'Search', :name => 'terms', :value => @search.present? ? @search.terms : ''}
+ - if Errbit::Config.elasticsearch_enabled
+ %li.search
+ = form_tag search_path, {:method => :get, :id => 'search'} do
+ %input{:type => 'text', :class => 'search-query span2', :placeholder => 'Search', :name => 'terms', :value => @search.present? ? @search.terms : ''}
View
4 config/config.example.yml
@@ -40,8 +40,8 @@ user_has_username: false
allow_comments_with_issue_tracker: true
# Index any problems in ElasticSearch
-elastic_search_enabled: true
-elastic_search_url: http://localhost:9200
+elasticsearch_enabled: true
+elasticsearch_url: http://localhost:9200
# Setup your deploy options for capistrano.
deployment:
View
6 config/initializers/tire.rb
@@ -1,6 +1,6 @@
-if Errbit::Config.elastic_search_enabled
+if Errbit::Config.elasticsearch_enabled
Tire.configure do
- url Errbit::Config.elastic_search_url
- logger STDERR
+ url Errbit::Config.elasticsearch_url
+ logger Rails.root.join("log", "elasticsearch.#{Rails.env}.log") unless Rails.env.production?
end
end
View
5 spec/spec_helper.rb
@@ -21,11 +21,16 @@
config.run_all_when_everything_filtered = true
config.alias_example_to :fit, :focused => true
+ config.before(:all) do
+ Problem.index_name('test_' + Problem.model_name.plural)
+ end
+
config.before(:each) do
DatabaseCleaner[:mongoid].strategy = :truncation
DatabaseCleaner.clean
end
config.include WebMock::API
end
+Errbit::Config.elasticsearch_enabled = false
OmniAuth.config.test_mode = true

0 comments on commit d44b887

Please sign in to comment.