Skip to content

Commit

Permalink
Merge pull request #257 from amaabca/ado-17518-use-draper-for-rails-6
Browse files Browse the repository at this point in the history
ADO 17518: Support Rails 6
  • Loading branch information
michealakinwonmi authored Jul 17, 2024
2 parents 3f3707e + bcf2601 commit ff3c6a2
Show file tree
Hide file tree
Showing 35 changed files with 120 additions and 227 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
*.a
mkmf.log
*.gem
bin
3 changes: 2 additions & 1 deletion .simplecov
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Add this line to your application's Gemfile:
```ruby
gem 'ama_layout'
```

And then execute:

$ bundle
Expand Down
7 changes: 2 additions & 5 deletions ama_layout.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]'
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion app/views/ama_layout/agent/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2 class="side-nav__header">Online Account</h2>
<div class="side-nav__content">
<ul class="side-nav__list">
<%= render partial: "ama_layout/main_nav_item", collection: navigation.items, as: :nav_item %>
<%= render partial: ama_layout_partial('main_nav_item'), collection: navigation.items, as: :nav_item %>
</ul>
</div>
</aside>
2 changes: 1 addition & 1 deletion app/views/ama_layout/v2/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2 class="side-nav__header">Online Account</h2>
<div class="side-nav__content">
<ul class="side-nav__list">
<%= render partial: "ama_layout/main_nav_item", collection: navigation.items, as: :nav_item %>
<%= render partial: ama_layout_partial('main_nav_item'), collection: navigation.items, as: :nav_item %>
</ul>
</div>
</aside>
2 changes: 1 addition & 1 deletion app/views/ama_layout/v2/_siteheader.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<li>
<a href="<%= Rails.configuration.amaabca_site %>/contact">Contact Us</a>
</li>
<%= navigation.account_toggle(self) %>
<%= navigation.account_toggle %>
<%= navigation.top_nav %>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/ama_layout/v2/_sub_nav.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ul class="side-nav__child-list">
<%= render partial: "ama_layout/sub_nav_item", collection: sub_nav, as: :nav_item %>
<%= render partial: ama_layout_partial('sub_nav_item'), collection: sub_nav, as: :nav_item %>
</ul>
2 changes: 1 addition & 1 deletion app/views/ama_layout/v2/_top_sub_nav.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ul class="submenu menu vertical" data-submenu>
<%= render partial: "ama_layout/top_sub_nav_item", collection: sub_nav, as: :nav_item %>
<%= render partial: ama_layout_partial('top_sub_nav_item'), collection: sub_nav, as: :nav_item %>
</ul>
2 changes: 1 addition & 1 deletion app/views/ama_layout/v3/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2 class="side-nav__header">Online Account</h2>
<div class="side-nav__content">
<ul class="side-nav__list">
<%= render partial: "ama_layout/main_nav_item", collection: navigation.items, as: :nav_item %>
<%= render partial: ama_layout_partial('main_nav_item'), collection: navigation.items, as: :nav_item %>
</ul>
</div>
</aside>
2 changes: 1 addition & 1 deletion app/views/ama_layout/v3/_siteheader.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<li>
<a href="<%= Rails.configuration.amaabca_site %>/contact">Contact Us</a>
</li>
<%= navigation.account_toggle(self) %>
<%= navigation.account_toggle %>
<%= navigation.top_nav %>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/ama_layout/v3/_sub_nav.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ul class="side-nav__child-list">
<%= render partial: "ama_layout/sub_nav_item", collection: sub_nav, as: :nav_item %>
<%= render partial: ama_layout_partial('sub_nav_item'), collection: sub_nav, as: :nav_item %>
</ul>
2 changes: 1 addition & 1 deletion app/views/ama_layout/v3/_top_sub_nav.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<ul class="submenu menu vertical" data-submenu>
<%= render partial: "ama_layout/top_sub_nav_item", collection: sub_nav, as: :nav_item %>
<%= render partial: ama_layout_partial('top_sub_nav_item'), collection: sub_nav, as: :nav_item %>
</ul>
4 changes: 2 additions & 2 deletions lib/ama_layout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
22 changes: 0 additions & 22 deletions lib/ama_layout/ama_layout_view.rb

This file was deleted.

10 changes: 6 additions & 4 deletions lib/ama_layout/decorators/agent/navigation_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions lib/ama_layout/decorators/moneris_decorator.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions lib/ama_layout/decorators/navigation_decorator.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions lib/ama_layout/decorators/navigation_item_decorator.rb
Original file line number Diff line number Diff line change
@@ -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 }
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions lib/ama_layout/decorators/notification_decorator.rb
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
37 changes: 0 additions & 37 deletions lib/ama_layout/draper_replacement.rb

This file was deleted.

8 changes: 6 additions & 2 deletions lib/ama_layout/notification_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/ama_layout/notifications/redis_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ama_layout/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module AmaLayout
VERSION = '11.5.1'
VERSION = '12.0.0'
end
2 changes: 1 addition & 1 deletion spec/agent/navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion spec/ama_layout/breadcrumb_builder_spec.rb
Original file line number Diff line number Diff line change
@@ -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] }
Expand Down
Loading

0 comments on commit ff3c6a2

Please sign in to comment.