subdomain_locale 1.1.0 → 1.2.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: 58e47382709b64c4b6cad31a6b18ed1aecb877cd
4
- data.tar.gz: aab6515f887fd395b12fcc0f92f5b9f880194206
3
+ metadata.gz: 89b4a08096b05551117c0cd44f1fcf1efb0fbf45
4
+ data.tar.gz: 74466f490964eaa00a1151cd151ce32cbf608c47
5
5
  SHA512:
6
- metadata.gz: 389de7c0409e09ced5edfd2677a14c2367fa4cc0e789a8f2764783c80d421659feecf2f6b0f06e00556b4a437cb10c3158e5f7a755e090e1fd42836793fa1b88
7
- data.tar.gz: 7a20a72a24742d04ecb3a81dcaf7c487a446bf9b090a8d1a23ba6040e7b8b2dc132231ea7a4de4476c41492b28cc05472c97a696001ff8f4efebae902126197b
6
+ metadata.gz: a79dfd3d19011a1201596ea65ab6681c577e75f28a16951accd081f8ae32006244f22a51608e251eb0d1047705ef27c568035077ed9883e0bc878b98b6b58358
7
+ data.tar.gz: 58b66f01b130c27d72659af4fa54d6d456dfa5c8f559f86229612a20973de3af916d2aa956547de2c3e491a7bfb7b77307cdb78055b207f5fea65f789f99708b
data/Isolate CHANGED
@@ -1,25 +1,26 @@
1
1
  options system: false, cleanup: false
2
2
 
3
3
  gem 'bundler', '~> 1.5.0'
4
- gem 'i18n', '~> 0.6.9'
4
+ gem 'i18n', '~> 0.7.0'
5
+ gem 'rack-test', '~> 0.6.2'
6
+ gem 'mail', '~> 2.6.0'
5
7
 
6
8
  case ENV['RAILS']
7
- when '3.2'
8
- version = '~> 3.2.16'
9
- gem 'actionpack', version
10
- gem 'actionmailer', version
11
- gem 'railties', version
12
- gem 'minitest', '~> 4.2'
13
9
  when '4.0'
14
10
  version = '~> 4.0.0'
15
11
  gem 'actionpack', version
16
12
  gem 'actionmailer', version
17
13
  gem 'railties', version
18
- when nil
14
+ when '4.1'
19
15
  version = '~> 4.1.0'
20
16
  gem 'actionpack', version
21
17
  gem 'actionmailer', version
22
18
  gem 'railties', version
19
+ when '4.2', nil
20
+ version = '~> 4.2.0'
21
+ gem 'actionpack', version
22
+ gem 'actionmailer', version
23
+ gem 'railties', version
23
24
  else
24
25
  raise "Unrecognized Rails version: #{ENV['RAILS']}"
25
26
  end
data/Rakefile CHANGED
@@ -12,11 +12,11 @@ Rake::TestTask.new do |t|
12
12
  end
13
13
 
14
14
  task "test:all" do
15
- sh "rake test"
15
+ sh({"RAILS" => "4.2"}, $0, "test")
16
16
  puts
17
- sh "rake test RAILS=4.0"
17
+ sh({"RAILS" => "4.1"}, $0, "test")
18
18
  puts
19
- sh "rake test RAILS=3.2"
19
+ sh({"RAILS" => "4.0"}, $0, "test")
20
20
  end
21
21
 
22
22
  task :default => :test
data/Readme.md CHANGED
@@ -84,6 +84,16 @@ rake test:all
84
84
 
85
85
  ## Changelog
86
86
 
87
+ 1.2.0
88
+
89
+ * Support Rails 4.2 and I18n 0.7; drop Rails 3.2.
90
+ * Note: Rails 4.2 is more strict about `_path/_url` helpers. Make sure to use `_url` helper whenever you specify locale parameter:
91
+
92
+ ```ruby
93
+ root_path(locale: :ru) # bad, will raise deprecation warning
94
+ root_url(locale: :ru) # good
95
+ ```
96
+
87
97
  1.1.0
88
98
 
89
99
  * Custom subdomain provided in your default_url_options now has precedence over the default subdomain-locale.
@@ -7,7 +7,7 @@ module SubdomainLocale
7
7
  # url_for params.merge(locale: 'ru') # => /ru/current_path
8
8
  # After including this module:
9
9
  # url_for params.merge(locale: 'ru') # => http://ru.example.com/current_path
10
- def url_for(options)
10
+ def url_for(options, *other)
11
11
  options = options.dup
12
12
  if options.key?(:locale)
13
13
  # Locale specified, force full URL
@@ -16,7 +16,7 @@ module SubdomainLocale
16
16
  options[:only_path] = false
17
17
  end
18
18
 
19
- super
19
+ super(options, *other)
20
20
  end
21
21
 
22
22
  def default_url_options
@@ -25,6 +25,8 @@ module SubdomainLocale
25
25
  })
26
26
  end
27
27
 
28
+ private
29
+
28
30
  def current_locale
