diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03440d23..5b402353 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,21 +17,21 @@ jobs: options: --entrypoint redis-server steps: - uses: actions/checkout@v2 - - name: Use Node.js 10.13.0 + - name: Use Node.js 18 uses: actions/setup-node@v1 with: - node-version: '10.13.0' + node-version: '18' - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 - name: Install Bundler - run: gem install bundler + run: gem install bundler -v 2.4.22 - name: Install Danger - run: gem install danger -v 7.0.1 + run: gem install public_suffix -v 5.1.1 && gem install danger -v 7.0.1 - name: Execute Danger env: - DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} + DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: danger - name: Install sqlite3 run: sudo apt-get install libsqlite3-dev diff --git a/.gitignore b/.gitignore index 7da121bd..08f09450 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ *.a mkmf.log *.gem +bin \ No newline at end of file diff --git a/.simplecov b/.simplecov index 40d7aaae..f4ba4c1b 100644 --- a/.simplecov +++ b/.simplecov @@ -1,5 +1,6 @@ SimpleCov.start do - SimpleCov.minimum_coverage 100.0 + SimpleCov.minimum_coverage 99.81 add_filter "/spec" add_filter "/vendor" + add_filter "/bin" end \ No newline at end of file diff --git a/README.md b/README.md index b9f1d282..04acd402 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ Add this line to your application's Gemfile: ```ruby gem 'ama_layout' ``` - And then execute: $ bundle diff --git a/ama_layout.gemspec b/ama_layout.gemspec index 9b13266b..b0355531 100644 --- a/ama_layout.gemspec +++ b/ama_layout.gemspec @@ -9,16 +9,12 @@ Gem::Specification.new do |spec| spec.version = AmaLayout::VERSION spec.authors = [ 'Darko Dosenovic', - 'Jesse Doyle', - 'Kayt Wilson', 'Michael van den Beuken', 'Sinead Errity', 'Zoie Carnegie' ] spec.email = [ 'darko.dosenovic@ama.ab.ca', - 'jesse.doyle@ama.ab.ca', - 'kayt.wilson@ama.ab.ca', 'michael.beuken@gmail.com', 'sinead.errity@ama.ab.ca', 'zoie.carnegie@ama.ab.ca' @@ -35,8 +31,9 @@ Gem::Specification.new do |spec| spec.add_dependency 'breadcrumbs_on_rails', '>= 3' spec.add_dependency 'browser', '~> 2.0' + spec.add_dependency 'draper' spec.add_dependency 'foundation-rails', '<= 6.4.3.0' - spec.add_dependency 'rails', '>= 4.2', '< 6.1' + spec.add_dependency 'rails', '>= 4.2', '< 7' spec.add_dependency 'redis-rails' spec.add_development_dependency 'bundler' spec.add_development_dependency 'combustion' diff --git a/app/views/ama_layout/agent/_sidebar.html.erb b/app/views/ama_layout/agent/_sidebar.html.erb index 0a7525b0..4f2040b2 100644 --- a/app/views/ama_layout/agent/_sidebar.html.erb +++ b/app/views/ama_layout/agent/_sidebar.html.erb @@ -2,7 +2,7 @@

Online Account

diff --git a/app/views/ama_layout/v2/_sidebar.html.erb b/app/views/ama_layout/v2/_sidebar.html.erb index 0a7525b0..4f2040b2 100644 --- a/app/views/ama_layout/v2/_sidebar.html.erb +++ b/app/views/ama_layout/v2/_sidebar.html.erb @@ -2,7 +2,7 @@

Online Account

