refinerycms-settings 2.1.1 → 3.0.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: dff237e551123dee6e9c3ced6281227539cb2614
4
- data.tar.gz: 100702ad1e1e8b554e38443d0f9ea71fb75ec305
3
+ metadata.gz: b996c2cc75a4f725c2cf6d70ed67ac7277a93e6c
4
+ data.tar.gz: b5d5585e04ca065315c798127b9c793435d714bd
5
5
  SHA512:
6
- metadata.gz: aa0f73f3b5d6783ffbc52643518f82adebb2c62d23b53fa729b119441e71bd5aa7d4b601d09626ca09b3620dc05a3c076a5586e202f31c30d36850565d84470c
7
- data.tar.gz: a3adac76e534b6e5278a0831a6b793da87a29c69f1c6e01575cd096b2b676f179f4d93099ed4ae41844d601deca4a430a847b5edbf05dc7e9159d60bfab133d8
6
+ metadata.gz: 8edc77367390f65772d45052b61d392d4cc37da5670e3a518ddbcf9269d95924a143e9e62f31bc38af2226e8cc3868723a115a897a3b8d3a902d505c5f8d8715
7
+ data.tar.gz: 910e7b789dacd9b04c879a0d46e317ac544248c7c088356bb28ad51fb1c8bdeade407b8b0cfe851e1511f46e3aa26b70b132d5904d8e000ce4fae6141ca35536
data/.travis.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  language: ruby
2
2
  bundler_args: --without development
3
+ cache:
4
+ - bundler: true
5
+ sudo: false
3
6
  before_script:
4
7
  - "sh -e /etc/init.d/xvfb start"
5
8
  - "bundle exec rake refinery:testing:dummy_app"
@@ -20,11 +23,7 @@ notifications:
20
23
  env:
21
24
  - DB=postgresql
22
25
  - DB=mysql
23
- matrix:
24
- allow_failures:
25
- - rvm: rbx-19mode
26
26
  rvm:
27
+ - 2.2
28
+ - 2.1
27
29
  - 2.0.0
28
- - 1.9.3
29
- - rbx-19mode
30
- - jruby-19mode
data/Gemfile CHANGED
@@ -2,35 +2,37 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'refinerycms', '~> 2.1.1'
6
- gem 'refinerycms-testing', '~> 2.1.1', :group => :test
7
- gem 'refinerycms-acts-as-indexed', '~> 1.0.0'
5
+ gem 'refinerycms', github: 'refinery/refinerycms'
6
+ gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n'
7
+ gem 'refinerycms-acts-as-indexed', github: 'refinery/refinerycms-acts-as-indexed'
8
+ gem "mime-types", "~> 1.25"
9
+
10
+ group :test do
11
+ gem 'refinerycms-testing', github: 'refinery/refinerycms'
12
+ gem 'poltergeist'
13
+ gem 'capybara-email', '~> 2.4'
14
+ end
8
15
 
9
16
  # Database Configuration
10
17
  unless ENV['TRAVIS']
11
- gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
12
- gem 'sqlite3', :platform => :ruby
18
+ gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
19
+ gem 'sqlite3', platform: :ruby
13
20
  end
14
21
 
15
22
  if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
16
- gem 'activerecord-jdbcmysql-adapter', :platform => :jruby
17
- gem 'jdbc-mysql', '= 5.1.13', :platform => :jruby
18
- gem 'mysql2', :platform => :ruby
23
+ gem 'activerecord-jdbcmysql-adapter', platform: :jruby
24
+ gem 'jdbc-mysql', '= 5.1.13', platform: :jruby
25
+ gem 'mysql2', platform: :ruby
19
26
  end
20
27
 
21
28
  if !ENV['TRAVIS'] || ENV['DB'] == 'postgresql'
22
- gem 'activerecord-jdbcpostgresql-adapter', :platform => :jruby
23
- gem 'pg', :platform => :ruby
29
+ gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby
30
+ gem 'pg', platform: :ruby
24
31
  end
25
32
 
26
- gem 'jruby-openssl', :platform => :jruby
27
-
28
33
  # Refinery/rails should pull in the proper versions of these
29
- group :assets do
30
- gem 'sass-rails'
31
- gem 'coffee-rails'
32
- gem 'uglifier'
33
- end
34
+ gem 'sass-rails', '~> 4.0.0'
35
+ gem 'coffee-rails', '~> 4.0.0'
34
36
 
