tenon 1.0.70 → 1.0.71
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tenon/i18n_lookup.rb +2 -2
- data/lib/tenon/version.rb +1 -1
- data/spec/features/tenon/comments_spec.rb +10 -10
- data/spec/features/tenon/i18n_spec.rb +106 -0
- data/spec/lib/tenon/i18n_lookup_spec.rb +19 -4
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9054c2cac1e7a21ec64187a6684a550f56529f2a
|
4
|
+
data.tar.gz: 392e62837098704cc4be1f177cbe97bb9df30f13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd28979cacc3f82a933a3d71e80a4a358805724381be2c0a18ef4b120a0f9ccd4940bf7dac7b28fe1b9815a8db2bc4e5e971c84b1910b5741a2ae9d1a08ad2ed
|
7
|
+
data.tar.gz: de00cba8698248740d9379a1a482a75bb2aad45675a2d41fdfe409c3d3fd5c3c1d90d90f9a0111c58bcd556cb5eae365db5c90ae510dfc3d7fcf4436cc610c74
|
data/lib/tenon/i18n_lookup.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Tenon
|
2
2
|
class I18nLookup
|
3
3
|
def initialize(klass)
|
4
|
-
@klass = klass
|
4
|
+
@klass = klass.to_s.sub /Decorator\z/, ''
|
5
5
|
end
|
6
6
|
|
7
7
|
def fields
|
8
|
-
self.class.fields[:tables][@klass.
|
8
|
+
self.class.fields[:tables][@klass.underscore.pluralize.to_sym] || []
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.fields
|
data/lib/tenon/version.rb
CHANGED
@@ -32,17 +32,17 @@ describe 'An admin viewing the comments index', js: true do
|
|
32
32
|
expect(page).to have_selector("a.toggle.#{action}.true")
|
33
33
|
end
|
34
34
|
end
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
37
|
+
context "if #{action} is true" do
|
38
|
+
it "should be able to toggle #{action} to false" do
|
39
|
+
comment.update_attributes(action.to_sym => true)
|
40
|
+
visit comments_path
|
41
|
+
within('ul#comments') do
|
42
|
+
expect(page).to have_selector("a.toggle.#{action}.true")
|
43
|
+
page.find("a.toggle.#{action}").click
|
44
|
+
expect(comment.reload.send("toggle_#{action}!")).to be_true
|
45
|
+
expect(page).to have_selector("a.toggle.#{action}.false")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include RequestHelpers
|
3
|
+
|
4
|
+
describe 'An admin', js: true do
|
5
|
+
let!(:admin) { create(:admin) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
login(admin)
|
9
|
+
end
|
10
|
+
|
11
|
+
# When a Tenon app is configured to use i18n, and a particular model is set
|
12
|
+
# up to have fields that are internationalized, then a Tenon user should
|
13
|
+
# see a "Locale" nav in the sidebar of the model form.
|
14
|
+
# EG, if posts are
|
15
|
+
# supposed to have an English title and a French title, when they add a
|
16
|
+
# post they will see a navigation item in the sidebar with two elements
|
17
|
+
# that say "English" and "French".
|
18
|
+
#
|
19
|
+
# Clicking these nav elements will show or hide the internationalized fields.
|
20
|
+
# The tests below make sure that these fields are rendered in the HTML
|
21
|
+
#
|
22
|
+
# However, there is a certain amount of configuration that is involved in
|
23
|
+
# making this stuff work, which is relevant only to these tests, and also
|
24
|
+
# happens to break stuff in other, non-internationalized tests. Therefore,
|
25
|
+
# we have all the setup and teardown below (see before(:all) and after(:all)
|
26
|
+
# respectively).
|
27
|
+
#
|
28
|
+
# We are using Tenon::Post as a test model, but this should work with any
|
29
|
+
# kind of model.
|
30
|
+
|
31
|
+
describe 'visiting a form with i18n fields' do
|
32
|
+
let!(:post) { create(:post) }
|
33
|
+
|
34
|
+
before(:all) do
|
35
|
+
# reset the Tenon:I18nLookup so that we use the thing defined in the
|
36
|
+
# spec/dummy app
|
37
|
+
Tenon::I18nLookup.class_variable_set :@@fields, nil
|
38
|
+
|
39
|
+
# We need to set up Tenon to tell it what languages it supports. We'll
|
40
|
+
# reset it below in after(:all)
|
41
|
+
@orig_languages = Tenon.config.languages
|
42
|
+
Tenon.config.languages = { "French" => :fr }
|
43
|
+
|
44
|
+
# Now that we've changed the langugages, we need to reload Tenon::Post
|
45
|
+
# so that the "tenon_content :content, i18n: true" call re-fires
|
46
|
+
# (otherwise, "association not found" errors happen)
|
47
|
+
reload "app/models/tenon/post.rb"
|
48
|
+
|
49
|
+
# Next we need to add the internationalized fields to the database so that
|
50
|
+
# we can save the post when we try to test the create / update views. We
|
51
|
+
# don't want to add a migration like that to the database, so we add it
|
52
|
+
# manually and reset the column info in Tenon::Post.
|
53
|
+
unless ActiveRecord::Base.connection.column_exists?(:tenon_posts, :title_fr)
|
54
|
+
ActiveRecord::Base.connection.add_column :tenon_posts, :title_fr, :string
|
55
|
+
end
|
56
|
+
Tenon::Post.reset_column_information
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'visiting the #new action' do
|
60
|
+
it 'should render the i18n fields' do
|
61
|
+
visit new_post_path
|
62
|
+
expect(page).to have_css "input#post_title_fr"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'visiting the #create action' do
|
67
|
+
it 'should render the i18n fields' do
|
68
|
+
visit new_post_path
|
69
|
+
# don't need the post to save properly, just need to see the create page
|
70
|
+
click_button 'Save'
|
71
|
+
expect(page).to have_css "input#post_title_fr"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'visiting the #edit action' do
|
76
|
+
it 'should render the i18n fields' do
|
77
|
+
visit edit_post_path(post)
|
78
|
+
expect(page).to have_css "input#post_title_fr"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'visiting the #update action' do
|
83
|
+
it 'should render the i18n fields' do
|
84
|
+
visit edit_post_path(post)
|
85
|
+
click_button 'Save'
|
86
|
+
expect(page).to have_css "input#post_title_fr"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
after(:all) do
|
91
|
+
# remove the added column
|
92
|
+
ActiveRecord::Base.connection.remove_column :tenon_posts, :title_fr
|
93
|
+
Tenon::Post.reset_column_information
|
94
|
+
|
95
|
+
# reset the languages Tenon is using
|
96
|
+
Tenon.config.languages = @orig_languages
|
97
|
+
|
98
|
+
# reload Tenon::Post
|
99
|
+
reload 'app/models/tenon/post.rb'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def reload(file_name)
|
105
|
+
load File.dirname(__FILE__) + '/../../../' + file_name
|
106
|
+
end
|
@@ -2,9 +2,18 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Tenon::I18nLookup do
|
4
4
|
describe '.new' do
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
context "when the given class is a Decorator" do
|
6
|
+
it 'assigns the decorated class.to_s to @klass' do
|
7
|
+
i = Tenon::I18nLookup.new(Tenon::Post.new.decorate.class)
|
8
|
+
expect(i.instance_variable_get('@klass')).to eq(Tenon::Post.new.class.to_s)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "when the given class is not a Decorator" do
|
13
|
+
it 'assigns class.to_s to @klass' do
|
14
|
+
i = Tenon::I18nLookup.new(String)
|
15
|
+
expect(i.instance_variable_get('@klass')).to eq(String.to_s)
|
16
|
+
end
|
8
17
|
end
|
9
18
|
end
|
10
19
|
|
@@ -48,7 +57,13 @@ describe Tenon::I18nLookup do
|
|
48
57
|
end
|
49
58
|
|
50
59
|
it 'should load the YAML' do
|
51
|
-
|
60
|
+
# for the love of Christ, make sure that the loaded YAML is a real
|
61
|
+
# representative of the file when loaded!
|
62
|
+
# alternatively, reload this with real data when done!
|
63
|
+
# MLK spent a shit-ton of time trying to fix testing errors caused
|
64
|
+
# by this:
|
65
|
+
# expect(YAML).to receive(:load) { {} }
|
66
|
+
expect(YAML).to receive(:load) { { tables: {} } }
|
52
67
|
Tenon::I18nLookup.fields
|
53
68
|
end
|
54
69
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tenon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.71
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- factor[e] design initiative
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: better_errors
|
@@ -1420,6 +1420,7 @@ files:
|
|
1420
1420
|
- spec/features/tenon/contacts_spec.rb
|
1421
1421
|
- spec/features/tenon/events_spec.rb
|
1422
1422
|
- spec/features/tenon/galleries_spec.rb
|
1423
|
+
- spec/features/tenon/i18n_spec.rb
|
1423
1424
|
- spec/features/tenon/pages_spec.rb
|
1424
1425
|
- spec/features/tenon/post_categories_spec.rb
|
1425
1426
|
- spec/features/tenon/posts_spec.rb
|
@@ -1506,7 +1507,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1506
1507
|
version: '0'
|
1507
1508
|
requirements: []
|
1508
1509
|
rubyforge_project:
|
1509
|
-
rubygems_version: 2.
|
1510
|
+
rubygems_version: 2.4.5
|
1510
1511
|
signing_key:
|
1511
1512
|
specification_version: 4
|
1512
1513
|
summary: A highly flexible mountable Rails CMS built for rapid application development.
|
@@ -1535,6 +1536,7 @@ test_files:
|
|
1535
1536
|
- spec/features/tenon/contacts_spec.rb
|
1536
1537
|
- spec/features/tenon/events_spec.rb
|
1537
1538
|
- spec/features/tenon/galleries_spec.rb
|
1539
|
+
- spec/features/tenon/i18n_spec.rb
|
1538
1540
|
- spec/features/tenon/pages_spec.rb
|
1539
1541
|
- spec/features/tenon/post_categories_spec.rb
|
1540
1542
|
- spec/features/tenon/posts_spec.rb
|