cmor_testimonials 0.0.8.pre → 0.0.9.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47e03fe0e148a6d92430c17764f771cfd3d6d99b77818570d52b7738b9782b1d
4
- data.tar.gz: 46ccb4604316104565146d9dc8f48b7077e5c1242256c7124d0fa3bb4b7846c8
3
+ metadata.gz: 673d3c98117a279b7e256e92d00802174e2ba4a094cefaf7b260e62e344711e6
4
+ data.tar.gz: 718f7433d4a4a36d34c65b8e6a03e82b266e592f12c2fe49800c227d599a81ff
5
5
  SHA512:
6
- metadata.gz: ba5df50c762711c4a0843b6932df7d33cddf463dd2eea84ed4239fd8e00b3af90a16c8ead75fef426c0ee3d07348804773ea62ed1fe9ce8d9781e98cbf6dc76f
7
- data.tar.gz: a05f728bd7702604cfc8c1d7db97b37fa68b65498e052b4a3ceb001f4f59e185816412f5cdc39ace266b5cfbe4e963f0585ed8a9d5337a459ca58df60acd5037
6
+ metadata.gz: 47ccafd07ae19e4e8d5a7925637061a7d0de322c09e91ea755511e9610ed73a57bad1d8d275e5b11e30a2698923f1af5f539be20d53f706d4d751eda97f0608e
7
+ data.tar.gz: 32e0e61cb536bb2ba895c8fc8ce7df1ddf63ddb70332be4290fcb0c0aecdf7f3c99b6c63dd21f7fcb432797da75683026107eb0eec65328bdd345fef398305a5
@@ -4,12 +4,12 @@
4
4
  }
5
5
 
6
6
 