35
37
  # Load local gems according to Refinery developer preference.
36
38
  if File.exist? local_gemfile = File.expand_path('../.gemfile', __FILE__)
data/Rakefile CHANGED
@@ -13,8 +13,7 @@ if File.exists?(APP_RAKEFILE)
13
13
  end
14
14
 
15
15
  require "refinerycms-testing"
16
- Refinery::Testing::Railtie.load_tasks
17
- Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
16
+ Refinery::Testing::Railtie.load_dummy_tasks File.dirname(__FILE__)
18
17
 
19
18
  load File.expand_path('../tasks/rspec.rake', __FILE__)
20
19
 
@@ -6,8 +6,7 @@ module ::Refinery
6
6
 
7
7
  crudify :'refinery/setting',
8
8
  :order => "name ASC",
9
- :redirect_to_url => :redirect_to_where?,
10
- :xhr_paging => true
9
+ :redirect_to_url => :redirect_to_where?
11
10
 
12
11
  before_filter :sanitise_params, :only => [:create, :update]
13
12
 
@@ -50,6 +49,12 @@ module ::Refinery
50
49
  def sanitise_params
51
50
  params.delete(:scoping)
52
51
  end
52
+
53
+ def setting_params
54
+ params.require(:setting).permit(:title, :name, :value, :destroyable,
55
+ :scoping, :restricted, :form_value_type)
56
+ end
57
+
53
58
  end
54
59
  end
55
60
  end
@@ -1,7 +1,15 @@
1
+ require 'friendly_id'
2
+
1
3
  module Refinery
2
4
  class Setting < Refinery::Core::BaseModel
3
5
  extend FriendlyId
4
- friendly_id :name, :use => :slugged
6
+
7
+ friendly_id :name, use: [:slugged, :finders]
8
+
9
+ # If name changes tell friendly_id to regenerate slug when saving record
10
+ def should_generate_new_friendly_id?
11
+ name_changed?
12
+ end
5
13
 
