ama_layout 5.11.0 → 5.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6cab6556e7a4d5677a6d0eb5bf73962f0955910
4
- data.tar.gz: 430b36246c6a7591a06429118f359e792e1b05d8
3
+ metadata.gz: 68fd224038d65d4b4733ef89e62342eb54616de9
4
+ data.tar.gz: 1748ef1c697447bbc45b6e0de04feda2f16f6f76
5
5
  SHA512:
6
- metadata.gz: b805a26a984a01280896dc2e4e4f63eaf54c0f3c630f6b0606130a756b0e1d585382765ed59da6c38259b99c339b42b759d6cb47370a1d9b12cb131f6dab59d2
7
- data.tar.gz: b98870ea9937be4ff27db4d8df34f3d9103aed56a3fa96f1baf476cbee4c1ecba9e05f396be535e4e34fb80348c675624474c77cf731f59f012274f35e52b959
6
+ metadata.gz: 03fdbd8ba50676c84aab9634f1476edd64396d483a6d21150f6f002b1f47181066ec1c7467891ae1e872014b56333d24ede29db654a758440bd3f50d85646734
7
+ data.tar.gz: e96716e1f6c132e99a08ba9b0fd7bb452c2dc3cb3e5abe2d68c1105e13f2465311e664fe75a729c5c1d107e670610916614bb68a028bd35dccd011b4ade57548
@@ -19,8 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'foundation-rails', '>= 6.4.1.2'
22
- spec.add_dependency 'rails', '~> 4.2'
23
- spec.add_dependency 'draper', '~> 2.1'
22
+ spec.add_dependency 'rails', '>= 4.2'
24
23
  spec.add_dependency 'browser', '~> 2.0'
25
24
  spec.add_dependency 'breadcrumbs_on_rails', '~> 3.0.1'
26
25
  spec.add_dependency 'redis-rails'
@@ -0,0 +1,3 @@
1
+ <li class="side-nav__item">
2
+ <a class="side-nav__link" href="/logout">Sign Out</a>
3
+ </li>
@@ -1,10 +1,10 @@
1
1
  require 'ama_layout/version'
2
2
  require 'rails/all'
3
3
  require 'foundation-rails'
4
- require 'draper'
5
4
  require 'browser'
6
5
  require 'breadcrumbs_on_rails'
7
6
  require 'redis-rails'
7
+ require 'ama_layout/draper_replacement'
8
8
  require 'ama_layout/breadcrumb_builder'
9
9
  require 'ama_layout/moneris'
10
10
  require 'ama_layout/navigation'
@@ -25,6 +25,7 @@ require 'ama_layout/notifications'
25
25
  module AmaLayout
26
26
  class Engine < Rails::Engine
27
27
  initializer('ama_layout') do
28
+ Rails.configuration.view_paths = File.join(self.root, 'app', 'views')
28
29
  I18n.load_path << File.join(self.root, 'app', 'config', 'locales', 'en.yml')
29
30
  ::ActionController::Base.send :include, AmaLayout::ActionController
30
31
  end
@@ -1,6 +1,7 @@
1
1
  module AmaLayout
2
- class MonerisDecorator < Draper::Decorator
3
- delegate_all
2
+ class MonerisDecorator
3
+ include AmaLayout::DraperReplacement
4
+ extend AmaLayout::DraperReplacement
4
5
 
5
6
  def textbox
6
7
  h.raw File.read textbox_style_file
@@ -1,20 +1,19 @@
1
1
  module AmaLayout
2
- class NavigationDecorator < Draper::Decorator
3
- delegate_all
2
+ class NavigationDecorator
3
+ include AmaLayout::DraperReplacement
4
+ extend AmaLayout::DraperReplacement
4
5
 
5
6
  def items
6
7
  object.items.map { |i| i.decorate }
7
8
  end
8
9
 
9
10
  def display_name_text
10
- name_or_email.truncate(30)
11
+ name_or_email.try(:truncate,30)
11
12
  end
12
13
 
13
14
  def sign_out_link
14
15
  return "" unless user
15
- h.content_tag :li, class: "side-nav__item" do
16
- h.concat h.link_to "Sign Out", "/logout", class: "side-nav__link"
17
- end
16
+ h.render partial: "ama_layout/sign_out_link"
18
17
  end
19
18
 
20
19
  def top_nav
@@ -1,6 +1,7 @@
1
1
  module AmaLayout
2
- class NavigationItemDecorator < Draper::Decorator
3
- delegate_all
2
+ class NavigationItemDecorator
3
+ include AmaLayout::DraperReplacement
4
+ extend AmaLayout::DraperReplacement
4
5
 
5
6
  def sub_nav
6
7
  object.sub_nav.map { |sn| sn.decorate }
@@ -1,6 +1,7 @@
1
1
  module AmaLayout