29
31
  I18n.locale
30
32
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "subdomain_locale"
5
- spec.version = "1.1.0"
5
+ spec.version = "1.2.0"
6
6
  spec.authors = ["Semyon Perepelitsa"]
7
7
  spec.email = ["sema@sema.in"]
8
8
  spec.summary = "Set I18n locale based on subdomain (Rails plugin)."
@@ -12,5 +12,6 @@ Gem::Specification.new do |spec|
12
12
  spec.files = File.read("Manifest.txt").split("\n")
13
13
  spec.test_files = spec.files.grep(%r{^test/})
14
14
 
15
- spec.add_dependency "i18n", "~> 0.6.9"
15
+ spec.add_dependency "i18n", ">= 0.7.0", "< 0.8"
16
+ spec.add_dependency "railties", ">= 4.0", "< 5.0"
16
17
  end
@@ -1,7 +1,9 @@
1
1
  class HelloMailer < ActionMailer::Base
2
- def world
3
- mail from: "app@example.com", to: "world@example.com", subject: "Hello, world!" do |f|
4
- f.text
2
+ def world(locale)
3
+ I18n.with_locale(locale) do
4
+ mail from: "app@example.com", to: "world@example.com", subject: "Hello, world!" do |f|
5
+ f.text
6
+ end
5
7
  end
6
8
  end
7
9
  end
@@ -1,8 +1,8 @@
1
1
  <menu>
2
- <%= link_to "Home", root_path %>
3
- <%= link_to "English", root_path(locale: "en") %>
4
- <%= link_to "Russian", root_path(locale: "ru") %>
5
- <%= link_to "Ukrainian", root_path(locale: "uk") %>
2
+ <%= link_to "Home", root_url %>
3
+ <%= link_to "English", root_url(locale: "en") %>
4
+ <%= link_to "Russian", root_url(locale: "ru") %>
5
+ <%= link_to "Ukrainian", root_url(locale: "uk") %>
6
6
  <%= link_to "Beta", root_url(subdomain: "beta") %>
7
7
  </menu>
8
8
 
@@ -1,7 +1,6 @@
1
1
  Dummy::Application.configure do
2
2
  config.eager_load = false
3
3
  config.cache_classes = true
4
- config.serve_static_assets = true
5
4
  config.consider_all_requests_local = true
6
5
  config.action_controller.perform_caching = false
7
6
  config.action_dispatch.show_exceptions = false
@@ -9,4 +8,5 @@ Dummy::Application.configure do
9
8
  config.active_support.deprecation = :stderr
10
9
  config.action_mailer.delivery_method = :test
11
10
  config.action_mailer.default_url_options = { host: "example.com" }
11
+ config.active_support.test_order = :random
12
12
  end
data/test/rails_test.rb CHANGED
@@ -6,7 +6,7 @@ class HelloControllerTest < ActionController::TestCase
6
6
  @request.host = "ru.example.com"
7
7
  get :world
8
8
  menu = css_select("menu a")
9
- assert_equal "/", menu[0]["href"]
9
+ assert_equal "http://example.com/", menu[0]["href"]
10
10
  assert_equal "http://en.example.com/", menu[1]["href"]
11
11
  assert_equal "http://example.com/", menu[2]["href"]
12
12
  assert_equal "http://ua.example.com/", menu[3]["href"]
@@ -49,13 +49,13 @@ end
49
49
 
50
50
  class HelloMailerTest < ActionController::TestCase
51
51
  def test_locale_domain
52
- mail = I18n.with_locale(:uk) { HelloMailer.world }
52
+ mail = HelloMailer.world(:uk)
53
53
  assert_equal "http://ua.example.com/", mail.body.to_s.lines[3].chomp
54
54
  end
55
55
 
56
56
  # BetaMailer overrides default_url_options
57
57
  def test_custom_domain
58
- mail = I18n.with_locale(:uk) { BetaMailer.world }
58
+ mail = BetaMailer.world(:uk)
59
59
  assert_equal "http://beta.example.com/", mail.body.to_s.lines[3].chomp
60
60
  end
61
61
  end
data/test/test_helper.rb CHANGED
@@ -6,9 +6,4 @@ require "minitest/autorun"
6
6
  require "rails/test_help"
7
7
  Rails.backtrace_cleaner.remove_silencers!
8
8
 
9
- # Mail 2.5 gives warnings, fixed in 2.6
10
- require "mail"
11
- Mail::Sendmail
12
- ##
13
-
14
9
  $VERBOSE = true
metadata CHANGED
@@ -1,29 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subdomain_locale
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Semyon Perepelitsa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.9
19
+ version: 0.7.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '0.8'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.7.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.8'
33
+ - !ruby/object:Gem::Dependency
34
+ name: railties
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '4.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '5.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '4.0'
50
+ - - "<"
25
51
  - !ruby/object:Gem::Version
26
- version: 0.6.9
52
+ version: '5.0'
27
53
  description:
28
54
  email:
29
55
  - sema@sema.in