cmor_testimonials 0.0.8.pre → 0.0.9.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/cmor/testimonials/application/carousel.css +2 -2
- data/app/models/cmor/testimonials/category.rb +8 -1
- data/app/view_helpers/cmor/testimonials/application_view_helper.rb +7 -9
- data/app/views/cmor/testimonials/application_view_helper/_render_category.html.haml +8 -12
- data/config/locales/de.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/spec/view_helpers/cmor/testimonials/application_view_helper_spec.rb +28 -6
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 673d3c98117a279b7e256e92d00802174e2ba4a094cefaf7b260e62e344711e6
|
4
|
+
data.tar.gz: 718f7433d4a4a36d34c65b8e6a03e82b266e592f12c2fe49800c227d599a81ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47ccafd07ae19e4e8d5a7925637061a7d0de322c09e91ea755511e9610ed73a57bad1d8d275e5b11e30a2698923f1af5f539be20d53f706d4d751eda97f0608e
|
7
|
+
data.tar.gz: 32e0e61cb536bb2ba895c8fc8ce7df1ddf63ddb70332be4290fcb0c0aecdf7f3c99b6c63dd21f7fcb432797da75683026107eb0eec65328bdd345fef398305a5
|
@@ -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(
|
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
|
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
|
-
|
18
|
-
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
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')
|
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
@@ -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
|
-
|
13
|
-
|
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.
|
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-
|
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.
|
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.
|
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.
|
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.
|
55
|
+
version: 0.0.9.pre
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: sqlite3
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|