2
- class NotificationDecorator < Draper::Decorator
3
- delegate_all
2
+ class NotificationDecorator
3
+ include AmaLayout::DraperReplacement
4
+ extend AmaLayout::DraperReplacement
4
5
 
5
6
  ICONS = {
6
7
  notice: {
@@ -0,0 +1,27 @@
1
+ module AmaLayout
2
+ module DraperReplacement
3
+ attr_accessor :object
4
+
5
+ def h
6
+ ActionView::Base.new(::ActionController::Base.view_paths, {}, ::ApplicationController.new)
7
+ end
8
+
9
+ def initialize(args = {})
10
+ self.object = args
11
+ end
12
+
13
+ def self.decorate_collection(objects = {})
14
+ objects.map { |o| self.new(o) }
15
+ end
16
+
17
+ def method_missing(method, *args, &block)
18
+ return super unless delegatable?(method)
19
+
20
+ (object || DraperReplacement).send(method, *args, &block)
21
+ end
22
+
23
+ def delegatable?(method)
24
+ object.respond_to?(method) || DraperReplacement.respond_to?(method)
25
+ end
26
+ end
27
+ end
@@ -1,7 +1,10 @@
1
1
  module AmaLayout
2
2
  class Moneris
3
3
  include ActiveModel::Model
4
- include Draper::Decoratable
4
+
5
+ def decorate
6
+ AmaLayout::MonerisDecorator.new(self)
7
+ end
5
8
 
6
9
  attr_accessor :textbox_style_file
7
10
 
@@ -1,7 +1,10 @@
1
1
  module AmaLayout
2
2
  class Navigation
3
3
  include ActiveModel::Model
4
- include Draper::Decoratable
4
+
5
+ def decorate
6
+ AmaLayout::NavigationDecorator.new(self)
7
+ end
5
8
 
6
9
  attr_accessor :user, :current_url, :nav_file_path, :display_name
7
10
 
@@ -1,7 +1,10 @@
1
1
  module AmaLayout
2
2
  class NavigationItem
3
3
  include ActiveModel::Model
4
- include Draper::Decoratable
4
+
5
+ def decorate
6
+ AmaLayout::NavigationItemDecorator.new(self)
7
+ end
5
8
 
6
9
  attr_accessor :text, :icon, :link, :target, :alt, :sub_nav, :current_url
7
10
 
@@ -1,7 +1,5 @@
1
1
  module AmaLayout
2
2
  class Notification
3
- include Draper::Decoratable
4
-
5
3
  TYPES = %i[notice warning alert].freeze
6
4
  DEFAULT_LIFESPAN = 1.year.freeze
7
5
  FORMAT_VERSION = '1.0.0'.freeze
@@ -1,3 +1,3 @@
1
1
  module AmaLayout
2
- VERSION = '5.11.0'
2
+ VERSION = '5.12.0'
3
3
  end
@@ -94,8 +94,9 @@ describe AmaLayout::NavigationDecorator do
94
94
  context "with items" do
95
95
  it "renders the partial" do
96
96
  allow_any_instance_of(AmaLayout::Navigation).to receive(:user).and_return(OpenStruct.new(navigation: "member"))
97
- allow_any_instance_of(Draper::HelperProxy).to receive(:render).and_return "render"
98
- expect(navigation_presenter.top_nav).to eq "render"
97
+ allow(Rails.configuration).to receive(:amaabca_site).and_return("amaabca.example.com")
98
+ allow(navigation_presenter).to receive(:sign_out_link).and_return("sign_out_link")
99
+ expect(navigation_presenter.top_nav).to include("AMA Road Reports", "http://auth.waffles.ca")
99
100
  end
100
101
  end
101
102
 
@@ -110,8 +111,7 @@ describe AmaLayout::NavigationDecorator do
110
111
  context "with items" do
111
112
  it "renders the partial" do
112
113
  allow_any_instance_of(AmaLayout::Navigation).to receive(:user).and_return(OpenStruct.new(navigation: "member"))
113
- allow_any_instance_of(Draper::HelperProxy).to receive(:render).and_return "render"
114
- expect(navigation_presenter.sidebar).to eq "render"
114
+ expect(navigation_presenter.sidebar).to include("Online Account", "Membership Overview", "Rewards Overview")
115
115
  end
116
116
  end
117
117
 
@@ -125,8 +125,7 @@ describe AmaLayout::NavigationDecorator do
125
125
  context "account toggle" do
126
126
  it "in ama_layout it renders a blank partial" do
127
127
  allow_any_instance_of(AmaLayout::Navigation).to receive(:user).and_return(OpenStruct.new(navigation: "member"))
128
- allow_any_instance_of(Draper::HelperProxy).to receive(:render).and_return "render"
129
- expect(navigation_presenter.account_toggle).to eq "render"
128
+ expect(navigation_presenter.account_toggle).to eq ""
130
129
  end
131
130
  end
132
131
 
@@ -153,8 +152,7 @@ describe AmaLayout::NavigationDecorator do
153
152
 
154
153
  describe '#notifications' do
155
154
  it 'renders the content to the page' do
156
- expect(subject.h).to receive(:render).once.and_return true
157
- expect(subject.notifications).to be true
155
+ expect(subject.notifications).to include("data-notifications-toggle")
158
156
  end
159
157
  end
160
158
 
@@ -217,8 +215,7 @@ describe AmaLayout::NavigationDecorator do
217
215
 
218
216
  describe '#notification_sidebar' do
219
217
  it 'renders content to the page' do
220
- expect(subject.h).to receive(:render).once.and_return true
221
- expect(subject.notification_sidebar).to be true
218
+ expect(subject.notification_sidebar).to include("Sign up now","off-canvas position-right")
222
219
  end
223
220
  end
224
221
 
@@ -39,8 +39,7 @@ describe AmaLayout::NavigationItemDecorator do
39
39
  context "with items" do
40
40
  it "renders the partial" do
41
41
  navigation_item.sub_nav = items
42
- allow_any_instance_of(Draper::HelperProxy).to receive(:render).and_return "render"
43
- expect(navigation_item_presenter.top_sub_nav).to eq "render"
42
+ expect(navigation_item_presenter.top_sub_nav).to include("Othersite Overview", "http://othersite.com")
44
43
  end
45
44
  end
46
45
 
@@ -55,8 +54,7 @@ describe AmaLayout::NavigationItemDecorator do
55
54
  context "with items" do
56
55
  it "renders the partial" do
57
56
  navigation_item.sub_nav = items
58
- allow_any_instance_of(Draper::HelperProxy).to receive(:render).and_return "render"
59
- expect(navigation_item_presenter.sidebar_sub_nav).to eq "render"
57
+ expect(navigation_item_presenter.sidebar_sub_nav).to include(">Othersite Overview", "http://othersite.com")
60
58
  end
61
59
  end
62
60
 
@@ -18,8 +18,6 @@ ActionView::TestCase::TestController.instance_eval do
18
18
  helper Rails.application.routes.url_helpers
19
19
  end
20
20
 
21
- Draper::ViewContext.test_strategy :fast
22
-
23
21
  RSpec.configure do |config|
24
22
  config.infer_spec_type_from_file_location!
25
23
  config.include Rails.application.routes.url_helpers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ama_layout
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.11.0
4
+ version: 5.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van den Beuken
@@ -18,7 +18,7 @@ authors:
18
18
  autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
- date: 2017-08-02 00:00:00.000000000 Z
21
+ date: 2017-08-15 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: foundation-rails
@@ -38,30 +38,16 @@ dependencies:
38
38
  name: rails
39
39
  requirement: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - "~>"
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '4.2'
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - "~>"
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '4.2'
51
- - !ruby/object:Gem::Dependency
52
- name: draper
53
- requirement: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - "~>"
56
- - !ruby/object:Gem::Version
57
- version: '2.1'
58
- type: :runtime
59
- prerelease: false
60
- version_requirements: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - "~>"
63
- - !ruby/object:Gem::Version
64
- version: '2.1'
65
51
  - !ruby/object:Gem::Dependency
66
52
  name: browser
67
53
  requirement: !ruby/object:Gem::Requirement
@@ -293,6 +279,7 @@ files:
293
279
  - app/views/ama_layout/_notification_sidebar.html.erb
294
280
  - app/views/ama_layout/_notifications.html.erb
295
281
  - app/views/ama_layout/_sidebar.html.erb
282
+ - app/views/ama_layout/_sign_out_link.html.erb
296
283
  - app/views/ama_layout/_siteheader.html.erb
297
284
  - app/views/ama_layout/_sub_nav.html.erb
298
285
  - app/views/ama_layout/_sub_nav_item.html.erb
@@ -309,6 +296,7 @@ files:
309
296
  - lib/ama_layout/decorators/navigation_decorator.rb
310
297
  - lib/ama_layout/decorators/navigation_item_decorator.rb
311
298
  - lib/ama_layout/decorators/notification_decorator.rb
299
+ - lib/ama_layout/draper_replacement.rb
312
300
  - lib/ama_layout/moneris.rb
313
301
  - lib/ama_layout/moneris/textbox.txt
314
302
  - lib/ama_layout/navigation.rb
@@ -377,7 +365,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
377
365
  version: '0'
378
366
  requirements: []
379
367
  rubyforge_project:
380
- rubygems_version: 2.4.5.1
368
+ rubygems_version: 2.5.1
381
369
  signing_key:
382
370
  specification_version: 4
383
371
  summary: ".ama.ab.ca site layouts"