renuo-cms-rails 0.0.1
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 +7 -0
- data/.editorconfig +20 -0
- data/.gitignore +20 -0
- data/.reek +15 -0
- data/.rspec +2 -0
- data/.rubocop.yml +35 -0
- data/.travis.yml +24 -0
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +41 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +142 -0
- data/Rakefile +7 -0
- data/lib/railtie.rb +6 -0
- data/lib/renuo-cms-rails.rb +6 -0
- data/lib/renuo_cms_rails/cms_helper.rb +28 -0
- data/lib/renuo_cms_rails/configuration.rb +29 -0
- data/lib/renuo_cms_rails/version.rb +3 -0
- data/renuo_cms_rails.gemspec +34 -0
- data/spec/renuo_cms_rails/cms_helper_spec.rb +59 -0
- data/spec/renuo_cms_rails/configuration_spec.rb +50 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/mock_rails.rb +6 -0
- metadata +249 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 571fe61d519389bb5d1298f328c098e52fe04190
|
4
|
+
data.tar.gz: f73eeaf2938755b44ff9c95ad1bb417e46d11e2c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4cd5e8cde14679f38c7f6360c5930aff249ff5b8c4803a75cafd04b4854c26634b88cb8bb9302284fd08ca1106c8212e73453446a82bf26533fb9cd945ce1fc8
|
7
|
+
data.tar.gz: 9656b07f7bfc237c3772f341a4ed2373aa5d83da09ec6ca4d2fa5626cda8a923b2bd58b5362d53810e9a268aee44fef32f8f1996f6d9a8788838792ab75b433d
|
data/.editorconfig
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# EditorConfig helps developers define and maintain consistent
|
2
|
+
# coding styles between different editors and IDEs
|
3
|
+
# editorconfig.org
|
4
|
+
|
5
|
+
root = true
|
6
|
+
|
7
|
+
[*]
|
8
|
+
|
9
|
+
# Change these settings to your own preference
|
10
|
+
indent_style = space
|
11
|
+
indent_size = 2
|
12
|
+
|
13
|
+
# We recommend you to keep these unchanged
|
14
|
+
end_of_line = lf
|
15
|
+
charset = utf-8
|
16
|
+
trim_trailing_whitespace = true
|
17
|
+
insert_final_newline = true
|
18
|
+
|
19
|
+
[*.md]
|
20
|
+
trim_trailing_whitespace = false
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
.rbenv-gemsets
|
19
|
+
vendor/bundle/*
|
20
|
+
.ruby-version
|
data/.reek
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
Rails:
|
2
|
+
Enabled: true
|
3
|
+
|
4
|
+
Metrics/LineLength:
|
5
|
+
Max: 120
|
6
|
+
|
7
|
+
Style/Documentation:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Style/NonNilCheck:
|
11
|
+
IncludeSemanticChanges: true
|
12
|
+
|
13
|
+
Style/FileName:
|
14
|
+
Exclude:
|
15
|
+
- 'Gemfile.local.rb'
|
16
|
+
- 'Gemfile.local.example.rb'
|
17
|
+
|
18
|
+
Style/FrozenStringLiteralComment:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
AllCops:
|
22
|
+
TargetRubyVersion: 2.3
|
23
|
+
Include:
|
24
|
+
- '**/Rakefile'
|
25
|
+
- '**/config.ru'
|
26
|
+
Exclude:
|
27
|
+
- 'bin/**/*'
|
28
|
+
- 'script/**/*'
|
29
|
+
- 'log/**/*'
|
30
|
+
- 'public/**/*'
|
31
|
+
- 'tmp/**/*'
|
32
|
+
- 'config/unicorn.rb'
|
33
|
+
- 'db/**/*'
|
34
|
+
- 'vendor/bundle/**/*'
|
35
|
+
- 'lib/renuo-cms-rails.rb'
|
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.0
|
5
|
+
addons:
|
6
|
+
apt:
|
7
|
+
packages:
|
8
|
+
- zsh
|
9
|
+
bundler_args: --jobs=3 --retry=3
|
10
|
+
cache:
|
11
|
+
bundler: true
|
12
|
+
apt: true
|
13
|
+
directories:
|
14
|
+
- coverage
|
15
|
+
before_install:
|
16
|
+
- export TZ=Europe/Zurich
|
17
|
+
before_script:
|
18
|
+
- export DISPLAY=:99.0
|
19
|
+
- sh -e /etc/init.d/xvfb start
|
20
|
+
script: bin/setup
|
21
|
+
notifications:
|
22
|
+
email:
|
23
|
+
on_success: change
|
24
|
+
on_failure: always
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
### We love pull requests. Here's a quick guide.
|
4
|
+
|
5
|
+
Fork, then clone the repo:
|
6
|
+
```
|
7
|
+
git clone git@github.com:your-username/renuo-cms-rails.git
|
8
|
+
```
|
9
|
+
|
10
|
+
Set up your machine:
|
11
|
+
```
|
12
|
+
git checkout -b your-branch-name
|
13
|
+
bundle
|
14
|
+
```
|
15
|
+
|
16
|
+
Make sure the tests pass:
|
17
|
+
```
|
18
|
+
rake
|
19
|
+
```
|
20
|
+
|
21
|
+
Make your change. Add tests for your change. Make the tests pass:
|
22
|
+
```
|
23
|
+
rake
|
24
|
+
```
|
25
|
+
|
26
|
+
Push to your fork and [submit a pull request][pr].
|
27
|
+
```
|
28
|
+
git push origin your-branch-name
|
29
|
+
```
|
30
|
+
|
31
|
+
[pr]: https://github.com/renuo/renuo-cms-rails/compare/
|
32
|
+
|
33
|
+
At this point you're waiting on us. We like to at least comment on pull requests within three business days
|
34
|
+
(and, typically, one business day). We may suggest some changes or improvements or alternatives.
|
35
|
+
|
36
|
+
Some things that will increase the chance that your pull request is accepted:
|
37
|
+
|
38
|
+
* Write tests.
|
39
|
+
* Write a [good commit message][commit].
|
40
|
+
|
41
|
+
[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Renuo GmbH
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
[](https://badge.fury.io/rb/renuo-cms-rails) [](http://travis-ci.org/renuo/renuo-cms-rails)
|
2
|
+
|
3
|
+
# Renuo CMS Rails
|
4
|
+
|
5
|
+
Gem for Rails 4.1+ applications that use the excellent Renuo CMS.
|
6
|
+
|
7
|
+
* [Renuo CMS Documentation](https://renuo.gitbooks.io/renuo-cms-doc/content/index.html)
|
8
|
+
* [Renuo CMS Client](https://github.com/renuo/renuo-cms-client)
|
9
|
+
* [Renuo CMS API](https://github.com/renuo/renuo-cms-api)
|
10
|
+
|
11
|
+
So far it includes:
|
12
|
+
|
13
|
+
* A `cms` helper method that creates an editable CMS block.
|
14
|
+
|
15
|
+
#### Compatibility
|
16
|
+
|
17
|
+
* Only Rails 4.1+ is fully supported
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'renuo-cms-rails'
|
25
|
+
```
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
```sh
|
30
|
+
bundle
|
31
|
+
```
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
### CMS Helper
|
36
|
+
|
37
|
+
To use the built in cms helper, add `<%= cms(path) %>` block to where you wish to use it. Here are some examples:
|
38
|
+
|
39
|
+
This uses the title "Default Title" as default text:
|
40
|
+
|
41
|
+
```slim
|
42
|
+
h1 = cms('view.article.index.title', 'Default Title')
|
43
|
+
```
|
44
|
+
|
45
|
+
This uses the whole block below as default text:
|
46
|
+
|
47
|
+
```slim
|
48
|
+
= cms('view.article.index.intro-text')
|
49
|
+
h1
|
50
|
+
| A title
|
51
|
+
p
|
52
|
+
| Lorem ipsum dolor sit amet, ad facete comprehensam duo. Sit ei option nominati temporibus. Sea meis ancillae at,
|
53
|
+
qui everti intellegebat ei, ad vim diam brute aperiam. Modo commune accumsan ad per. Soleat verterem tacimates quo
|
54
|
+
ad, nostrum ullamcorper pri te, paulo eruditi placerat no vix.
|
55
|
+
p
|
56
|
+
| Dolores torquatos has in. Quod nullam interesset cum cu, vel ut dico fabulas, vis no ponderum delicata. Doctus
|
57
|
+
deserunt salutandi has ad, cum in illum splendide. Pri quas tantas cetero id, semper senserit sed id.
|
58
|
+
```
|
59
|
+
|
60
|
+
If you've already translated your app using I18n, the next block will help you. It uses
|
61
|
+
```I18n.t('view.article.index.title')``` as default text:
|
62
|
+
|
63
|
+
```slim
|
64
|
+
h1 = cms('view.article.index.title')
|
65
|
+
```
|
66
|
+
|
67
|
+
Of course, you can also use it like this, where the whole block is the default text:
|
68
|
+
|
69
|
+
```slim
|
70
|
+
= cms('view.article.index.intro-text')
|
71
|
+
h1 = t('.title')
|
72
|
+
p = t('.paragraph-1')
|
73
|
+
p = t('.paragraph-2')
|
74
|
+
```
|
75
|
+
|
76
|
+
## Configuration
|
77
|
+
|
78
|
+
The configuration is optional. If you want to use it, add an initializer file to your Rails app:
|
79
|
+
*config/initializers/renuo_cms_rails.rb* containing the following block:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
RenuoCmsRails.configure do |config|
|
83
|
+
# Default: ENV['RENUO_CMS_API_HOST']
|
84
|
+
config.api_host = 'custom.host'
|
85
|
+
# Default: ENV['RENUO_CMS_API_KEY']
|
86
|
+
config.api_key = 'custom-api-key'
|
87
|
+
# Default: ENV['RENUO_CMS_PRIVATE_API_KEY']
|
88
|
+
config.private_api_key = 'custom-private-api-key'
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
## Authorization
|
93
|
+
|
94
|
+
To implement the authorization, implement a method ```cms_admin?``` in your application helper. Example (with devise):
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
module ApplicationHelper
|
98
|
+
def cms_admin?
|
99
|
+
user_signed_in?
|
100
|
+
end
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
Another example:
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
module ApplicationHelper
|
108
|
+
def cms_admin?
|
109
|
+
user_signed_in? && current_user.admin?
|
110
|
+
end
|
111
|
+
end
|
112
|
+
```
|
113
|
+
|
114
|
+
Of course, you can also add an application controller method, and make it a helper_method. See
|
115
|
+
http://api.rubyonrails.org/classes/AbstractController/Helpers/ClassMethods.html#method-i-helper_method for details.
|
116
|
+
|
117
|
+
## Release
|
118
|
+
|
119
|
+
```sh
|
120
|
+
git flow release start [.....]
|
121
|
+
# adjust version.rb
|
122
|
+
bundle install
|
123
|
+
git commit -av
|
124
|
+
git flow release finish [.....]
|
125
|
+
git push origin develop:develop
|
126
|
+
git push origin master:master
|
127
|
+
git checkout master
|
128
|
+
bundle exec rake release
|
129
|
+
git checkout develop
|
130
|
+
```
|
131
|
+
|
132
|
+
## Contributing
|
133
|
+
|
134
|
+
See the [CONTRIBUTING](CONTRIBUTING.md) file.
|
135
|
+
|
136
|
+
## Special Thanks
|
137
|
+
|
138
|
+
Thanks https://github.com/sgruhier/foundation_rails_helper for the gem template.
|
139
|
+
|
140
|
+
## Copyright
|
141
|
+
|
142
|
+
Renuo GmbH (https://www.renuo.ch) - MIT LICENSE - 2016
|
data/Rakefile
ADDED
data/lib/railtie.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'action_view/helpers'
|
2
|
+
|
3
|
+
module RenuoCmsRails
|
4
|
+
module CmsHelper
|
5
|
+
def cms(path, default_value = nil, &block)
|
6
|
+
url_path = "#{path}-#{I18n.locale}"
|
7
|
+
default_translation = capture_default_value(path, default_value, &block)
|
8
|
+
content_tag(:div, default_translation, data: cms_attributes(url_path))
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# :reek:FeatureEnvy
|
14
|
+
def cms_attributes(url_path)
|
15
|
+
config = RenuoCmsRails.configuration
|
16
|
+
cms_attributes = { content_path: url_path, api_host: config.api_host, api_key: config.api_key }
|
17
|
+
cms_attributes[:private_api_key] = config.private_api_key if cms_admin?
|
18
|
+
cms_attributes
|
19
|
+
end
|
20
|
+
|
21
|
+
def capture_default_value(path, default_value)
|
22
|
+
return default_value if default_value
|
23
|
+
return capture { yield } if block_given?
|
24
|
+
|
25
|
+
I18n.t(path)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module RenuoCmsRails
|
2
|
+
class << self
|
3
|
+
attr_writer :configuration
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configuration
|
7
|
+
@configuration ||= Configuration.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.reset
|
11
|
+
@configuration = Configuration.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
yield(configuration)
|
16
|
+
end
|
17
|
+
|
18
|
+
class Configuration
|
19
|
+
attr_accessor :api_host
|
20
|
+
attr_accessor :api_key
|
21
|
+
attr_accessor :private_api_key
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
self.api_host = ENV['RENUO_CMS_API_HOST']
|
25
|
+
self.api_key = ENV['RENUO_CMS_API_KEY']
|
26
|
+
self.private_api_key = ENV['RENUO_CMS_PRIVATE_API_KEY']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'renuo_cms_rails/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'renuo-cms-rails'
|
7
|
+
spec.version = RenuoCmsRails::VERSION
|
8
|
+
spec.authors = ['Lukas Elmer']
|
9
|
+
spec.email = ['lukas.elmer@renuo.ch']
|
10
|
+
|
11
|
+
spec.summary = 'Rails helpers for the renuo-cms'
|
12
|
+
spec.description = 'The Renuo CLI automates some commonly used workflows by providing a command line interface.'
|
13
|
+
spec.homepage = 'https://github.com/renuo/renuo-cms-rails'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bin)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
|
22
|
+
spec.add_dependency 'railties', '~> 4.1'
|
23
|
+
spec.add_dependency 'actionpack', '~> 4.1'
|
24
|
+
spec.add_dependency 'activemodel', '~> 4.1'
|
25
|
+
spec.add_dependency 'activesupport', '~> 4.1'
|
26
|
+
spec.add_dependency 'tzinfo', '~> 1.2', '>= 1.2.2'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'rspec-rails', '~> 3.1', '>= 3.1.0'
|
29
|
+
spec.add_development_dependency 'mime-types', '~> 2'
|
30
|
+
spec.add_development_dependency 'capybara', '~> 2.4', '>= 2.4.3'
|
31
|
+
spec.add_development_dependency 'climate_control', '~> 0', '>= 0.0.3'
|
32
|
+
spec.add_development_dependency 'rubocop'
|
33
|
+
spec.add_development_dependency 'reek'
|
34
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RenuoCmsRails::CmsHelper do
|
4
|
+
include RenuoCmsRails::CmsHelper
|
5
|
+
include ActionView::Helpers::TagHelper
|
6
|
+
include RenuoCmsRailsSpecHelper
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
RenuoCmsRails.configuration.api_host = 'some.host'
|
10
|
+
RenuoCmsRails.configuration.api_key = 'apikey'
|
11
|
+
RenuoCmsRails.configuration.private_api_key = 'pk'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'sets the correct attributes for the public view' do
|
15
|
+
allow(self).to receive(:cms_admin?).and_return(false)
|
16
|
+
|
17
|
+
node = Capybara.string cms('some.content', 'Some CMS content')
|
18
|
+
expect(node).to have_css('div', text: 'Some CMS content')
|
19
|
+
expect(node).to have_css("div[data-content-path='some.content-en']")
|
20
|
+
expect(node).to have_css("div[data-api-host='some.host']")
|
21
|
+
expect(node).to have_css("div[data-api-key='apikey']")
|
22
|
+
expect(node).not_to have_css('div[data-private-api-key]')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'sets the correct attributes for the admin view' do
|
26
|
+
allow(self).to receive(:cms_admin?).and_return(true)
|
27
|
+
|
28
|
+
node = Capybara.string cms('some.content', 'Some CMS content')
|
29
|
+
expect(node).to have_css('div', text: 'Some CMS content')
|
30
|
+
expect(node).to have_css("div[data-content-path='some.content-en']")
|
31
|
+
expect(node).to have_css("div[data-api-host='some.host']")
|
32
|
+
expect(node).to have_css("div[data-api-key='apikey']")
|
33
|
+
expect(node).to have_css("div[data-private-api-key='pk']")
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'captures a block' do
|
37
|
+
allow(self).to receive(:cms_admin?).and_return(false)
|
38
|
+
|
39
|
+
node = Capybara.string cms('some.content') { content_tag('p', 'Block content!') }
|
40
|
+
expect(node).not_to have_css('div', text: 'Some CMS content')
|
41
|
+
expect(node).to have_css('div p', text: 'Block content!')
|
42
|
+
expect(node).to have_css("div[data-content-path='some.content-en']")
|
43
|
+
expect(node).to have_css("div[data-api-host='some.host']")
|
44
|
+
expect(node).to have_css("div[data-api-key='apikey']")
|
45
|
+
expect(node).not_to have_css('div[data-private-api-key]')
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'translates a key as content' do
|
49
|
+
allow(self).to receive(:cms_admin?).and_return(false)
|
50
|
+
|
51
|
+
I18n.backend.store_translations :en, some: { content: 'I18n.t content!' }
|
52
|
+
node = Capybara.string cms('some.content')
|
53
|
+
expect(node).to have_css('div', text: 'I18n.t content!')
|
54
|
+
expect(node).to have_css("div[data-content-path='some.content-en']")
|
55
|
+
expect(node).to have_css("div[data-api-host='some.host']")
|
56
|
+
expect(node).to have_css("div[data-api-key='apikey']")
|
57
|
+
expect(node).not_to have_css('div[data-private-api-key]')
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RenuoCmsRails do
|
4
|
+
describe RenuoCmsRails::Configuration do
|
5
|
+
[
|
6
|
+
[:RENUO_CMS_API_HOST, :api_host, 'custom.host', 'new.host'],
|
7
|
+
[:RENUO_CMS_API_KEY, :api_key, 'custom-api-key', 'new-key'],
|
8
|
+
[:RENUO_CMS_PRIVATE_API_KEY, :private_api_key, 'custom-private-api-key', 'new-pk']
|
9
|
+
].each do |env_variable_name, method, default_value, new_value|
|
10
|
+
describe "##{method}" do
|
11
|
+
it 'is the default value from the ENV variable' do
|
12
|
+
ClimateControl.modify env_variable_name => default_value do
|
13
|
+
config = RenuoCmsRails::Configuration.new
|
14
|
+
expect(config.send(method)).to eq(default_value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "##{method}=" do
|
20
|
+
it 'can set value without an env variable' do
|
21
|
+
config = RenuoCmsRails::Configuration.new
|
22
|
+
config.send("#{method}=", new_value)
|
23
|
+
expect(config.send(method)).to eq(new_value)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'can set value when an env variable is defined' do
|
27
|
+
ClimateControl.modify env_variable_name => default_value do
|
28
|
+
config = RenuoCmsRails::Configuration.new
|
29
|
+
config.send("#{method}=", new_value)
|
30
|
+
expect(config.send(method)).to eq(new_value)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#reset (#{method})" do
|
36
|
+
it "resets the #{method}" do
|
37
|
+
ClimateControl.modify env_variable_name => default_value do
|
38
|
+
RenuoCmsRails.configure do |config|
|
39
|
+
config.send("#{method}=", new_value)
|
40
|
+
end
|
41
|
+
|
42
|
+
expect(RenuoCmsRails.configuration.send(method)).to eq(new_value)
|
43
|
+
RenuoCmsRails.reset
|
44
|
+
expect(RenuoCmsRails.configuration.send(method)).to eq(default_value)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,249 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: renuo-cms-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lukas Elmer
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actionpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activemodel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tzinfo
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.2.2
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.2'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.2.2
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rspec-rails
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '3.1'
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 3.1.0
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '3.1'
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 3.1.0
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: mime-types
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '2'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '2'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: capybara
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '2.4'
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 2.4.3
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '2.4'
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 2.4.3
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
name: climate_control
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - "~>"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.0.3
|
153
|
+
type: :development
|
154
|
+
prerelease: false
|
155
|
+
version_requirements: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 0.0.3
|
163
|
+
- !ruby/object:Gem::Dependency
|
164
|
+
name: rubocop
|
165
|
+
requirement: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
type: :development
|
171
|
+
prerelease: false
|
172
|
+
version_requirements: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
- !ruby/object:Gem::Dependency
|
178
|
+
name: reek
|
179
|
+
requirement: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
type: :development
|
185
|
+
prerelease: false
|
186
|
+
version_requirements: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
description: The Renuo CLI automates some commonly used workflows by providing a command
|
192
|
+
line interface.
|
193
|
+
email:
|
194
|
+
- lukas.elmer@renuo.ch
|
195
|
+
executables: []
|
196
|
+
extensions: []
|
197
|
+
extra_rdoc_files: []
|
198
|
+
files:
|
199
|
+
- ".editorconfig"
|
200
|
+
- ".gitignore"
|
201
|
+
- ".reek"
|
202
|
+
- ".rspec"
|
203
|
+
- ".rubocop.yml"
|
204
|
+
- ".travis.yml"
|
205
|
+
- CHANGELOG.md
|
206
|
+
- CONTRIBUTING.md
|
207
|
+
- Gemfile
|
208
|
+
- LICENSE
|
209
|
+
- README.md
|
210
|
+
- Rakefile
|
211
|
+
- lib/railtie.rb
|
212
|
+
- lib/renuo-cms-rails.rb
|
213
|
+
- lib/renuo_cms_rails/cms_helper.rb
|
214
|
+
- lib/renuo_cms_rails/configuration.rb
|
215
|
+
- lib/renuo_cms_rails/version.rb
|
216
|
+
- renuo_cms_rails.gemspec
|
217
|
+
- spec/renuo_cms_rails/cms_helper_spec.rb
|
218
|
+
- spec/renuo_cms_rails/configuration_spec.rb
|
219
|
+
- spec/spec_helper.rb
|
220
|
+
- spec/support/mock_rails.rb
|
221
|
+
homepage: https://github.com/renuo/renuo-cms-rails
|
222
|
+
licenses:
|
223
|
+
- MIT
|
224
|
+
metadata: {}
|
225
|
+
post_install_message:
|
226
|
+
rdoc_options: []
|
227
|
+
require_paths:
|
228
|
+
- lib
|
229
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
230
|
+
requirements:
|
231
|
+
- - ">="
|
232
|
+
- !ruby/object:Gem::Version
|
233
|
+
version: '0'
|
234
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
|
+
requirements:
|
236
|
+
- - ">="
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: '0'
|
239
|
+
requirements: []
|
240
|
+
rubyforge_project:
|
241
|
+
rubygems_version: 2.5.1
|
242
|
+
signing_key:
|
243
|
+
specification_version: 4
|
244
|
+
summary: Rails helpers for the renuo-cms
|
245
|
+
test_files:
|
246
|
+
- spec/renuo_cms_rails/cms_helper_spec.rb
|
247
|
+
- spec/renuo_cms_rails/configuration_spec.rb
|
248
|
+
- spec/spec_helper.rb
|
249
|
+
- spec/support/mock_rails.rb
|