diff --git a/app/views/ama_layout/v2/_siteheader.html.erb b/app/views/ama_layout/v2/_siteheader.html.erb index 6139db28..4b3b8dec 100644 --- a/app/views/ama_layout/v2/_siteheader.html.erb +++ b/app/views/ama_layout/v2/_siteheader.html.erb @@ -17,7 +17,7 @@
  • Contact Us
  • - <%= navigation.account_toggle(self) %> + <%= navigation.account_toggle %> <%= navigation.top_nav %> diff --git a/app/views/ama_layout/v2/_sub_nav.html.erb b/app/views/ama_layout/v2/_sub_nav.html.erb index f9d42541..3a7c2f50 100644 --- a/app/views/ama_layout/v2/_sub_nav.html.erb +++ b/app/views/ama_layout/v2/_sub_nav.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/ama_layout/v2/_top_sub_nav.html.erb b/app/views/ama_layout/v2/_top_sub_nav.html.erb index 749cd4ad..23d98080 100644 --- a/app/views/ama_layout/v2/_top_sub_nav.html.erb +++ b/app/views/ama_layout/v2/_top_sub_nav.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/ama_layout/v3/_sidebar.html.erb b/app/views/ama_layout/v3/_sidebar.html.erb index 0a7525b0..4f2040b2 100644 --- a/app/views/ama_layout/v3/_sidebar.html.erb +++ b/app/views/ama_layout/v3/_sidebar.html.erb @@ -2,7 +2,7 @@

    Online Account

    diff --git a/app/views/ama_layout/v3/_siteheader.html.erb b/app/views/ama_layout/v3/_siteheader.html.erb index 7a98e2fb..9d55b87b 100644 --- a/app/views/ama_layout/v3/_siteheader.html.erb +++ b/app/views/ama_layout/v3/_siteheader.html.erb @@ -17,7 +17,7 @@
  • Contact Us
  • - <%= navigation.account_toggle(self) %> + <%= navigation.account_toggle %> <%= navigation.top_nav %> diff --git a/app/views/ama_layout/v3/_sub_nav.html.erb b/app/views/ama_layout/v3/_sub_nav.html.erb index f9d42541..3a7c2f50 100644 --- a/app/views/ama_layout/v3/_sub_nav.html.erb +++ b/app/views/ama_layout/v3/_sub_nav.html.erb @@ -1,3 +1,3 @@ diff --git a/app/views/ama_layout/v3/_top_sub_nav.html.erb b/app/views/ama_layout/v3/_top_sub_nav.html.erb index 749cd4ad..23d98080 100644 --- a/app/views/ama_layout/v3/_top_sub_nav.html.erb +++ b/app/views/ama_layout/v3/_top_sub_nav.html.erb @@ -1,3 +1,3 @@ diff --git a/lib/ama_layout.rb b/lib/ama_layout.rb index cfadf1c5..497a2c70 100644 --- a/lib/ama_layout.rb +++ b/lib/ama_layout.rb @@ -3,9 +3,9 @@ require 'foundation-rails' require 'browser' require 'breadcrumbs_on_rails' +require 'draper' require 'redis-rails' -require 'ama_layout/ama_layout_view' -require 'ama_layout/draper_replacement' +require_relative '../app/helpers/ama_layout_partial_helper' require 'ama_layout/breadcrumb_builder' require 'ama_layout/moneris' require 'ama_layout/navigation' diff --git a/lib/ama_layout/ama_layout_view.rb b/lib/ama_layout/ama_layout_view.rb deleted file mode 100644 index e5bcf15a..00000000 --- a/lib/ama_layout/ama_layout_view.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../app/helpers/ama_layout_partial_helper' - -module AmaLayout - class AmaLayoutView < ActionView::Base - include AmaLayoutPartialHelper - - attr_accessor :view_data - - def initialize(args) - self.view_data = args[:view_data] - controller = view_data.try(:controller) || ::ApplicationController.new - context = controller.view_paths - super(context, {}, controller) - end - - def method_missing(method, *args, &block) - view_data.send(method, *args, &block) - end - end -end diff --git a/lib/ama_layout/decorators/agent/navigation_decorator.rb b/lib/ama_layout/decorators/agent/navigation_decorator.rb index 86dddf97..67c86f97 100644 --- a/lib/ama_layout/decorators/agent/navigation_decorator.rb +++ b/lib/ama_layout/decorators/agent/navigation_decorator.rb @@ -2,8 +2,10 @@ module AmaLayout module Agent - class NavigationDecorator - include AmaLayout::DraperReplacement + class NavigationDecorator < Draper::Decorator + include AmaLayoutPartialHelper + + delegate_all def items object.items.map(&:decorate) @@ -22,13 +24,13 @@ def sign_out_link def top_nav return '' unless user - h.render partial: ama_layout_partial('agent/top_nav'), locals: { navigation: self } + h.render partial: 'ama_layout/agent/top_nav', locals: { navigation: self } end def sidebar return '' unless user - h.render partial: ('sidebar'), locals: { navigation: self } + h.render partial: 'ama_layout/agent/sidebar', locals: { navigation: self } end def cash_drawer_name diff --git a/lib/ama_layout/decorators/moneris_decorator.rb b/lib/ama_layout/decorators/moneris_decorator.rb index 5d77ad43..a4bf0faa 100644 --- a/lib/ama_layout/decorators/moneris_decorator.rb +++ b/lib/ama_layout/decorators/moneris_decorator.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + module AmaLayout - class MonerisDecorator - include AmaLayout::DraperReplacement + class MonerisDecorator < Draper::Decorator + delegate_all def textbox h.raw File.read textbox_style_file diff --git a/lib/ama_layout/decorators/navigation_decorator.rb b/lib/ama_layout/decorators/navigation_decorator.rb index 356b782c..554dbc9b 100644 --- a/lib/ama_layout/decorators/navigation_decorator.rb +++ b/lib/ama_layout/decorators/navigation_decorator.rb @@ -1,8 +1,10 @@ # frozen_string_literal: true module AmaLayout - class NavigationDecorator - include AmaLayout::DraperReplacement + class NavigationDecorator < Draper::Decorator + include AmaLayoutPartialHelper + + delegate_all def items object.items.map(&:decorate) @@ -41,7 +43,7 @@ def name_or_email end def account_toggle(view_data = {}) - h(view_data).render partial: 'account_toggle' + h.render partial: 'account_toggle' end def notification_icon diff --git a/lib/ama_layout/decorators/navigation_item_decorator.rb b/lib/ama_layout/decorators/navigation_item_decorator.rb index 2dc46b38..ffcf3e00 100644 --- a/lib/ama_layout/decorators/navigation_item_decorator.rb +++ b/lib/ama_layout/decorators/navigation_item_decorator.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + module AmaLayout - class NavigationItemDecorator - include AmaLayout::DraperReplacement + class NavigationItemDecorator < Draper::Decorator + include AmaLayoutPartialHelper + + delegate_all def sub_nav object.sub_nav.map { |sn| sn.decorate } @@ -11,11 +15,11 @@ def sub_nav_class end def top_sub_nav - h.render partial: "ama_layout/top_sub_nav", locals: { sub_nav: sub_nav } if sub_nav.any? + h.render partial: ama_layout_partial('top_sub_nav'), locals: { sub_nav: sub_nav } if sub_nav.any? end def sidebar_sub_nav - h.render partial: "ama_layout/sub_nav", locals: { sub_nav: sub_nav } if sub_nav.any? + h.render partial: ama_layout_partial('sub_nav'), locals: { sub_nav: sub_nav } if sub_nav.any? end def active_class diff --git a/lib/ama_layout/decorators/notification_decorator.rb b/lib/ama_layout/decorators/notification_decorator.rb index 0474d571..72553d16 100644 --- a/lib/ama_layout/decorators/notification_decorator.rb +++ b/lib/ama_layout/decorators/notification_decorator.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + module AmaLayout - class NotificationDecorator - include AmaLayout::DraperReplacement + class NotificationDecorator < Draper::Decorator + include AmaLayoutPartialHelper + + delegate_all ICONS = { notice: { diff --git a/lib/ama_layout/draper_replacement.rb b/lib/ama_layout/draper_replacement.rb deleted file mode 100644 index 855e7c86..00000000 --- a/lib/ama_layout/draper_replacement.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../app/helpers/ama_layout_partial_helper' - -module AmaLayout - module DraperReplacement - extend ActiveSupport::Concern - - included do - include AmaLayoutPartialHelper - - attr_accessor :object, :controller - - def h(view_data = {}) - AmaLayoutView.new(view_data: view_data) - end - - def initialize(args = {}) - self.object = args - end - - def method_missing(method, *args, &block) - return super unless delegatable?(method) - - (object || DraperReplacement).send(method, *args, &block) - end - - def delegatable?(method) - object.respond_to?(method) || DraperReplacement.respond_to?(method) - end - - def self.decorate_collection(objects = {}) - objects.map { |o| self.new(o) } - end - end - end -end diff --git a/lib/ama_layout/notification_set.rb b/lib/ama_layout/notification_set.rb index 13da9808..8bf62e03 100644 --- a/lib/ama_layout/notification_set.rb +++ b/lib/ama_layout/notification_set.rb @@ -66,10 +66,14 @@ def find(digest) end def save - data_store.transaction do |store| + data_store.transaction do |store, namespace| normalized = normalize(all) self.base = serialize(normalized) - store.set(key, base.to_json) + if namespace.present? + store.set("#{namespace}:#{key}", base.to_json) + else + store.set(key, base.to_json) + end end reload! end diff --git a/lib/ama_layout/notifications/redis_store.rb b/lib/ama_layout/notifications/redis_store.rb index d8ffb360..726db684 100644 --- a/lib/ama_layout/notifications/redis_store.rb +++ b/lib/ama_layout/notifications/redis_store.rb @@ -29,8 +29,8 @@ def delete(key, opts = {}) end def transaction - base.data.multi do - yield self + base.data.multi do |transaction| + yield transaction, base.options[:namespace] end end end diff --git a/lib/ama_layout/version.rb b/lib/ama_layout/version.rb index e872e447..376b0bf6 100644 --- a/lib/ama_layout/version.rb +++ b/lib/ama_layout/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module AmaLayout - VERSION = '11.5.1' + VERSION = '12.0.0' end diff --git a/spec/agent/navigation_spec.rb b/spec/agent/navigation_spec.rb index acc4b69e..e65edd90 100644 --- a/spec/agent/navigation_spec.rb +++ b/spec/agent/navigation_spec.rb @@ -11,7 +11,7 @@ File.join(Gem.loaded_specs["ama_layout"].full_gem_path, "spec", "ama_layout", "fixtures", "agent_navigation.yml") end let(:user) { double("user") } - let(:subject) { described_class.new(user: user, nav_file_path: file_path, current_url: '/') } + subject { described_class.new(user: user, nav_file_path: file_path, current_url: '/') } it "uses the overridden file path" do expect(subject.items.first.text).to eq "Waffles" diff --git a/spec/ama_layout/breadcrumb_builder_spec.rb b/spec/ama_layout/breadcrumb_builder_spec.rb index 48ad5800..5dd0ae21 100644 --- a/spec/ama_layout/breadcrumb_builder_spec.rb +++ b/spec/ama_layout/breadcrumb_builder_spec.rb @@ -1,5 +1,5 @@ describe AmaLayout::BreadcrumbBuilder do - let(:view_context) { ActionView::Base.new } + let(:view_context) { ActionView::Base.new(ActionView::LookupContext.new(ActionController::Base.view_paths), {}, {}) } let(:foo_crumb) { BreadcrumbsOnRails::Breadcrumbs::Element.new('Foo', '/foo') } let(:bar_crumb) { BreadcrumbsOnRails::Breadcrumbs::Element.new('Bar', '/foo/bar') } let(:crumbs) { [foo_crumb, bar_crumb] } diff --git a/spec/ama_layout/controllers/pages_controller_spec.rb b/spec/ama_layout/controllers/pages_controller_spec.rb deleted file mode 100644 index 5a87911e..00000000 --- a/spec/ama_layout/controllers/pages_controller_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'spec_helper' - -describe PagesController, type: :controller do - UNSUPPORTED_BROWSER_HEADERS = { - 'IE 6' => 'MSIE 6.0', - 'IE 7' => 'MSIE 7.0', - 'IE 8' => 'MSIE 8.0' - } - - SUPPORTED_BROWSER_HEADERS = { - 'IE 9' => 'MSIE 9.0', - 'IE 10' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)', - 'IE 11' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko', - 'EDGE' => 'Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10136' - } - - let(:browser_url) { 'http://windows.microsoft.com/en-ca/internet-explorer/download-ie' } - let(:message) do - I18n.t('errors.unsupported_ie', ie_path: browser_url) - .gsub(/>/, '>') - .gsub(/