Commit 51c1d1bb9a91055f9298d88ec59833e94f8c23e6

Authored by Cyril Mougel
2 parents 6523e5b9 17cc07f8
Exists in master and in 1 other branch production

Merge branch 'master' into refactor/problem_controller

CHANGELOG.md
... ... @@ -16,6 +16,9 @@
16 16 - [#343][] Fix the ical generation. ([@shingara][])
17 17 - [#503][] Fix issue on where the service_url choose never use. ([@nfedyashev][])
18 18 - [#506][] Fix issue on bitbucket issue tracker creation failed. ([@Gonzih][])
  19 +- [#514][] Add CDATA in xml return by Javascript. ([@mildavw][])
  20 +- [#517][] Javascript escape path from javascript Notifier. ([@roryf][])
  21 +- [#518][] Fix issue when you try launch task errbit:db:update_update_problem_attrs. ([@shingara][])
19 22  
20 23 ## 0.1.0 - 2013-05-29
21 24  
... ... @@ -72,6 +75,8 @@
72 75 [#503]: https://github.com/errbit/errbit/issues/503
73 76 [#506]: https://github.com/errbit/errbit/issues/506
74 77 [#508]: https://github.com/errbit/errbit/issues/508
  78 +[#514]: https://github.com/errbit/errbit/issues/514
  79 +[#517]: https://github.com/errbit/errbit/issues/517
75 80  
76 81 <!-- Contributor on Errbit Thanks to all of them -->
77 82  
... ... @@ -90,3 +95,5 @@
90 95 [@parallel588]: https://github.com/parallel588
91 96 [@Gonzih]: https://github.com/Gonzih
92 97 [@boblail]: https://github.com/boblail
  98 +[@roryf]: https://github.com/roryf
  99 +[@mildavw]: https://github.com/mildavw
... ...
Gemfile
... ... @@ -17,7 +17,7 @@ gem &#39;strong_parameters&#39;
17 17 gem 'SystemTimer', :platform => :ruby_18
18 18 gem 'actionmailer_inline_css'
19 19 gem 'kaminari', '>= 0.14.1'
20   -gem 'rack-ssl-enforcer'
  20 +gem 'rack-ssl-enforcer', :require => false
21 21 # fabrication 1.3.0 is last supporting ruby 1.8. Update when stop supporting this version too
22 22 gem 'fabrication', "~> 1.3.0" # Used for both tests and demo data
23 23 gem 'rails_autolink'
... ...
README.md
... ... @@ -150,6 +150,8 @@ git clone http://github.com/errbit/errbit.git
150 150 ```
151 151 * Update `db/seeds.rb` with admin credentials for your initial login.
152 152  
  153 + * Run `bundle`
  154 +
153 155 * Create & configure for Heroku
154 156  
155 157 ```bash
... ... @@ -467,7 +469,11 @@ Solutions known to work are listed below:
467 469 Develop on Errbit
468 470 -----------------
469 471  
470   -A guide can help on this way on [**Errbit Advanced Developer Guide**](https://github.com/errbit/errbit/blob/master/docs/DEVELOPER-ADVANCED.md)
  472 +A guide can help on this way on [**Errbit Advanced Developer Guide**](docs/DEVELOPER-ADVANCED.md)
  473 +
  474 +## Other documentation
  475 +
  476 +* [All ENV variables availables to configure Errbit](docs/ENV-VARIABLES.md)
471 477  
472 478 TODO
473 479 ----
... ...
app/assets/stylesheets/errbit.css
... ... @@ -304,7 +304,7 @@ form label.inline { display: inline; }
304 304 form .checkbox label { display: inline; }
305 305 form .required label { padding-right: 20px; background: transparent url(images/icons/required.png) right 50% no-repeat; }
306 306 form .field_with_errors label { color: #900; }
307   -form input[type=text], form input[type=password] {
  307 +form input[type=text], form input[type=password], form input[type=email] {
308 308 width: 96%; padding: 0.8em;
309 309 font-size: 1em;
310 310 color: #787878; border: 1px solid #C6C6C6;
... ... @@ -316,7 +316,7 @@ form textarea {
316 316 }
317 317 form textarea.short { height: 8em; }
318 318 form textarea.supershort { height: 4em; }
319   -form input[type=text]:focus, form input[type=password]:focus, form textarea:focus {
  319 +form input[type=text]:focus, form input[type=password]:focus, form input[type=email]:focus, form textarea:focus {
320 320 box-shadow: 0px 0px 4px #69C;
321 321 -moz-box-shadow: 0px 0px 4px #69C;
322 322 -webkit-box-shadow: 0px 0px 4px #69C
... ...
app/views/devise/sessions/new.html.haml
... ... @@ -9,7 +9,7 @@
9 9 = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
10 10 .required
11 11 = f.label auth_key
12   - = f.text_field auth_key, :tabindex => 1
  12 + = f.text_field auth_key, :type => (Errbit::Config.user_has_username ? 'text' : 'email'), :tabindex => 1
13 13  
14 14 .required
15 15 = link_to 'forget it?', new_password_path(resource_name), :class => 'float-right', :id => "forgot_password"
... ...
config/initializers/_load_config.rb
... ... @@ -4,15 +4,17 @@ default_config_file = Rails.root.join(&quot;config&quot;, &quot;config.example.yml&quot;)
4 4 # Allow a Rails Engine to override config by defining it earlier
5 5 unless defined?(Errbit::Config)
6 6 Errbit::Config = OpenStruct.new
  7 + use_env = ENV['HEROKU'] || ENV['USE_ENV']
7 8  
8 9 # If Errbit is running on Heroku, config can be set from environment variables.
9   - if ENV['HEROKU']
  10 + if use_env
10 11 Errbit::Config.host = ENV['ERRBIT_HOST']
11 12 Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM']
12   - Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES']
13   - Errbit::Config.confirm_resolve_err = ENV['ERRBIT_CONFIRM_RESOLVE_ERR']
14   - Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME']
15   - Errbit::Config.allow_comments_with_issue_tracker = ENV['ERRBIT_ALLOW_COMMENTS_WITH_ISSUE_TRACKER']
  13 + # Not really easy to use like an env because need an array and ENV return a string :(
  14 + # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES']
  15 + Errbit::Config.confirm_resolve_err = ENV['ERRBIT_CONFIRM_RESOLVE_ERR'].to_i == 0
  16 + Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1
  17 + Errbit::Config.allow_comments_with_issue_tracker = ENV['ERRBIT_ALLOW_COMMENTS_WITH_ISSUE_TRACKER'].to_i == 0
16 18 Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL']
17 19  
18 20 Errbit::Config.use_gravatar = ENV['ERRBIT_USE_GRAVATAR']
... ... @@ -29,7 +31,7 @@ unless defined?(Errbit::Config)
29 31 :authentication => :plain,
30 32 :user_name => ENV['SMTP_USERNAME'] || ENV['SENDGRID_USERNAME'],
31 33 :password => ENV['SMTP_PASSWORD'] || ENV['SENDGRID_PASSWORD'],
32   - :domain => ENV['SENDGRID_DOMAIN'] || ENV['ERRBIT_EMAIL_FROM'].split('@').last
  34 + :domain => ENV['SMTP_DOMAIN'] || ENV['SENDGRID_DOMAIN'] || ENV['ERRBIT_EMAIL_FROM'].split('@').last
33 35 }
34 36 end
35 37  
... ... @@ -44,7 +46,7 @@ unless defined?(Errbit::Config)
44 46 Errbit::Config.send("#{k}=", v)
45 47 end
46 48 # Show message if we are not running tests, not running on Heroku, and config.yml doesn't exist.
47   - elsif not ENV['HEROKU']
  49 + elsif not use_env
48 50 puts "Please copy 'config/config.example.yml' to 'config/config.yml' and configure your settings. Using default settings."
49 51 end
50 52  
... ... @@ -76,4 +78,4 @@ end
76 78  
77 79 if Rails.env.production?
78 80 Rails.application.config.consider_all_requests_local = Errbit::Config.display_internal_errors
79   -end
80 81 \ No newline at end of file
  82 +end
... ...
config/initializers/mongo.rb
1   -if mongo = ENV['MONGOLAB_URI'] || ENV['MONGOHQ_URL']
2   - settings = URI.parse(mongo)
3   - database_name = settings.path.gsub(/^\//, '')
  1 +# Some code extract from Mongoid gem
  2 +config_file = Rails.root.join("config", "mongoid.yml")
  3 +if config_file.file? &&
  4 + YAML.load(ERB.new(File.read(config_file)).result)[Rails.env].values.flatten.any?
  5 + ::Mongoid.load!(config_file)
  6 +else
  7 + # No mongoid.yml file. Use ENV variable to define your MongoDB
  8 + # configuration
  9 + if mongo = ENV['MONGOLAB_URI'] || ENV['MONGOHQ_URL']
  10 + settings = URI.parse(mongo)
  11 + database_name = settings.path.gsub(/^\//, '')
  12 + else
  13 + settings = OpenStruct.new({
  14 + :host => ENV['MONGOID_HOST'],
  15 + :port => ENV['MONGOID_PORT'],
  16 + :user => ENV['MONGOID_USERNAME'],
  17 + :password => ENV['MONGOID_PASSWORD']
  18 + })
  19 + database_name = ENV['MONGOID_DATABASE']
  20 + end
4 21  
5 22 Mongoid.configure do |config|
6   - config.master = Mongo::Connection.new(settings.host, settings.port).db(database_name)
  23 + config.master = Mongo::Connection.new(
  24 + settings.host,
  25 + settings.port
  26 + ).db(database_name)
7 27 config.master.authenticate(settings.user, settings.password) if settings.user
8   - config.allow_dynamic_fields = false
9   - config.use_activesupport_time_zone = true
10 28 end
11 29 end
12 30  
  31 +Mongoid.allow_dynamic_fields = false
  32 +Mongoid.use_activesupport_time_zone = true
  33 +Mongoid.identity_map_enabled = true
... ...
config/initializers/ssl_enforcer.rb
1 1 # Enforce SSL connections, if configured
2 2 if Errbit::Config.enforce_ssl
  3 + require 'rack/ssl-enforcer'
3 4 ActionMailer::Base.default_url_options.merge!(:protocol => 'https://')
4 5 Errbit::Application.configure do
5 6 config.middleware.use Rack::SslEnforcer, :except => /^\/deploys/
... ...
docs/ENV-VARIABLES.md 0 → 100644
... ... @@ -0,0 +1,71 @@
  1 +# Which env variable you can use ?
  2 +
  3 +Errbit can be almost configured by some ENVIRONMENT variables. If you
  4 +use this variable, you don't need copy all of you configuration file
  5 +
  6 +To activate this env variable you need activate it by a Variable env.
  7 +You can do that with HEROKU or USE_ENV variable
  8 +
  9 +If you activate it you can use all of this env variable :
  10 +
  11 +## Errbit base configuration
  12 +
  13 +* ERRBIT_HOST : the host of your errbit instance (not define by default)
  14 +* ERRBIT_EMAIL_FROM : the email sending all of your notification (not
  15 + define by default )
  16 +* ERRBIT_CONFIRM_RESOLVE_ERR : define if you need confirm when you mark
  17 + a problem resolve. ( true by default, fill it and you not need
  18 +confirm )
  19 +* ERRBIT_USER_HAS_USERNAME : allow identify your user by username
  20 + instead of email. ( false by default, set to '1' to activate it)
  21 +* ERRBIT_ALLOW_COMMENTS_WITH_ISSUE_TRACKER : define if you activate the
  22 + comment or not. By default comment are
  23 +* ERRBIT_ENFORCE_SSL : allow force the ssl on all the application. By
  24 + default is false
  25 +* ERRBIT_USE_GRAVATAR : allow use gravatar to see user gravatar in user
  26 + comment and page
  27 +
  28 +## Authentification configuration
  29 +
  30 +Environement variable allow define how you can auth on your errbit
  31 +
  32 +### Github authentification
  33 +
  34 +You can allow the GITHUB auth
  35 +
  36 +* GITHUB_AUTHENTIFICATION : define if you allow the github auth. By
  37 + default false
  38 +* GITHUB_CLIENT_ID : you github app client id to use in your github auth
  39 +* GITHUB_SECRET : your github app secret to use in your github auth
  40 +* GITHUB_ACCESS_SCOPE : The scope to ask to access on github account
  41 +
  42 +## Email sending configuration
  43 +
  44 +You can define how you connect your email sending system By all of this
  45 +information. All mail can be send only by SMTP if you use variable
  46 +system
  47 +
  48 +* SMTP_SERVER
  49 +* SMTP_PORT
  50 +* SMTP_USERNAME
  51 +* SMTP_PASSWORD
  52 +* SMTP_DOMAIN
  53 +
  54 +## MongoDB
  55 +
  56 +You can define your MongoDB connection by 2 ways. If you have an URL,
  57 +you can define one of this ENV variables. All independently can works
  58 +
  59 +* MONGOLAB_URI
  60 +* MONGOHQ_URL
  61 +
  62 +If you have a complete MongoDB connection you can define it by all
  63 +information associate to your MongoDB connection. You need define all
  64 +variable.
  65 +
  66 +* MONGOID_HOST
  67 +* MONGOID_PORT
  68 +* MONGOID_USERNAME
  69 +* MONGOID_PASSWORD
  70 +* MONGOID_DATABASE
  71 +
... ...
lib/tasks/errbit/database.rake
... ... @@ -7,7 +7,7 @@ namespace :errbit do
7 7 task :update_problem_attrs => :environment do
8 8 puts "Updating problems"
9 9 Problem.all.each{|problem|
10   - ProblemUpdaterCache.new(self).update
  10 + ProblemUpdaterCache.new(problem).update
11 11 }
12 12 end
13 13  
... ...
public/javascripts/notifier.js
... ... @@ -366,7 +366,7 @@ printStackTrace.implementation.prototype = {
366 366 '</notifier>' +
367 367 '<error>' +
368 368 '<class>{exception_class}</class>' +
369   - '<message>{exception_message}</message>' +
  369 + '<message><![CDATA[{exception_message}]]></message>' +
370 370 '<backtrace>{backtrace_lines}</backtrace>' +
371 371 '</error>' +
372 372 '<request>' +
... ... @@ -972,8 +972,8 @@ printStackTrace.implementation.prototype = {
972 972 // '" number="' + matches[3] + '" />');
973 973  
974 974 backtrace.push({
975   - 'function': matches[1],
976   - file: file,
  975 + 'function': Util.escape(matches[1]),
  976 + file: Util.escape(file),
977 977 line: matches[3]
978 978 });
979 979 }
... ...
spec/fixtures/hoptoad_test_notice.xml
... ... @@ -9,7 +9,7 @@
9 9 <framework>Rails: 3.2.11</framework>
10 10 <error>
11 11 <class>HoptoadTestingException</class>
12   - <message>HoptoadTestingException: Testing hoptoad via "rake hoptoad:test". If you can see this, it works.</message>
  12 + <message><![CDATA[HoptoadTestingException: Testing hoptoad via "rake hoptoad:test". If you can see this, it works & works well.]]></message>
13 13 <backtrace>
14 14 <line number="425" file="[GEM_ROOT]/gems/activesupport-3.0.0.rc/lib/active_support/callbacks.rb" method="_run__2115867319__process_action__262109504__callbacks"/>
15 15 <line number="404" file="[GEM_ROOT]/gems/activesupport-3.0.0.rc/lib/active_support/callbacks.rb" method="send"/>
... ...
spec/models/problem_spec.rb
... ... @@ -104,7 +104,7 @@ describe Problem do
104 104  
105 105 it "should record the time when it was resolved" do
106 106 problem = Fabricate(:problem)
107   - expected_resolved_at = Time.now
  107 + expected_resolved_at = Time.zone.now
108 108 Timecop.freeze(expected_resolved_at) do
109 109 problem.resolve!
110 110 end
... ...