Skip to content
This repository
  • 5 commits
  • 20 files changed
  • 0 comments
  • 3 contributors
46  Gemfile.lock
... ...
@@ -1,24 +1,24 @@
1 1
 PATH
2 2
   remote: .
3 3
   specs:
4  
-    spree (0.70.0)
5  
-      spree_api (= 0.70.0)
6  
-      spree_auth (= 0.70.0)
7  
-      spree_core (= 0.70.0)
8  
-      spree_dash (= 0.70.0)
9  
-      spree_promo (= 0.70.0)
10  
-      spree_sample (= 0.70.0)
11  
-    spree_api (0.70.0)
12  
-      spree_auth (= 0.70.0)
13  
-      spree_core (= 0.70.0)
14  
-    spree_auth (0.70.0)
  4
+    spree (0.70.1)
  5
+      spree_api (= 0.70.1)
  6
+      spree_auth (= 0.70.1)
  7
+      spree_core (= 0.70.1)
  8
+      spree_dash (= 0.70.1)
  9
+      spree_promo (= 0.70.1)
  10
+      spree_sample (= 0.70.1)
  11
+    spree_api (0.70.1)
  12
+      spree_auth (= 0.70.1)
  13
+      spree_core (= 0.70.1)
  14
+    spree_auth (0.70.1)
15 15
       cancan (= 1.6.5)
16 16
       devise (= 1.4.7)
17  
-      spree_core (= 0.70.0)
18  
-    spree_core (0.70.0)
  17
+      spree_core (= 0.70.1)
  18
+    spree_core (0.70.1)
19 19
       activemerchant (= 1.17.0)
20 20
       acts_as_list (= 0.1.4)
21  
-      deface (>= 0.6.1)
  21
+      deface (>= 0.7.0)
22 22
       faker (= 1.0.0)
23 23
       highline (= 1.5.1)
24 24
       jquery-rails (>= 1.0.14)
@@ -31,13 +31,13 @@ PATH
31 31
       rd_resource_controller
32 32
       state_machine (= 1.0.1)
33 33
       stringex (= 1.0.3)
34  
-    spree_dash (0.70.0)
35  
-      spree_core (= 0.70.0)
36  
-    spree_promo (0.70.0)
37  
-      spree_auth (= 0.70.0)
38  
-      spree_core (= 0.70.0)
39  
-    spree_sample (0.70.0)
40  
-      spree_core (= 0.70.0)
  34
+    spree_dash (0.70.1)
  35
+      spree_core (= 0.70.1)
  36
+    spree_promo (0.70.1)
  37
+      spree_auth (= 0.70.1)
  38
+      spree_core (= 0.70.1)
  39
+    spree_sample (0.70.1)
  40
+      spree_core (= 0.70.1)
41 41
 
42 42
 GEM
43 43
   remote: http://rubygems.org/
@@ -113,7 +113,7 @@ GEM
113 113
       nokogiri (>= 1.4.4)
114 114
       rack-test (>= 0.5.7)
115 115
     database_cleaner (0.6.7)
116  
-    deface (0.6.1)
  116
+    deface (0.7.0)
117 117
       nokogiri (~> 1.5.0)
118 118
       rails (>= 3.0.9)
119 119
     devise (1.4.7)
@@ -136,7 +136,7 @@ GEM
136 136
     highline (1.5.1)
137 137
     hike (1.2.1)
138 138
     i18n (0.6.0)
139  
-    jquery-rails (1.0.14)
  139
+    jquery-rails (1.0.16)
140 140
       railties (~> 3.0)
141 141
       thor (~> 0.14)
142 142
     json (1.6.1)
2  README.md
Source Rendered
@@ -49,7 +49,7 @@ Peformance
49 49
 
50 50
 Rails 3.1 introduced a concept known as the asset pipeline.  Unfortunately it results in poor performance when running your site in development mode (production mode is unaffected.)  You may want to run the following command when testing locally in development mode
51 51
 
52  
-    $ bundle exec rake assets:precompile RAILS_ENV=development RAILS_ASSETS_NONDIGEST=true
  52
+    $ bundle exec rake assets:precompile:nondigest
53 53
 
54 54
 Using the precompile rake task in development will prevent any changes to asset files from being automatically included in when you reload the page. You must re-run the precompile task for changes to become available.
55 55
 
2  Rakefile
@@ -98,5 +98,5 @@ task :sandbox do
98 98
   Spree::SiteGenerator.start
99 99
 
100 100
   cmd = "bundle exec rake db:bootstrap AUTO_ACCEPT=true"; puts cmd; system cmd
