refinerycms-admin-locales 1.0.0
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.
- data/.gitignore +158 -0
- data/Gemfile +7 -0
- data/Rakefile +18 -0
- data/app/controllers/admin/admin_locales_controller.rb +20 -0
- data/app/views/admin/admin_locales/_form.html.erb +20 -0
- data/app/views/admin/admin_locales/_records.html.erb +3 -0
- data/app/views/admin/admin_locales/_user.html.erb +13 -0
- data/app/views/admin/admin_locales/_users.html.erb +4 -0
- data/app/views/admin/admin_locales/edit.html.erb +2 -0
- data/app/views/admin/admin_locales/index.html.erb +3 -0
- data/config/locales/en.yml +18 -0
- data/config/locales/es.yml +18 -0
- data/config/routes.rb +5 -0
- data/db/migrate/1_add_locale_to_user.rb +13 -0
- data/db/seeds/refinerycms_admin_locales.rb +6 -0
- data/lib/generators/refinerycms_admin_locales_generator.rb +8 -0
- data/lib/refinery/admin_locales/version.rb +17 -0
- data/lib/refinerycms-admin-locales.rb +44 -0
- data/readme.md +36 -0
- data/refinerycms-admin-locales.gemspec +26 -0
- data/script/rails +10 -0
- data/spec/requests/refinery/admin_locales/admin/admin_locales_spec.rb +101 -0
- data/spec/spec_helper.rb +57 -0
- data/spec/support/factories/refinery/admin_locales.rb +11 -0
- data/tasks/rspec.rake +6 -0
- data/tasks/testing.rake +8 -0
- metadata +96 -0
data/.gitignore
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# Rails
|
|
2
|
+
.bundle
|
|
3
|
+
db/*.sqlite3
|
|
4
|
+
db/*.sqlite3-journal
|
|
5
|
+
*.log
|
|
6
|
+
tmp
|
|
7
|
+
tmp/**/*
|
|
8
|
+
|
|
9
|
+
# Documentation
|
|
10
|
+
doc/api
|
|
11
|
+
doc/app
|
|
12
|
+
.yardoc
|
|
13
|
+
.yardopts
|
|
14
|
+
coverage
|
|
15
|
+
|
|
16
|
+
# Public Uploads
|
|
17
|
+
public/system/*
|
|
18
|
+
public/themes/*
|
|
19
|
+
|
|
20
|
+
# Public Cache
|
|
21
|
+
public/javascripts/cache
|
|
22
|
+
public/stylesheets/cache
|
|
23
|
+
|
|
24
|
+
# Vendor Cache
|
|
25
|
+
vendor/cache
|
|
26
|
+
|
|
27
|
+
# Acts as Indexed
|
|
28
|
+
index/**/*
|
|
29
|
+
|
|
30
|
+
# Refinery Specific
|
|
31
|
+
*.tmproj
|
|
32
|
+
*.autobackupbyrefinery.*
|
|
33
|
+
refinerycms-*.gem
|
|
34
|
+
|
|
35
|
+
# Mac
|
|
36
|
+
.DS_Store
|
|
37
|
+
|
|
38
|
+
# Windows
|
|
39
|
+
Thumbs.db
|
|
40
|
+
|
|
41
|
+
# NetBeans
|
|
42
|
+
nbproject
|
|
43
|
+
|
|
44
|
+
# Eclipse
|
|
45
|
+
.project
|
|
46
|
+
|
|
47
|
+
# Redcar
|
|
48
|
+
.redcar
|
|
49
|
+
|
|
50
|
+
# Rubinius
|
|
51
|
+
*.rbc
|
|
52
|
+
|
|
53
|
+
# Vim
|
|
54
|
+
*.swp
|
|
55
|
+
*.swo
|
|
56
|
+
|
|
57
|
+
# RubyMine
|
|
58
|
+
.idea
|
|
59
|
+
|
|
60
|
+
# E-texteditor
|
|
61
|
+
.eprj
|
|
62
|
+
|
|
63
|
+
# Backup
|
|
64
|
+
*~
|
|
65
|
+
|
|
66
|
+
# Capybara Bug
|
|
67
|
+
capybara-*html
|
|
68
|
+
|
|
69
|
+
# sass
|
|
70
|
+
.sass-cache
|
|
71
|
+
.sass-cache/*
|
|
72
|
+
|
|
73
|
+
#rvm
|
|
74
|
+
.rvmrc
|
|
75
|
+
.rvmrc.*
|
|
76
|
+
|
|
77
|
+
# dummy applications.
|
|
78
|
+
spec/dummy
|
|
79
|
+
|
|
80
|
+
# Rails
|
|
81
|
+
.bundle
|
|
82
|
+
db/*.sqlite3
|
|
83
|
+
db/*.sqlite3-journal
|
|
84
|
+
*.log
|
|
85
|
+
tmp
|
|
86
|
+
tmp/**/*
|
|
87
|
+
|
|
88
|
+
# Documentation
|
|
89
|
+
doc/api
|
|
90
|
+
doc/app
|
|
91
|
+
.yardoc
|
|
92
|
+
.yardopts
|
|
93
|
+
coverage
|
|
94
|
+
|
|
95
|
+
# Public Uploads
|
|
96
|
+
public/system/*
|
|
97
|
+
public/themes/*
|
|
98
|
+
|
|
99
|
+
# Public Cache
|
|
100
|
+
public/javascripts/cache
|
|
101
|
+
public/stylesheets/cache
|
|
102
|
+
|
|
103
|
+
# Vendor Cache
|
|
104
|
+
vendor/cache
|
|
105
|
+
|
|
106
|
+
# Acts as Indexed
|
|
107
|
+
index/**/*
|
|
108
|
+
|
|
109
|
+
# Refinery Specific
|
|
110
|
+
*.tmproj
|
|
111
|
+
*.autobackupbyrefinery.*
|
|
112
|
+
refinerycms-*.gem
|
|
113
|
+
|
|
114
|
+
# Mac
|
|
115
|
+
.DS_Store
|
|
116
|
+
|
|
117
|
+
# Windows
|
|
118
|
+
Thumbs.db
|
|
119
|
+
|
|
120
|
+
# NetBeans
|
|
121
|
+
nbproject
|
|
122
|
+
|
|
123
|
+
# Eclipse
|
|
124
|
+
.project
|
|
125
|
+
|
|
126
|
+
# Redcar
|
|
127
|
+
.redcar
|
|
128
|
+
|
|
129
|
+
# Rubinius
|
|
130
|
+
*.rbc
|
|
131
|
+
|
|
132
|
+
# Vim
|
|
133
|
+
*.swp
|
|
134
|
+
*.swo
|
|
135
|
+
|
|
136
|
+
# RubyMine
|
|
137
|
+
.idea
|
|
138
|
+
|
|
139
|
+
# E-texteditor
|
|
140
|
+
.eprj
|
|
141
|
+
|
|
142
|
+
# Backup
|
|
143
|
+
*~
|
|
144
|
+
|
|
145
|
+
# Capybara Bug
|
|
146
|
+
capybara-*html
|
|
147
|
+
|
|
148
|
+
# sass
|
|
149
|
+
.sass-cache
|
|
150
|
+
.sass-cache/*
|
|
151
|
+
|
|
152
|
+
#rvm
|
|
153
|
+
.rvmrc
|
|
154
|
+
.rvmrc.*
|
|
155
|
+
|
|
156
|
+
# vendor/extensions dummy applications.
|
|
157
|
+
vendor/extensions/**/spec/dummy
|
|
158
|
+
|
data/Gemfile
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
begin
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
ENGINE_PATH = File.dirname(__FILE__)
|
|
9
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
10
|
+
|
|
11
|
+
load 'rails/tasks/engine.rake' if File.exists?(APP_RAKEFILE)
|
|
12
|
+
|
|
13
|
+
require "refinerycms-testing"
|
|
14
|
+
Refinery::Testing::Railtie.load_tasks
|
|
15
|
+
Refinery::Testing::Railtie.load_dummy_tasks(ENGINE_PATH)
|
|
16
|
+
|
|
17
|
+
load File.expand_path('../tasks/testing.rake', __FILE__)
|
|
18
|
+
load File.expand_path('../tasks/rspec.rake', __FILE__)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Admin
|
|
2
|
+
class AdminLocalesController < Admin::BaseController
|
|
3
|
+
|
|
4
|
+
crudify :user,
|
|
5
|
+
:order => 'username ASC',
|
|
6
|
+
:title_attribute => :username,
|
|
7
|
+
:xhr_paging => true
|
|
8
|
+
|
|
9
|
+
def update
|
|
10
|
+
locale = params[:user][:locale]
|
|
11
|
+
@user.locale = locale if params[:user][:locale]
|
|
12
|
+
if locale && @user.save
|
|
13
|
+
redirect_to admin_admin_locales_path,
|
|
14
|
+
:notice => t('updated', :what => @user.username, :scope => 'refinery.crudify')
|
|
15
|
+
else
|
|
16
|
+
render :edit
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%= form_for @user, :url => admin_admin_locale_path(@user), :method => :put do |f| %>
|
|
2
|
+
|
|
3
|
+
<%= render :partial => "/shared/admin/error_messages",
|
|
4
|
+
:locals => {
|
|
5
|
+
:object => @user,
|
|
6
|
+
:include_object_name => true
|
|
7
|
+
} %>
|
|
8
|
+
|
|
9
|
+
<div class='field'>
|
|
10
|
+
<%= f.label :locale %>
|
|
11
|
+
<%= f.select :locale, options_for_select(Refinery::I18n.locales.map(&:reverse), @user.locale) %>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<%= render :partial => "/shared/admin/form_actions",
|
|
15
|
+
:locals => {
|
|
16
|
+
:f => f,
|
|
17
|
+
:continue_editing => false,
|
|
18
|
+
:hide_delete => true
|
|
19
|
+
} %>
|
|
20
|
+
<% end %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<li id="sortable_<%= user.id %>" class='clearfix record <%= cycle("on", "on-hover") %>'>
|
|
2
|
+
<span class='title'>
|
|
3
|
+
<strong><%= user.username %></strong>
|
|
4
|
+
<span class="preview">
|
|
5
|
+
<%= t '.locale' %>: <%= user.locale || t('.any') %>
|
|
6
|
+
</span>
|
|
7
|
+
</span>
|
|
8
|
+
<span class='actions'>
|
|
9
|
+
<%= link_to refinery_icon_tag('application_edit.png'),
|
|
10
|
+
edit_admin_admin_locale_path(user),
|
|
11
|
+
:title => t('.edit') %>
|
|
12
|
+
</span>
|
|
13
|
+
</li>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
en:
|
|
2
|
+
plugins:
|
|
3
|
+
refinerycms_admin_locales:
|
|
4
|
+
title: User locales
|
|
5
|
+
admin:
|
|
6
|
+
admin_locales:
|
|
7
|
+
records:
|
|
8
|
+
title: User locales
|
|
9
|
+
sorry_no_results: No results, sorry.
|
|
10
|
+
no_items_yet: There are not users yet
|
|
11
|
+
user:
|
|
12
|
+
any: Any
|
|
13
|
+
edit: Edit locale
|
|
14
|
+
locale: Locale
|
|
15
|
+
activerecord:
|
|
16
|
+
attributes:
|
|
17
|
+
user:
|
|
18
|
+
locale: Locale
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
es:
|
|
2
|
+
plugins:
|
|
3
|
+
refinerycms_admin_locales:
|
|
4
|
+
title: Idiomas de usuario
|
|
5
|
+
admin:
|
|
6
|
+
admin_locales:
|
|
7
|
+
records:
|
|
8
|
+
title: Idiomas de usuario
|
|
9
|
+
sorry_no_results: Lo siento, no hay resultados
|
|
10
|
+
no_items_yet: No hay usuario todavía.
|
|
11
|
+
user:
|
|
12
|
+
any: Ninguno
|
|
13
|
+
edit: Editar este idioma
|
|
14
|
+
locale: Idioma
|
|
15
|
+
activerecord:
|
|
16
|
+
attributes:
|
|
17
|
+
user:
|
|
18
|
+
locale: Idioma
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'refinery'
|
|
2
|
+
|
|
3
|
+
module Refinery
|
|
4
|
+
module AdminLocales
|
|
5
|
+
class << self
|
|
6
|
+
attr_accessor :root
|
|
7
|
+
|
|
8
|
+
def root
|
|
9
|
+
@root ||= Pathname.new(File.expand_path('../../../', __FILE__))
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def version
|
|
13
|
+
::Refinery::AdminLocales::Version.to_s
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class Engine < Rails::Engine
|
|
18
|
+
|
|
19
|
+
config.after_initialize do
|
|
20
|
+
Refinery::Plugin.register do |plugin|
|
|
21
|
+
plugin.name = "refinerycms_admin_locales"
|
|
22
|
+
plugin.pathname = root
|
|
23
|
+
plugin.url = { :controller => '/admin/admin_locales', :action => 'index' }
|
|
24
|
+
plugin.menu_match = /(admin|refinery)\/admin_locales$/
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
config.to_prepare do
|
|
29
|
+
::Admin::BaseController.class_eval do
|
|
30
|
+
def find_or_set_locale_with_default
|
|
31
|
+
if current_user && current_user.locale
|
|
32
|
+
::Refinery::I18n.current_locale = current_user.locale
|
|
33
|
+
::I18n.locale = ::Refinery::I18n.current_locale
|
|
34
|
+
else
|
|
35
|
+
find_or_set_locale_without_default
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
alias_method_chain :find_or_set_locale, :default
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/readme.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Admin Locales extension for Refinery CMS.
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
This extension adds a locale attribute to dashboard users
|
|
6
|
+
and a tab to change this locale in each user.
|
|
7
|
+
|
|
8
|
+
The dashboard locale will allways load the user locale instead the selected locale
|
|
9
|
+
in the views. If the user hasn't locale, the find locale method used will be the default
|
|
10
|
+
refinery method.
|
|
11
|
+
|
|
12
|
+
This refinery extension solves the locale dashboard conflicts with multiple
|
|
13
|
+
users who need different locales at the same time.
|
|
14
|
+
|
|
15
|
+
## How to add this extension to your project
|
|
16
|
+
|
|
17
|
+
### Refinery 2:
|
|
18
|
+
|
|
19
|
+
#### Add gem to Gemfile
|
|
20
|
+
gem 'refinerycms-admin-locales', '2.0', :git => 'git_repo/refinerycms-admin-locales'
|
|
21
|
+
|
|
22
|
+
#### Install extension
|
|
23
|
+
rake refinery_admin_locales:install:migrations
|
|
24
|
+
rake db:migrate
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Refinery 1:
|
|
28
|
+
|
|
29
|
+
#### Add gem to Gemfile
|
|
30
|
+
gem 'refinerycms-admin-locales', '1.0', :git => 'git_repo/refinerycms-admin-locales', :branch => 'refinerycms1'
|
|
31
|
+
|
|
32
|
+
#### Install extension
|
|
33
|
+
rails generate refinerycms_admin_locales
|
|
34
|
+
rake db:migrate
|
|
35
|
+
|
|
36
|
+
**WARNING: Refinary 1 version, is not test, but it should work**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
4
|
+
require 'refinery/admin_locales/version'
|
|
5
|
+
version = Refinery::AdminLocales::Version.to_s
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.name = %q{refinerycms-admin-locales}
|
|
10
|
+
s.version = version
|
|
11
|
+
s.description = %q{Manage locale for each user in the refinerycms admin.}
|
|
12
|
+
s.summary = %q{Admin Locales extension for Refinery CMS.}
|
|
13
|
+
s.email = %q{ruben@simplelogica.net}
|
|
14
|
+
s.authors = ['Simplelógica','Rubén Sierra']
|
|
15
|
+
s.homepage = %q{http://simplelogica.net/}
|
|
16
|
+
s.require_paths = %w(lib)
|
|
17
|
+
|
|
18
|
+
s.files = `git ls-files`.split("\n")
|
|
19
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
|
20
|
+
|
|
21
|
+
# Runtime dependencies
|
|
22
|
+
s.add_dependency 'refinerycms-core', '~> 1.0.0'
|
|
23
|
+
|
|
24
|
+
# Development dependencies (usually used for testing)
|
|
25
|
+
s.add_development_dependency 'refinerycms-testing', '~> 1.0.0'
|
|
26
|
+
end
|
data/script/rails
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
ENGINE_PATH = File.expand_path('../..', __FILE__)
|
|
5
|
+
dummy_rails_path = File.expand_path('../../spec/dummy/script/rails', __FILE__)
|
|
6
|
+
if File.exist?(dummy_rails_path)
|
|
7
|
+
load dummy_rails_path
|
|
8
|
+
else
|
|
9
|
+
puts "Please first run 'rake refinery:testing:dummy_app' to create a dummy Refinery CMS application."
|
|
10
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require "spec_helper"
|
|
3
|
+
|
|
4
|
+
describe Refinery do
|
|
5
|
+
describe "AdminLocales" do
|
|
6
|
+
describe "Admin" do
|
|
7
|
+
describe "admin_locales" do
|
|
8
|
+
login_refinery_user
|
|
9
|
+
|
|
10
|
+
describe "admin_locales list" do
|
|
11
|
+
before(:each) do
|
|
12
|
+
FactoryGirl.create(:admin_locale, :locale => "UniqueTitleOne")
|
|
13
|
+
FactoryGirl.create(:admin_locale, :locale => "UniqueTitleTwo")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "shows two items" do
|
|
17
|
+
visit refinery.admin_locales_admin_admin_locales_path
|
|
18
|
+
page.should have_content("UniqueTitleOne")
|
|
19
|
+
page.should have_content("UniqueTitleTwo")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "create" do
|
|
24
|
+
before(:each) do
|
|
25
|
+
visit refinery.admin_locales_admin_admin_locales_path
|
|
26
|
+
|
|
27
|
+
click_link "Add New Admin Locale"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "valid data" do
|
|
31
|
+
it "should succeed" do
|
|
32
|
+
fill_in "Locale", :with => "This is a test of the first string field"
|
|
33
|
+
click_button "Save"
|
|
34
|
+
|
|
35
|
+
page.should have_content("'This is a test of the first string field' was successfully added.")
|
|
36
|
+
Refinery::AdminLocales::AdminLocale.count.should == 1
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context "invalid data" do
|
|
41
|
+
it "should fail" do
|
|
42
|
+
click_button "Save"
|
|
43
|
+
|
|
44
|
+
page.should have_content("Locale can't be blank")
|
|
45
|
+
Refinery::AdminLocales::AdminLocale.count.should == 0
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
context "duplicate" do
|
|
50
|
+
before(:each) { FactoryGirl.create(:admin_locale, :locale => "UniqueTitle") }
|
|
51
|
+
|
|
52
|
+
it "should fail" do
|
|
53
|
+
visit refinery.admin_locales_admin_admin_locales_path
|
|
54
|
+
|
|
55
|
+
click_link "Add New Admin Locale"
|
|
56
|
+
|
|
57
|
+
fill_in "Locale", :with => "UniqueTitle"
|
|
58
|
+
click_button "Save"
|
|
59
|
+
|
|
60
|
+
page.should have_content("There were problems")
|
|
61
|
+
Refinery::AdminLocales::AdminLocale.count.should == 1
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "edit" do
|
|
68
|
+
before(:each) { FactoryGirl.create(:admin_locale, :locale => "A locale") }
|
|
69
|
+
|
|
70
|
+
it "should succeed" do
|
|
71
|
+
visit refinery.admin_locales_admin_admin_locales_path
|
|
72
|
+
|
|
73
|
+
within ".actions" do
|
|
74
|
+
click_link "Edit this admin locale"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
fill_in "Locale", :with => "A different locale"
|
|
78
|
+
click_button "Save"
|
|
79
|
+
|
|
80
|
+
page.should have_content("'A different locale' was successfully updated.")
|
|
81
|
+
page.should have_no_content("A locale")
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe "destroy" do
|
|
86
|
+
before(:each) { FactoryGirl.create(:admin_locale, :locale => "UniqueTitleOne") }
|
|
87
|
+
|
|
88
|
+
it "should succeed" do
|
|
89
|
+
visit refinery.admin_locales_admin_admin_locales_path
|
|
90
|
+
|
|
91
|
+
click_link "Remove this admin locale forever"
|
|
92
|
+
|
|
93
|
+
page.should have_content("'UniqueTitleOne' was successfully removed.")
|
|
94
|
+
Refinery::AdminLocales::AdminLocale.count.should == 0
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
def setup_environment
|
|
2
|
+
# Configure Rails Environment
|
|
3
|
+
ENV["RAILS_ENV"] ||= 'test'
|
|
4
|
+
|
|
5
|
+
if File.exist?(dummy_path = File.expand_path('../spec/dummy/config/environment.rb', __FILE__))
|
|
6
|
+
require dummy_path
|
|
7
|
+
elsif File.dirname(__FILE__) =~ %r{vendor/extensions}
|
|
8
|
+
# Require the path to the refinerycms application this is vendored inside.
|
|
9
|
+
require File.expand_path('../../../../../config/environment', __FILE__)
|
|
10
|
+
else
|
|
11
|
+
raise "Could not find a config/environment.rb file to require. Please specify this in spec/spec_helper.rb"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
require 'rspec/rails'
|
|
15
|
+
require 'capybara/rspec'
|
|
16
|
+
|
|
17
|
+
Rails.backtrace_cleaner.remove_silencers!
|
|
18
|
+
|
|
19
|
+
RSpec.configure do |config|
|
|
20
|
+
config.mock_with :rspec
|
|
21
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
|
22
|
+
config.filter_run :focus => true
|
|
23
|
+
config.run_all_when_everything_filtered = true
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def each_run
|
|
28
|
+
Rails.cache.clear
|
|
29
|
+
ActiveSupport::Dependencies.clear
|
|
30
|
+
FactoryGirl.reload
|
|
31
|
+
|
|
32
|
+
# Requires supporting files with custom matchers and macros, etc,
|
|
33
|
+
# in ./support/ and its subdirectories including factories.
|
|
34
|
+
([Rails.root.to_s] | ::Refinery::Plugins.registered.pathnames).map{|p|
|
|
35
|
+
Dir[File.join(p, 'spec', 'support', '**', '*.rb').to_s]
|
|
36
|
+
}.flatten.sort.each do |support_file|
|
|
37
|
+
require support_file
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# If spork is available in the Gemfile it'll be used but we don't force it.
|
|
42
|
+
unless (begin; require 'spork'; rescue LoadError; nil end).nil?
|
|
43
|
+
Spork.prefork do
|
|
44
|
+
# Loading more in this block will cause your tests to run faster. However,
|
|
45
|
+
# if you change any configuration or code from libraries loaded here, you'll
|
|
46
|
+
# need to restart spork for it take effect.
|
|
47
|
+
setup_environment
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Spork.each_run do
|
|
51
|
+
# This code will be run each time you run your specs.
|
|
52
|
+
each_run
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
setup_environment
|
|
56
|
+
each_run
|
|
57
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
FactoryGirl.define do
|
|
3
|
+
factory :user, :class => Refinery::User do
|
|
4
|
+
sequence(:username) { |n| "refinery#{n}" }
|
|
5
|
+
sequence(:email) { |n| "refinery#{n}@refinerycms.com" }
|
|
6
|
+
password "refinerycms"
|
|
7
|
+
password_confirmation "refinerycms"
|
|
8
|
+
locale :en
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
data/tasks/rspec.rake
ADDED
data/tasks/testing.rake
ADDED
metadata
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: refinerycms-admin-locales
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Simplelógica
|
|
9
|
+
- Rubén Sierra
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: bin
|
|
12
|
+
cert_chain: []
|
|
13
|
+
date: 2012-09-04 00:00:00.000000000Z
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: refinerycms-core
|
|
17
|
+
requirement: &2152159380 !ruby/object:Gem::Requirement
|
|
18
|
+
none: false
|
|
19
|
+
requirements:
|
|
20
|
+
- - ~>
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 1.0.0
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: *2152159380
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: refinerycms-testing
|
|
28
|
+
requirement: &2152158400 !ruby/object:Gem::Requirement
|
|
29
|
+
none: false
|
|
30
|
+
requirements:
|
|
31
|
+
- - ~>
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 1.0.0
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: *2152158400
|
|
37
|
+
description: Manage locale for each user in the refinerycms admin.
|
|
38
|
+
email: ruben@simplelogica.net
|
|
39
|
+
executables: []
|
|
40
|
+
extensions: []
|
|
41
|
+
extra_rdoc_files: []
|
|
42
|
+
files:
|
|
43
|
+
- .gitignore
|
|
44
|
+
- Gemfile
|
|
45
|
+
- Rakefile
|
|
46
|
+
- app/controllers/admin/admin_locales_controller.rb
|
|
47
|
+
- app/views/admin/admin_locales/_form.html.erb
|
|
48
|
+
- app/views/admin/admin_locales/_records.html.erb
|
|
49
|
+
- app/views/admin/admin_locales/_user.html.erb
|
|
50
|
+
- app/views/admin/admin_locales/_users.html.erb
|
|
51
|
+
- app/views/admin/admin_locales/edit.html.erb
|
|
52
|
+
- app/views/admin/admin_locales/index.html.erb
|
|
53
|
+
- config/locales/en.yml
|
|
54
|
+
- config/locales/es.yml
|
|
55
|
+
- config/routes.rb
|
|
56
|
+
- db/migrate/1_add_locale_to_user.rb
|
|
57
|
+
- db/seeds/refinerycms_admin_locales.rb
|
|
58
|
+
- lib/generators/refinerycms_admin_locales_generator.rb
|
|
59
|
+
- lib/refinery/admin_locales/version.rb
|
|
60
|
+
- lib/refinerycms-admin-locales.rb
|
|
61
|
+
- readme.md
|
|
62
|
+
- refinerycms-admin-locales.gemspec
|
|
63
|
+
- script/rails
|
|
64
|
+
- spec/requests/refinery/admin_locales/admin/admin_locales_spec.rb
|
|
65
|
+
- spec/spec_helper.rb
|
|
66
|
+
- spec/support/factories/refinery/admin_locales.rb
|
|
67
|
+
- tasks/rspec.rake
|
|
68
|
+
- tasks/testing.rake
|
|
69
|
+
homepage: http://simplelogica.net/
|
|
70
|
+
licenses: []
|
|
71
|
+
post_install_message:
|
|
72
|
+
rdoc_options: []
|
|
73
|
+
require_paths:
|
|
74
|
+
- lib
|
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
|
+
none: false
|
|
77
|
+
requirements:
|
|
78
|
+
- - ! '>='
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0'
|
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
|
+
none: false
|
|
83
|
+
requirements:
|
|
84
|
+
- - ! '>='
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: '0'
|
|
87
|
+
requirements: []
|
|
88
|
+
rubyforge_project:
|
|
89
|
+
rubygems_version: 1.8.10
|
|
90
|
+
signing_key:
|
|
91
|
+
specification_version: 3
|
|
92
|
+
summary: Admin Locales extension for Refinery CMS.
|
|
93
|
+
test_files:
|
|
94
|
+
- spec/requests/refinery/admin_locales/admin/admin_locales_spec.rb
|
|
95
|
+
- spec/spec_helper.rb
|
|
96
|
+
- spec/support/factories/refinery/admin_locales.rb
|