7
- .carousel-control-prev-icon:before {
7
+ .carousel-control-prev:before {
8
8
  content:"\2039";
9
9
  font-size: 250%;
10
10
  }
11
11
 
12
- .carousel-control-next-icon:before {
12
+ .carousel-control-next:before {
13
13
  content:"\203A";
14
14
  font-size: 250%;
15
15
  }
@@ -1,7 +1,14 @@
1
1
  module Cmor
2
2
  module Testimonials
3
3
  class Category < ActiveRecord::Base
4
- has_many :testimonials, -> { order(position: :asc) }, dependent: :destroy
4
+ has_many :testimonials, -> { order(position: :asc) }, dependent: :destroy do
5
+ def published
6
+ merge(Testimonial.published)
7
+ end
8
+ end
9
+
10
+ scope :with, ->(type) { joins(type) }
11
+ scope :with_published_testimonials, -> { with(:testimonials).merge(Testimonial.published) }
5
12
 
6
13
  validates :locale, presence: true, inclusion: { in: I18n.available_locales.map(&:to_s) }
7
14
  validates :identifier, presence: true, uniqueness: { scope: [ :locale ] }
@@ -1,7 +1,7 @@
1
1
  module Cmor
2
2
  module Testimonials
3
3
  class ApplicationViewHelper < Rao::ViewHelper::Base
4
- def render_category(identifier, options = {})
4
+ def render_category(category_or_identifier, options = {})
5
5
  default_variant_options = Cmor::Testimonials::Configuration.image_variant_options[:category]
6
6
  options.reverse_merge!(
7
7
  autostart: true,
@@ -15,18 +15,16 @@ module Cmor
15
15
  variant_options: default_variant_options,
16
16
  font_awesome: false
17
17
  )
18
- category = Cmor::Testimonials::Category.where(identifier: identifier).first
18
+ category = if category_or_identifier.is_a?(Cmor::Testimonials::Category)
19
+ category_or_identifier
20
+ else
21
+ Cmor::Testimonials::Category.where(identifier: category_or_identifier).first
22
+ end
19
23
 
20
- if category.present?
24
+ if category.present? && category.testimonials.published.any?
21
25
  render category: category, options: options
22
26
  end
23
27
  end
24
-
25
- private
26
-
27
- def render(locals = {})
28
- c.render partial: "/#{self.class.name.underscore}/#{caller_locations(1,1)[0].label}", locals: locals
29
- end
30
28
  end
31
29
  end
32
30
  end
@@ -2,11 +2,11 @@
2
2
  - if options[:indicators]
3
3
  / Carousel indicators
4
4
  %ol.carousel-indicators
5
- - category.testimonials.count.times do |i|
5
+ - category.testimonials.published.count.times do |i|
6
6
  %li{ class: (i == 0) ? "active" : "", "data-slide-to" => i, "data-target" => "##{dom_id(category)}"}
7
7
  / Wrapper for carousel items
8
8
  .carousel-inner
9
- - category.testimonials.each_with_index do |testimonial, i|
9
+ - category.testimonials.published.each_with_index do |testimonial, i|
10
10
  .item.carousel-item.text-center{ class: ((i == 0) ? 'active' : '') }
11
11
  .img-box
12
12
  %img.img-thumbnail.rounded-circle{:alt => "", :src => main_app.url_for(testimonial.image.variant(options[:variant_options])) }/
@@ -14,15 +14,11 @@
14
14
  %p.overview
15
15
  = "<b>#{testimonial.fullname}</b>, #{testimonial.role} - #{testimonial.company}".html_safe
16
16
  - if options[:controls]
17
- %a.carousel-control-prev{"data-slide" => "prev", :href => "##{dom_id(category)}", :role => "button"}
18
- - if options[:font_awesome]
19
- %i.fa.fa-angle-left
20
- - else
21
- %span.carousel-control-prev-icon{"aria-hidden" => "true"}
17
+ - if options[:font_awesome]
18
+ %i.fa.fa-angle-left
19
+ %i.fa.fa-angle-right
20
+ - else
21
+ %a.carousel-control-prev{"data-slide" => "prev", :href => "##{dom_id(category)}", :role => "button"}
22
22
  %span.sr-only= t('.previous')
23
- %a.carousel-control-next{"data-slide" => "next", :href => "##{dom_id(category)}", :role => "button"}
24
- - if options[:font_awesome]
25
- %i.fa.fa-angle-right
26
- - else
27
- %span.carousel-control-next-icon{"aria-hidden" => "true"}
23
+ %a.carousel-control-next{"data-slide" => "next", :href => "##{dom_id(category)}", :role => "button"}
28
24
  %span.sr-only= t('.next')
@@ -33,7 +33,7 @@ de:
33
33
  cmor:
34
34
  testimonials:
35
35
  application_view_helper:
36
- render:
36
+ render_category:
37
37
  next: Vor
38
38
  previous: Zurück
39
39
  routes:
@@ -33,7 +33,7 @@ en:
33
33
  cmor:
34
34
  testimonials:
35
35
  application_view_helper:
36
- render:
36
+ render_category:
37
37
  next: Next
38
38
  previous: Previous
39
39
  routes:
@@ -1,15 +1,37 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  RSpec.describe Cmor::Testimonials::ApplicationViewHelper, type: :view_helper do
4
- let(:testimonials) { create_list(:cmor_testimonials_testimonial, 3) }
5
- let(:category) { create(:cmor_testimonials_category, testimonials: testimonials) }
6
- let(:args) { [category.identifier, {}] }
7
4
  before(:each) do
8
5
  register_view_helper Markup::Rails::ApplicationViewHelper, as: :markup_helper
9
6
  end
10
-
11
7
 
12
- describe 'render_category' do
13
- it { expect(html).to have_css('div.cmor-testimonials-category') }
8
+ context 'testimonials present' do
9
+ let(:testimonials) { create_list(:cmor_testimonials_testimonial, 3) }
10
+ let(:category) { create(:cmor_testimonials_category, testimonials: testimonials) }
11
+ let(:args) { [category.identifier, {}] }
12
+
13
+ describe 'render_category' do
14
+ it { expect(html).to have_css('div.cmor-testimonials-category') }
15
+ end
16
+ end
17
+
18
+ context 'testimonials absent' do
19
+ let(:testimonials) {[]}
20
+ let(:category) { create(:cmor_testimonials_category, testimonials: testimonials) }
21
+ let(:args) { [category.identifier, {}] }
22
+
23
+ describe 'render_category' do
24
+ it { expect(rendered).to eq(nil) }
25
+ end
26
+ end
27
+
28
+ context 'when using a category as first argument' do
29
+ let(:testimonials) { create_list(:cmor_testimonials_testimonial, 3) }
30
+ let(:category) { create(:cmor_testimonials_category, testimonials: testimonials) }
31
+ let(:args) { [category, {}] }
32
+
33
+ describe 'render_category' do
34
+ it { expect(html).to have_css('div.cmor-testimonials-category') }
35
+ end
14
36
  end
15
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmor_testimonials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8.pre
4
+ version: 0.0.9.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Müller
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-25 00:00:00.000000000 Z
12
+ date: 2019-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,28 +31,28 @@ dependencies:
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 0.0.8.pre
34
+ version: 0.0.9.pre
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 0.0.8.pre
41
+ version: 0.0.9.pre
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: cmor_core_frontend
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 0.0.8.pre
48
+ version: 0.0.9.pre
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 0.0.8.pre
55
+ version: 0.0.9.pre
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: sqlite3
58
58
  requirement: !ruby/object:Gem::Requirement