6
14
  FORM_VALUE_TYPES = [
7
15
  ['Multi-line', 'text_area'],
@@ -12,93 +20,30 @@ module Refinery
12
20
 
13
21
  serialize :value # stores into YAML format
14
22
 
15
- attr_accessible :name, :value, :destroyable,
16
- :scoping, :restricted, :form_value_type
17
-
18
23
  before_save do |setting|
19
24
  setting.restricted = false if setting.restricted.nil?
20
25
  end
21
26
 
22
- after_save do |setting|
23
- setting.class.rewrite_cache
24
- end
25
-
26
- after_destroy do |setting|
27
- setting.class.rewrite_cache
28
- end
29
-
30
27
  class << self
31
28
  # Number of settings to show per page when using will_paginate
32
29
  def per_page
33
30
  12
34
31
  end
35
32
 
36
- def ensure_cache_exists!
37
- if (result = Rails.cache.read(cache_key, :multithread => true)).nil?
38
- result = rewrite_cache
39
- end
40
-
41
- result
42
- end
43
- protected :ensure_cache_exists!
44
-
45
- def cache_read(name = nil, scoping = nil)
46
- result = ensure_cache_exists!
47
-
48
- if name.present?
49
- scoping = scoping.to_s if scoping.is_a?(Symbol)
50
- result = result.detect do |rs|
51
- rs[:name] == name.to_s.downcase.to_sym and rs[:scoping] == scoping
52
- end
53
- result = result[:value] if !result.nil? and result.keys.include?(:value)
54
- end
55
-
56
- result
57
- end
58
-
59
- def to_cache(settings)
60
- settings.collect do |rs|
61
- {
62
- :name => rs.name.to_s.downcase.to_sym,
63
- :value => rs.value,
64
- :scoping => rs.scoping,
65
- :destroyable => rs.destroyable
66
- }
67
- end
68
- end
69
-
70
- def rewrite_cache
71
- # delete cache
72
- Rails.cache.delete(cache_key, :multithread => true)
73
-
74
- # generate new cache
75
- result = (to_cache(all) if (table_exists? rescue false))
76
-
77
- # write cache
78
- Rails.cache.write(cache_key, result, :multithread => true)
79
-
80
- # return cache, or lack thereof.
81
- result ||= []
82
- end
83
-
84
- def cache_key
85
- [Refinery::Core.base_cache_key, 'settings_cache'].join('_')
86
- end
87
-
88
33
  # find_or_set offers a convenient way to
89
34
  def find_or_set(name, the_value, options={})
90
35
  # Merge default options with supplied options.
91
36
  options = {
92
- :scoping => nil,
93
- :restricted => false,
94
- :form_value_type => 'text_area'
37
+ scoping: nil,
38
+ restricted: false,
39
+ form_value_type: 'text_area'
95
40
  }.merge(options)
96
41
 
97
42
  # try to find the setting first
98
- value = get(name, :scoping => options[:scoping])
43
+ value = get(name, scoping: options[:scoping])
99
44
 
100
45
  # if the setting's value is nil, store a new one using the existing functionality.
101
- value = set(name, options.merge({:value => the_value})) if value.nil?
46
+ value = set(name, options.merge(value: the_value)) if value.nil?
102
47
 
103
48
  # Return what we found.
104
49
  value
@@ -108,8 +53,9 @@ module Refinery
108
53
 
109
54
  # Retrieve the current value for the setting whose name is supplied.
110
55
  def get(name, options = {})
111
- options = {:scoping => nil}.update(options)
112
- cache_read(name, options[:scoping])
56
+ options = {scoping: nil}.update(options)
57
+ where(name: name, scoping: options[:scoping])
58
+ .select(:value).map(&:value).first
113
59
  end
114
60
 
115
61
  alias :[] :get
@@ -118,7 +64,7 @@ module Refinery
118
64
  return (value.is_a?(Hash) ? value[:value] : value) unless (table_exists? rescue false)
119
65
 
120
66
  scoping = (value[:scoping] if value.is_a?(Hash) and value.has_key?(:scoping))
121
- setting = find_or_initialize_by_name_and_scoping(name.to_s, scoping)
67
+ setting = where(name: name.to_s, scoping: scoping).first_or_initialize
122
68
 
123
69
  # you could also pass in {:value => 'something', :scoping => 'somewhere'}
124
70
  unless value.is_a?(Hash) and value.has_key?(:value)
@@ -139,12 +85,8 @@ module Refinery
139
85
  end
140
86
  end
141
87
 
142
- # prettier version of the name.
143
- # site_name becomes Site Name
144
88
  def title
145
- result = name.to_s.titleize
146
- result << " (#{scoping.titleize})" if scoping.is_a?(String)
147
- result
89
+ self[:title].presence || auto_title
148
90
  end
149
91
 
150
92
  # form_value is so that on the web interface we can display a sane value.
@@ -162,14 +104,12 @@ module Refinery
162
104
 
163
105
  def value=(new_value)
164
106
  # must convert "1" to true and "0" to false when supplied using 'check_box', unfortunately.
165
- if ["1", "0"].include?(new_value) and form_value_type == 'check_box'
166
- new_value = new_value == "1" ? true : false
107
+ if %w[1 0].include?(new_value) && form_value_type == 'check_box'
108
+ new_value = new_value == "1"
167
109
  end
168
110
 
169
111
  # must convert to string if true or false supplied otherwise it becomes 0 or 1, unfortunately.
170
- if [true, false].include?(new_value)
171
- new_value = new_value.to_s
172
- end
112
+ new_value = new_value.to_s if [true, false].include?(new_value)
173
113
 
174
114
  super
175
115
  end
@@ -201,5 +141,13 @@ module Refinery
201
141
  current_value
202
142
  end
203
143
 
144
+ # prettier version of the name.
145
+ # site_name becomes Site Name
146
+ def auto_title
147
+ result = name.to_s.titleize
148
+ result << " (#{scoping.titleize})" if scoping.is_a?(String)
149
+ result
150
+ end
151
+
204
152
  end
205
153
  end
@@ -2,15 +2,14 @@
2
2
 
3
3
  <%= render '/refinery/admin/error_messages', :object => @setting, :include_object_name => true %>
4
4
 
5
- <div class='field'>
6
- <%= f.label :name %>
5
+ <div class='field'>
7
6
  <% if action_name =~ /(new)|(create)/ %>
7
+ <%= f.label :name %>
8
8
  <%= f.text_field :name, :class => "larger widest" %>
9
9
  <% else %>
10
- <label class='stripped' for='setting_value'>
11
- <%= @setting.title %>
12
- </label>
13
- <span class="preview">- (<%= @setting.name %>)</span>
10
+ <%= f.label :title %>
11
+ <%= f.text_field :title, :value => @setting.title, :class => "larger widest" %>
12
+ <span class="preview">(<%= @setting.name %>)</span>
14
13
  <% end %>
15
14
  <% if current_refinery_user.has_role?(:superuser) && @setting.new_record? %>
16
15
  <div class='field'>
@@ -12,7 +12,7 @@ de:
12
12
  new: Neue Einstellung erstellen
13
13
  records:
14
14
  empty_set: Es gibt noch keine Einstellungen.
15
- create_first: Klicken Sie auf '%{link}', um Ihre erste Einstellung anzulegen.
15
+ create_first: "Klicken Sie auf '%{link}', um Ihre erste Einstellung anzulegen."
16
16
  form:
17
17
  enabled: "Ja, die Einstellung aktivieren."
18
18
  restart_may_be_in_order_html: "<strong>Bitte beachten Sie</strong>, dass Sie Ihre Website eventuell neu starten müssen, damit die Einstellungen angewendet werden."
@@ -23,8 +23,7 @@ de:
23
23
  models:
24
24
  refinery/setting: Einstellungen
25
25
  attributes:
26
- refinery:
27
- setting:
28
- name: Name
29
- value: Wert
30
- restricted: Eingeschränkt
26
+ refinery/setting:
27
+ name: Name
28
+ value: Wert
29
+ restricted: Eingeschränkt
@@ -24,6 +24,7 @@ en:
24
24
  refinery/setting: setting
25
25
  attributes:
26
26
  refinery/setting:
27
+ title: Title
27
28
  name: Name
28
29
  value: Value
29
30
  restricted: Restricted
@@ -19,7 +19,6 @@ ja:
19
19
  yes_make_this_setting_restricted: "管理人のみ閲覧可能にする。"
20
20
  help:
21
21
  restricted: 管理人のみが変更出来るようにします。
22
- activity_show_limit: ダッシュボードで表示されるアイテムの数を制限します。
23
22
  activerecord:
24
23
  models:
25
24
  refinery/setting: 設定
@@ -0,0 +1,5 @@
1
+ class AddTitleToRefinerySettings < ActiveRecord::Migration
2
+ def change
3
+ add_column :refinery_settings, :title, :string
4
+ end
5
+ end
@@ -3,12 +3,11 @@
3
3
  Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.name = %q{refinerycms-settings}
6
- s.version = %q{2.1.1}
6
+ s.version = %q{3.0.0}
7
7
  s.summary = %q{Settings engine for Refinery CMS}
8
8
  s.description = %q{Adds programmer creatable, user editable settings.}
9
9
  s.email = %q{info@refinerycms.com}
10
10
  s.homepage = %q{http://refinerycms.com}
11
- s.rubyforge_project = %q{refinerycms}
12
11
  s.authors = ['Philip Arndt', 'Uģis Ozols']
13
12
  s.license = %q{MIT}
14
13
  s.require_paths = %w(lib)
@@ -16,5 +15,6 @@ Gem::Specification.new do |s|
16
15
  s.files = `git ls-files`.split("\n")
17
16
  s.test_files = `git ls-files -- spec/*`.split("\n")
18
17
 
19
- s.add_dependency 'refinerycms-core', '~> 2.1.1'
18
+ s.add_dependency 'refinerycms-core', ['~> 3.0', '>= 3.0.0']
19
+ s.add_dependency 'friendly_id', ['~> 5.0', '>= 5.0.1']
20
20
  end
@@ -2,19 +2,19 @@ require "spec_helper"
2
2
 
3
3
  module Refinery
4
4
  module Admin
5
- describe "Settings" do
5
+ describe "Settings", :type => :feature do
6
6
  refinery_login_with :refinery_user
7
7
 
8
8
  context "when interface config is enabled" do
9
9
  before do
10
- Refinery::Settings.stub(:enable_interface).and_return(true)
10
+ allow(Refinery::Settings).to receive(:enable_interface).and_return(true)
11
11
  end
12
12
 
13
13
  it "shows up in menu" do
14
14
  visit refinery.admin_root_path
15
15
 
16
16
  within('nav') do
17
- page.should have_content "Settings"
17
+ expect(page).to have_content "Settings"
18
18
  end
19
19
  end
20
20
 
@@ -23,14 +23,14 @@ module Refinery
23
23
 
24
24
  it "invites to create one" do
25
25
  visit refinery.admin_settings_path
26
- page.should have_content("There are no settings yet. Click 'Add new setting' to add your first setting.")
26
+ expect(page).to have_content("There are no settings yet. Click 'Add new setting' to add your first setting.")
27
27
  end
28
28
  end
29
29
 
30
30
  it "shows add new setting link" do
31
31
  visit refinery.admin_settings_path
32
- page.should have_content("Add new setting")
33
- page.should have_selector("a[href*='/refinery/settings/new']")
32
+ expect(page).to have_content("Add new setting")
33
+ expect(page).to have_selector("a[href*='/refinery/settings/new']")
34
34
  end
35
35
 
36
36
  context "new/create" do
@@ -38,7 +38,7 @@ module Refinery
38
38
  visit refinery.admin_settings_path
39
39
  click_link "Add new setting"
40
40
 
41
- page.should have_selector('iframe#dialog_iframe')
41
+ expect(page).to have_selector('iframe#dialog_iframe')
42
42
 
43
43
  page.within_frame('dialog_iframe') do
44
44
  fill_in "setting_name", :with => "test setting"
@@ -46,16 +46,16 @@ module Refinery
46
46
 
47
47
  click_button "submit_button"
48
48
  end
49
-
50
- page.should have_content("'Test Setting' was successfully added.")
51
- page.should have_content("Test Setting - true")
49
+ expect(page).not_to have_css("#dialog_iframe")
50
+ expect(page).to have_content("'Test Setting' was successfully added.")
51
+ expect(page).to have_content("Test Setting - true")
52
52
  end
53
53
 
54
54
  it "adds setting with slug unfriendly name", :js => true do
55
55
  visit refinery.admin_settings_path
56
56
  click_link "Add new setting"
57
57
 
58
- page.should have_selector('iframe#dialog_iframe')
58
+ expect(page).to have_selector('iframe#dialog_iframe')
59
59
 
60
60
  page.within_frame('dialog_iframe') do
61
61
  fill_in "setting_name", :with => "Test/Setting"
@@ -64,11 +64,34 @@ module Refinery
64
64
  click_button "submit_button"
65
65
  end
66
66
 
67
- page.should have_content("'Test/Setting' was successfully added.")
68
- page.should have_content("Test/Setting - true")
67
+ expect(page).to have_content("'Test/Setting' was successfully added.")
68
+ expect(page).to have_content("Test/Setting - true")
69
69
 
70
70
  visit refinery.edit_admin_setting_path(Refinery::Setting.last)
71
- page.should_not have_content('NoMethodError in Refinery::Admin::BaseController#error_404')
71
+ expect(page).not_to have_content('NoMethodError in Refinery::Admin::BaseController#error_404')
72
+ end
73
+ end
74
+
75
+ context "edit/update" do
76
+ before(:each) {::Refinery::Setting.set(:rspec_testing_edit_and_update, 1)}
77
+
78
+ it "modifies setting", :js => true do
79
+ visit refinery.admin_settings_path
80
+ find("a[href*='/refinery/settings/rspec_testing_edit_and_update/edit']").click
81
+
82
+ expect(page).to have_selector('iframe#dialog_iframe')
83
+ page.within_frame('dialog_iframe') do
84
+
85
+ expect(find_field('Title').value).to eql("Rspec Testing Edit And Update")
86
+
87
+ fill_in "Title", :with => "Edit and Update Title"
88
+ fill_in "Value", :with => "2"
89
+
90
+ click_button "Save"
91
+ end
92
+
93
+ expect(page).to have_content("'Edit and Update Title' was successfully updated.")
94
+ expect(page).to have_content("Edit and Update Title - 2")
72
95
  end
73
96
  end
74
97
 
@@ -82,14 +105,14 @@ module Refinery
82
105
  specify "page links" do
83
106
  visit refinery.admin_settings_path
84
107
 
85
- page.should have_selector("a[href*='settings?page=2']")
108
+ expect(page).to have_selector("a[href*='settings?page=2']")
86
109
  end
87
110
  end
88
111
  end
89
112
 
90
113
  context "when interface config is disabled" do
91
114
  before do
92
- Refinery::Settings.stub(:enable_interface).and_return(false)
115
+ allow(Refinery::Settings).to receive(:enable_interface).and_return(false)
93
116
  Refinery::Plugins.registered.find_by_name("refinery_settings").hide_from_menu = true
94
117
  end
95
118
 
@@ -97,7 +120,7 @@ module Refinery
97
120
  visit refinery.admin_root_path
98
121
 
99
122
  within('nav') do
100
- page.should_not have_content "Settings"
123
+ expect(page).not_to have_content "Settings"
101
124
  end
102
125
  end
103
126
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Refinery
4
- describe Setting do
4
+ describe Setting, :type => :model do
5
5
 
6
6
  before do
7
7
  ::Refinery::Setting.set(:creating_from_scratch, nil)
@@ -11,7 +11,7 @@ module Refinery
11
11
  context "slug" do
12
12
  it "should create correct slug" do
13
13
  ::Refinery::Setting.set('test/something', {:value => "Look, a value"})
14
- ::Refinery::Setting.last.to_param.should eq('test-something')
14
+ expect(::Refinery::Setting.last.to_param).to eq('test-something')
15
15
  end
16
16
  end
17
17
 
@@ -19,81 +19,81 @@ module Refinery
19
19
  it "should save and get @keram" do
20
20
  ::Refinery::Setting.find_or_set(:twitter, '@keram')
21
21
  setting = ::Refinery::Setting.last
22
- setting.value.should eq('@keram')
22
+ expect(setting.value).to eq('@keram')
23
23
  end
24
24
 
25
25
  it "should not strip whitespaces" do
26
26
  ::Refinery::Setting.find_or_set(:author, ' benbruscella ')
27
27
  setting = ::Refinery::Setting.last
28
- setting.value.should eq(' benbruscella ')
28
+ expect(setting.value).to eq(' benbruscella ')
29
29
  end
30
30
 
31
31
  it "should create a setting that didn't exist" do
32
- ::Refinery::Setting.get(:creating_from_scratch, :scoping => 'rspec_testing').should eq(nil)
33
- ::Refinery::Setting.set(:creating_from_scratch, {:value => "Look, a value", :scoping => 'rspec_testing'}).should eq("Look, a value")
32
+ expect(::Refinery::Setting.get(:creating_from_scratch, :scoping => 'rspec_testing')).to eq(nil)
33
+ expect(::Refinery::Setting.set(:creating_from_scratch, {:value => "Look, a value", :scoping => 'rspec_testing'})).to eq("Look, a value")
34
34
  end
35
35
 
36
36
  it "should override an existing setting" do
37
37
  set = ::Refinery::Setting.set(:creating_from_scratch, {:value => "a value", :scoping => 'rspec_testing'})
38
- set.should eq("a value")
38
+ expect(set).to eq("a value")
39
39
 
40
40
  new_set = ::Refinery::Setting.set(:creating_from_scratch, {:value => "newer replaced value", :scoping => 'rspec_testing'})
41
- new_set.should eq("newer replaced value")
41
+ expect(new_set).to eq("newer replaced value")
42
42
  end
43
43
 
44
44
  it "should default to form_value_type text_area" do
45
45
  set = ::Refinery::Setting.set(:creating_from_scratch, {:value => "a value", :scoping => 'rspec_testing'})
46
- ::Refinery::Setting.find_by_name(:creating_from_scratch.to_s, :conditions => {:scoping => 'rspec_testing'}).form_value_type.should eq("text_area")
46
+ expect(::Refinery::Setting.find_by(:name => 'creating_from_scratch', :scoping => 'rspec_testing').form_value_type).to eq("text_area")
47
47
  end
48
48
 
49
49
  it "should fix true as a value to 'true' (string)" do
50
50
  set = ::Refinery::Setting.set(:creating_from_scratch, {:value => true, :scoping => 'rspec_testing'})
51
- ::Refinery::Setting.find_by_name(:creating_from_scratch.to_s, :conditions => {:scoping => 'rspec_testing'})[:value].should eq('true')
52
- set.should eq(true)
51
+ expect(::Refinery::Setting.find_by(:name => 'creating_from_scratch', :scoping => 'rspec_testing')[:value]).to eq('true')
52
+ expect(set).to eq(true)
53
53
  end
54
54
 
55
55
  it "should fix false as a value to 'false' (string)" do
56
56
  set = ::Refinery::Setting.set(:creating_from_scratch, {:value => false, :scoping => 'rspec_testing'})
57
- ::Refinery::Setting.find_by_name(:creating_from_scratch.to_s, :conditions => {:scoping => 'rspec_testing'})[:value].should eq('false')
58
- set.should eq(false)
57
+ expect(::Refinery::Setting.find_by(:name => 'creating_from_scratch', :scoping => 'rspec_testing')[:value]).to eq('false')
58
+ expect(set).to eq(false)
59
59
  end
60
60
 
61
61
  it "should fix '1' as a value with a check_box form_value_type to true" do
62
62
  set = ::Refinery::Setting.set(:creating_from_scratch, {:value => "1", :scoping => 'rspec_testing', :form_value_type => 'check_box'})
63
- ::Refinery::Setting.find_by_name(:creating_from_scratch.to_s, :conditions => {:scoping => 'rspec_testing'})[:value].should eq('true')
64
- set.should eq(true)
63
+ expect(::Refinery::Setting.find_by(:name => 'creating_from_scratch', :scoping => 'rspec_testing')[:value]).to eq('true')
64
+ expect(set).to eq(true)
65
65
  end
66
66
 
67
67
  it "should fix '0' as a value with a check_box form_value_type to false" do
68
68
  set = ::Refinery::Setting.set(:creating_from_scratch, {:value => "0", :scoping => 'rspec_testing', :form_value_type => 'check_box'})
69
- ::Refinery::Setting.find_by_name(:creating_from_scratch.to_s, :conditions => {:scoping => 'rspec_testing'})[:value].should eq('false')
70
- set.should eq(false)
69
+ expect(::Refinery::Setting.find_by(:name => 'creating_from_scratch', :scoping => 'rspec_testing')[:value]).to eq('false')
70
+ expect(set).to eq(false)
71
71
  end
72
72
  end
73
73
 
74
74
  context "get" do
75
75
  it "should retrieve a seting that was created" do
76
76
  set = ::Refinery::Setting.set(:creating_from_scratch, {:value => "some value", :scoping => 'rspec_testing'})
77
- set.should eq('some value')
77
+ expect(set).to eq('some value')
78
78
 
79
79
  get = ::Refinery::Setting.get(:creating_from_scratch, :scoping => 'rspec_testing')
80
- get.should eq('some value')
80
+ expect(get).to eq('some value')
81
81
  end
82
82
 
83
83
  it "should also work with setting scoping using string and getting via symbol" do
84
84
  set = ::Refinery::Setting.set(:creating_from_scratch, {:value => "some value", :scoping => 'rspec_testing'})
85
- set.should eq('some value')
85
+ expect(set).to eq('some value')
86
86
 
87
87
  get = ::Refinery::Setting.get(:creating_from_scratch, :scoping => :rspec_testing)
88
- get.should eq('some value')
88
+ expect(get).to eq('some value')
89
89
  end
90
90
 
91
91
  it "should also work with setting scoping using symbol and getting via string" do
92
92
  set = ::Refinery::Setting.set(:creating_from_scratch, {:value => "some value", :scoping => :rspec_testing})
93
- set.should eq('some value')
93
+ expect(set).to eq('some value')
94
94
 
95
95
  get = ::Refinery::Setting.get(:creating_from_scratch, :scoping => 'rspec_testing')
96
- get.should eq('some value')
96
+ expect(get).to eq('some value')
97
97
  end
98
98
  end
99
99
 
@@ -101,22 +101,34 @@ module Refinery
101
101
  it "should create a non existant setting" do
102
102
  created = ::Refinery::Setting.find_or_set(:creating_from_scratch, 'I am a setting being created', :scoping => 'rspec_testing')
103
103
 
104
- created.should eq("I am a setting being created")
104
+ expect(created).to eq("I am a setting being created")
105
105
  end
106
106
 
107
107
  it "should not override an existing setting" do
108
108
  created = ::Refinery::Setting.set(:creating_from_scratch, {:value => 'I am a setting being created', :scoping => 'rspec_testing'})
109
- created.should eq("I am a setting being created")
109
+ expect(created).to eq("I am a setting being created")
110
110
 
111
111
  find_or_set_created = ::Refinery::Setting.find_or_set(:creating_from_scratch, 'Trying to change an existing value', :scoping => 'rspec_testing')
112
112
 
113
- created.should eq("I am a setting being created")
113
+ expect(created).to eq("I am a setting being created")
114
114
  end
115
115
 
116
116
  it "should work without scoping" do
117
- ::Refinery::Setting.find_or_set(:rspec_testing_creating_from_scratch, 'Yes it worked').should eq('Yes it worked')
117
+ expect(::Refinery::Setting.find_or_set(:rspec_testing_creating_from_scratch, 'Yes it worked')).to eq('Yes it worked')
118
118
  end
119
119
  end
120
120
 
121
+ describe "#should_generate_new_friendly_id?" do
122
+ context "when name changes" do
123
+ it "regenerates slug upon save" do
124
+ setting = FactoryGirl.create(:setting, :name => "Test Name")
125
+
126
+ setting.name = "Test Name 2"
127
+ setting.save!
128
+
129
+ expect(setting.slug).to eq("test-name-2")
130
+ end
131
+ end
132
+ end
121
133
  end
122
134
  end
@@ -1,11 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
3
 
4
- describe "routes for refinery settings" do
4
+ describe "routes for refinery settings", :type => :routing do
5
5
 
6
6
  context "when interface config is disabled" do
7
7
  before do
8
- Refinery::Settings.stub(:enable_interface).and_return(false)
8
+ allow(Refinery::Settings).to receive(:enable_interface).and_return(false)
9
9
  Refinery::Plugins.registered.find_by_name("refinery_settings").hide_from_menu = true
10
10
  end
11
11
 
data/spec/spec_helper.rb CHANGED
@@ -13,13 +13,13 @@ Rails.backtrace_cleaner.remove_silencers!
13
13
 
14
14
  RSpec.configure do |config|
15
15
  config.mock_with :rspec
16
- config.treat_symbols_as_metadata_keys_with_true_values = true
17
16
  config.filter_run :focus => true
18
17
  config.run_all_when_everything_filtered = true
19
18
  end
20
19
 
21
20
  # set javascript driver for capybara
22
- Capybara.javascript_driver = :selenium
21
+ require 'capybara/poltergeist'
22
+ Capybara.javascript_driver = :poltergeist
23
23
 
24
24
  # Requires supporting files with custom matchers and macros, etc,
25
25
  # in ./support/ and its subdirectories including factories.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Arndt
@@ -9,31 +9,57 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-10 00:00:00.000000000 Z
12
+ date: 2014-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: refinerycms-core
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 2.1.1
20
+ version: '3.0'
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.0.0
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - ~>
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '3.0'
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.0
34
+ - !ruby/object:Gem::Dependency
35
+ name: friendly_id
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 5.0.1
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '5.0'
51
+ - - ">="
26
52
  - !ruby/object:Gem::Version
27
- version: 2.1.1
53
+ version: 5.0.1
28
54
  description: Adds programmer creatable, user editable settings.
29
55
  email: info@refinerycms.com
30
56
  executables: []
31
57
  extensions: []
32
58
  extra_rdoc_files: []
33
59
  files:
34
- - .gitignore
35
- - .rspec
36
- - .travis.yml
60
+ - ".gitignore"
61
+ - ".rspec"
62
+ - ".travis.yml"
37
63
  - Gemfile
38
64
  - Rakefile
39
65
  - app/controllers/refinery/admin/settings_controller.rb
@@ -77,6 +103,7 @@ files:
77
103
  - config/routes.rb
78
104
  - db/migrate/20100913234710_create_refinerycms_settings_schema.rb
79
105
  - db/migrate/20130414130143_add_slug_to_refinery_settings.rb
106
+ - db/migrate/20130422105953_add_title_to_refinery_settings.rb
80
107
  - lib/generators/refinery/settings_generator.rb
81
108
  - lib/generators/refinery/templates/config/initializers/refinery/settings.rb.erb
82
109
  - lib/refinery/settings.rb
@@ -103,17 +130,17 @@ require_paths:
103
130
  - lib
104
131
  required_ruby_version: !ruby/object:Gem::Requirement
105
132
  requirements:
106
- - - '>='
133
+ - - ">="
107
134
  - !ruby/object:Gem::Version
108
135
  version: '0'
109
136
  required_rubygems_version: !ruby/object:Gem::Requirement
110
137
  requirements:
111
- - - '>='
138
+ - - ">="
112
139
  - !ruby/object:Gem::Version
113
140
  version: '0'
114
141
  requirements: []
115
- rubyforge_project: refinerycms
116
- rubygems_version: 2.1.0
142
+ rubyforge_project:
143
+ rubygems_version: 2.2.2
117
144
  signing_key:
118
145
  specification_version: 4
119
146
  summary: Settings engine for Refinery CMS