101  
-  cmd = "bundle exec rake assets:precompile RAILS_ENV=development RAILS_ASSETS_NONDIGEST=true"; puts cmd; system cmd
  101
+  cmd = "bundle exec rake assets:precompile:nondigest"; puts cmd; system cmd
102 102
 end
2  SPREE_VERSION
... ...
@@ -1 +1 @@
1  
-0.70.0
  1
+0.70.1
8  core/app/assets/javascripts/admin/admin.js.erb
@@ -210,7 +210,7 @@ $(document).ready(function(){
210 210
           $.each($('table.sortable tbody tr'), function(position, obj){
211 211
             reg = /(\w+_?)+_(\d+)/;
212 212
             parts = reg.exec($(obj).attr('id'));
213  
-            if (parts) { 
  213
+            if (parts) {
214 214
               positions['positions['+parts[2]+']'] = position;
215 215
               type = parts[1];
216 216
             }
@@ -227,3 +227,9 @@ $(document).ready(function(){
227 227
   });
228 228
 
229 229
 });
  230
+
  231
+jQuery(document).ready(function() {
  232
+  $('div.alert a.dismiss').click(function() {
  233
+    $(this).parent().fadeOut();
  234
+  });
  235
+});
28  core/app/assets/stylesheets/admin/admin.css.erb
@@ -588,3 +588,31 @@ span.handle{
588 588
   width:14px;
589 589
   height:15px;
590 590
 }
  591
+
  592
+.alert {
  593
+  -moz-border-radius: 5px;
  594
+  -webkit-border-radius: 5px;
  595
+  border-radius: 5px;
  596
+  font-size: 1.3em;
  597
+  margin-bottom: 1em;
  598
+  padding: 0.8em;
  599
+}
  600
+.alert a.dismiss {
  601
+  float:right;
  602
+  font-size: 0.8em;
  603
+}
  604
+.alert.release {
  605
+  background: #ccddff url(../images/shadow_top.png) 0px -50px repeat-x;
  606
+  color: #556699;
  607
+  border: 1px solid #99aacc;
  608
+}
  609
+.alert.security {
  610
+  background: #f4b4b4 url(../images/shadow_top.png) 0px -50px repeat-x;
  611
+  color: #000000;
  612
+  border: 1px solid #e75b5b;
  613
+}
  614
+.alert.news {
  615
+  background: #ccffd4 url(../images/shadow_top.png) 0px -50px repeat-x;
  616
+  color: #000000;
  617
+  border: 1px solid #66ff7e;
  618
+}
32  core/app/controllers/admin/base_controller.rb
... ...
@@ -1,12 +1,42 @@
1 1
 class Admin::BaseController < Spree::BaseController
2 2
   ssl_required
3 3
 
  4
+  before_filter :check_alerts if Rails.env.production?
  5
+
4 6
   helper :search
5 7
   helper 'admin/navigation'
6 8
   layout 'admin'
7 9
 
8 10
   protected
9  
-  
  11
+  def check_alerts
  12
+    return unless current_user and should_check_alerts?
  13
+
  14
+    unless session.has_key? :alerts
  15
+      begin
  16
+        session[:alerts] = Spree::Alert.current(request.host)
  17
+        filter_dismissed_alerts
  18
+        Spree::Config.set :last_check_for_spree_alerts => DateTime.now.to_s
  19
+      rescue
  20
+        session[:alerts] = nil
  21
+      end
  22
+    end
  23
+  end
  24
+
  25
+  def should_check_alerts?
  26
+    return false if not Spree::Config[:check_for_spree_alerts]
  27
+
  28
+    last_check = Spree::Config[:last_check_for_spree_alerts]
  29
+    return true if last_check.blank?
  30
+
  31
+    DateTime.parse(last_check) < 12.hours.ago
  32
+  end
  33
+
  34
+  def filter_dismissed_alerts
  35
+    return unless session[:alerts]
  36
+    dismissed = (Spree::Config[:dismissed_spree_alerts] || '').split(',')
  37
+    session[:alerts].reject! { |a| dismissed.include? a.id.to_s }
  38
+  end
  39
+
10 40
   def flash_message_for(object, event_sym)
11 41
     resource_desc  = object.class.model_name.human
12 42
     resource_desc += " \"#{object.name}\"" if object.respond_to?(:name)
9  core/app/controllers/admin/general_settings_controller.rb
@@ -18,4 +18,13 @@ def update
18 18
     redirect_to admin_general_settings_path
19 19
   end
20 20
 
  21
+  def dismiss_alert
  22
+    if request.xhr? and params[:alert_id]
  23
+      dismissed = Spree::Config[:dismissed_spree_alerts] || ''
  24
+      Spree::Config.set :dismissed_spree_alerts => dismissed.split(',').push(params[:alert_id]).join(',')
  25
+      filter_dismissed_alerts
  26
+      render :nothing => true
  27
+    end
  28
+  end
  29
+
21 30
 end
3  core/app/models/app_configuration.rb
@@ -39,6 +39,9 @@ class AppConfiguration < Configuration
39 39
   preference :allow_checkout_on_gateway_error, :boolean, :default => false
40 40
   preference :select_taxons_from_tree, :boolean, :default => false # provide opportunity to select taxons from tree instead of search with autocomplete
41 41
   preference :max_level_in_taxons_menu, :integer, :default => 1 # maximum nesting level in taxons menu
  42
+  preference :check_for_spree_alerts, :boolean, :default => true
  43
+  preference :dismissed_spree_alerts, :string, :default => ''
  44
+  preference :last_check_for_spree_alerts, :string, :default => nil
42 45
 
43 46
   validates :name, :presence => true, :uniqueness => true
44 47
 
13  core/app/models/spree/alert.rb
... ...
@@ -0,0 +1,13 @@
  1
+class Spree::Alert < ActiveResource::Base
  2
+  self.site = "http://alerts.spreecommerce.com/"
  3
+  self.format = :json
  4
+
  5
+  def self.current(host)
  6
+    find(:all, :params => { :version => Spree.version,
  7
+                            :name => Spree::Config[:site_name],
  8
+                            :host => host,
  9
+                            :rails_env => Rails.env,
  10
+                            :rails_version => Rails.version })
  11
+  end
  12
+end
  13
+
6  core/app/views/admin/shared/_alert.html.erb
... ...
@@ -0,0 +1,6 @@
  1
+<div class="alert <%= alert.severity.downcase %>">
  2
+  <%= alert.message %> <%= link_to alert.url_name, alert.url if alert.url %>
  3
+  <%= link_to 'X', dismiss_alert_admin_general_settings_path(:alert_id => alert.id),
  4
+              :remote => true, :method => :post, :class => 'dismiss' %>
  5
+</div>
  6
+
2  core/app/views/layouts/admin.html.erb
@@ -40,6 +40,8 @@
40 40
       <div class="flash notice"><%= notice %></div>
41 41
     <% end %>
42 42
 
  43
+    <%= render :partial => 'admin/shared/alert', :collection => session[:alerts] %>
  44
+
43 45
     <%= yield %>
44 46
 
45 47
     <% if content_for?(:sidebar) %>
2  core/config/locales/en.yml
@@ -937,6 +937,8 @@ en:
937 937
   ssl_will_be_used_in_production_mode: "SSL will be used in production mode"
938 938
   ssl_will_not_be_used_in_development_and_test_modes: "SSL will not be used in development and test mode if necessary."
939 939
   ssl_will_not_be_used_in_production_mode: "SSL will not be used in production mode"
  940
+  spree_alert_checking: "Check for Spree security and release alerts"
  941
+  spree_alert_not_checking: "Not checking for Spree security and release alerts"
940 942
   start: Start
941 943
   start_date: Valid from
942 944
   state: State
6  core/config/routes.rb
@@ -159,7 +159,11 @@
159 159
       end
160 160
     end
161 161
 
162  
-    resource :general_settings
  162
+    resource :general_settings do
  163
+      collection do
  164
+        post :dismiss_alert
  165
+      end
  166
+    end
163 167
 
164 168
     resources :taxonomies do
165 169
       member do
10  core/lib/generators/spree/site/site_generator.rb
@@ -56,15 +56,25 @@ def setup_assets
56 56
       template "app/assets/stylesheets/admin/all.css"
57 57
     end
58 58
 
  59
+    def create_overrides_directory
  60
+      empty_directory "app/overrides"
  61
+    end
  62
+
59 63
     def configure_application
60 64
       application <<-APP
61 65
   config.middleware.use "SeoAssist"
62 66
     config.middleware.use "RedirectLegacyProductUrl"
63 67
 
64 68
     config.to_prepare do
  69
+      #loads application's model / class decorators
65 70
       Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
66 71
         Rails.configuration.cache_classes ? require(c) : load(c)
67 72
       end
  73
+
  74
+      #loads application's deface view overrides
  75
+      Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/*.rb")) do |c|
  76
+        Rails.application.config.cache_classes ? require(c) : load(c)
  77
+      end
68 78
     end
69 79
       APP
70 80
 
2  core/lib/spree_core/railtie.rb
@@ -55,7 +55,7 @@ def self.activate
55 55
     end
56 56
 
57 57
     # sets the manifests / assets to be precompiled
58  
-    initializer "spree.assets.precompile", :group => :assets do |app|
  58
+    initializer "spree.assets.precompile" do |app|
59 59
       app.config.assets.precompile += ['store/all.*', 'admin/all.*', 'admin/spree_dash.*', 'admin/orders/edit_form.js', 'jqPlot/excanvas.min.js', 'admin/images/new.js']
60 60
     end
61 61
 
2  core/lib/spree_core/version.rb
... ...
@@ -1,5 +1,5 @@
1 1
 module Spree
2 2
   def self.version
3  
-    "0.70.0"
  3
+    "0.70.1"
4 4
   end
5 5
 end
61  core/spec/controllers/admin/base_controller_spec.rb
... ...
@@ -0,0 +1,61 @@
  1
+require File.dirname(__FILE__) + '/../../spec_helper'
  2
+
  3
+describe Admin::BaseController do
  4
+
  5
+  describe "Spree Alert Checks" do
  6
+    it "only checks once per session" do
  7
+      controller.stub(:current_user => true)
  8
+      Spree::Config.set :check_for_spree_alerts => true
  9
+      session[:alerts] = []
  10
+      Spree::Alert.should_not_receive(:current)
  11
+      controller.send(:check_alerts)
  12
+    end
  13
+
  14
+    it "does not check if preference is false" do
  15
+      controller.stub(:current_user => true)
  16
+      Spree::Config.set :check_for_spree_alerts => false
  17
+      controller.send(:check_alerts)
  18
+      session[:alerts].should be_nil
  19
+    end
  20
+
  21
+    it "checks alerts if preference is true" do
  22
+      controller.stub(:current_user => true)
  23
+      Spree::Config.set :check_for_spree_alerts => true
  24
+      alerts = []
  25
+      Spree::Alert.should_receive(:current).and_return(alerts)
  26
+      controller.send(:check_alerts)
  27
+      session[:alerts].should eq alerts
  28
+      Spree::Config[:last_check_for_spree_alerts].should_not be_nil
  29
+    end
  30
+
  31
+    it "filters alerts stored in preferences" do
  32
+      Spree::Config.set :dismissed_spree_alerts => "1,3"
  33
+      alerts = [mock(:id => 1), mock(:id => 2), mock(:id => 3)]
  34
+      session[:alerts] = alerts
  35
+      controller.send(:filter_dismissed_alerts)
  36
+      session[:alerts].count.should be 1
  37
+      session[:alerts].first.id.should be 2
  38
+    end
  39
+
  40
+    it "checks if last check was more then 12 hours" do
  41
+      Spree::Config.set :check_for_spree_alerts => true
  42
+      Spree::Config.set :last_check_for_spree_alerts => 13.hours.ago.to_s
  43
+      controller.send(:should_check_alerts?).should be_true
  44
+    end
  45
+
  46
+    it "does not check if last check was recent" do
  47
+      Spree::Config.set :check_for_spree_alerts => true
  48
+      Spree::Config.set :last_check_for_spree_alerts => 4.hours.ago.to_s
  49
+      controller.send(:should_check_alerts?).should be_false
  50
+    end
  51
+
  52
+    it "does not check if preference is false" do
  53
+      Spree::Config.set :check_for_spree_alerts => false
  54
+      controller.send(:should_check_alerts?).should be_false
  55
+    end
  56
+
  57
+  end
  58
+
  59
+end
  60
+
  61
+
17  core/spec/controllers/admin/general_settings_controller_spec.rb
... ...
@@ -0,0 +1,17 @@
  1
+require File.dirname(__FILE__) + '/../../spec_helper'
  2
+
  3
+describe Admin::GeneralSettingsController do
  4
+  before :each do 
  5
+    controller.stub :current_user => mock
  6
+  end
  7
+
  8
+  it "saves dismissed alerts in a preference" do
  9
+    Spree::Config.set :dismissed_spree_alerts => "1"
  10
+    xhr :post, :dismiss_alert, :alert_id => 2
  11
+    response.response_code.should == 200
  12
+    Spree::Config[:dismissed_spree_alerts].should eq "1,2"
  13
+  end
  14
+
  15
+end
  16
+
  17
+
2  core/spree_core.gemspec
@@ -33,5 +33,5 @@ Gem::Specification.new do |s|
33 33
   s.add_dependency 'activemerchant', '= 1.17.0'
34 34
   s.add_dependency 'rails', '= 3.1.1'
35 35
   s.add_dependency 'kaminari', '>= 0.12.4'
36  
-  s.add_dependency 'deface', '>= 0.6.1'
  36
+  s.add_dependency 'deface', '>= 0.7.0'
37 37
 end

No commit comments for this range

Something went wrong with that request. Please try again.