Commit e5021790c4c284deccd32dd2e21bc44a4606536a
1 parent
af30de84
Exists in
master
and in
29 other branches
metadata: fix application_controller test
Showing
4 changed files
with
48 additions
and
16 deletions
Show diff stats
plugins/metadata/lib/ext/environment.rb
... | ... | @@ -3,11 +3,19 @@ require_dependency 'environment' |
3 | 3 | class Environment |
4 | 4 | |
5 | 5 | metadata_spec namespace: :og, tags: { |
6 | + type: 'website', | |
7 | + title: proc{ |e, plugin| e.name }, | |
6 | 8 | site_name: proc{ |e, plugin| e.name }, |
7 | 9 | description: proc{ |e, plugin| e.name }, |
8 | 10 | url: proc{ |e, plugin| e.top_url }, |
9 | 11 | 'locale:locale' => proc{ |e, plugin| e.default_language }, |
10 | - 'locale:alternate' => proc{ |e, plugin| e.languages - [e.default_language] }, | |
12 | + 'locale:alternate' => proc{ |e, plugin| if e.default_language then e.languages - [e.default_language] else e.languages end }, | |
13 | + } | |
14 | + | |
15 | + metadata_spec namespace: :twitter, key_attr: :name, tags: { | |
16 | + card: 'summary', | |
17 | + title: proc{ |e, plugin| e.name }, | |
18 | + description: proc{ |e, plugin| e.name }, | |
11 | 19 | } |
12 | 20 | |
13 | 21 | end | ... | ... |
plugins/metadata/lib/ext/profile.rb
... | ... | @@ -24,4 +24,10 @@ class Profile |
24 | 24 | longitude: proc{ |p, plugin| p.lng }, |
25 | 25 | } |
26 | 26 | |
27 | + metadata_spec namespace: :twitter, key_attr: :name, tags: { | |
28 | + card: 'summary', | |
29 | + title: proc{ |p, plugin| p.name }, | |
30 | + description: proc{ |p, plugin| p.description }, | |
31 | + } | |
32 | + | |
27 | 33 | end | ... | ... |
plugins/metadata/test/functional/home_controller_test.rb
0 → 100644
... | ... | @@ -0,0 +1,33 @@ |
1 | +require 'test_helper' | |
2 | +require 'home_controller' | |
3 | + | |
4 | +# Re-raise errors caught by the controller. | |
5 | +class HomeController; def rescue_action(e) raise e end; end | |
6 | + | |
7 | +class HomeControllerTest < ActionController::TestCase | |
8 | + | |
9 | + def setup | |
10 | + @controller = HomeController.new | |
11 | + @request = ActionController::TestRequest.new | |
12 | + @response = ActionController::TestResponse.new | |
13 | + | |
14 | + Noosfero::Plugin.stubs(:all).returns([MetadataPlugin.name]) | |
15 | + Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([MetadataPlugin.new]) | |
16 | + end | |
17 | + | |
18 | + should 'display meta tags for social media' do | |
19 | + get :index | |
20 | + assert_tag :tag => 'meta', :attributes => { :name => 'twitter:card', :content => 'summary' } | |
21 | + assert_tag :tag => 'meta', :attributes => { :name => 'twitter:title', :content => assigns(:environment).name } | |
22 | + assert_tag :tag => 'meta', :attributes => { :name => 'twitter:description', :content => assigns(:environment).name } | |
23 | + assert_no_tag :tag => 'meta', :attributes => { :name => 'twitter:image' } | |
24 | + assert_tag :tag => 'meta', :attributes => { :property => 'og:type', :content => 'website' } | |
25 | + assert_tag :tag => 'meta', :attributes => { :property => 'og:url', :content => assigns(:environment).top_url } | |
26 | + assert_tag :tag => 'meta', :attributes => { :property => 'og:title', :content => assigns(:environment).name } | |
27 | + assert_tag :tag => 'meta', :attributes => { :property => 'og:site_name', :content => assigns(:environment).name } | |
28 | + assert_tag :tag => 'meta', :attributes => { :property => 'og:description', :content => assigns(:environment).name } | |
29 | + assert_no_tag :tag => 'meta', :attributes => { :property => 'article:published_time' } | |
30 | + assert_no_tag :tag => 'meta', :attributes => { :property => 'og:image' } | |
31 | + end | |
32 | + | |
33 | +end | ... | ... |
test/functional/application_controller_test.rb
... | ... | @@ -498,21 +498,6 @@ class ApplicationControllerTest < ActionController::TestCase |
498 | 498 | |
499 | 499 | end |
500 | 500 | |
501 | - should 'display meta tags for social media' do | |
502 | - get :index | |
503 | - assert_tag :tag => 'meta', :attributes => { :name => 'twitter:card', :value => 'summary' } | |
504 | - assert_tag :tag => 'meta', :attributes => { :name => 'twitter:title', :content => assigns(:environment).name } | |
505 | - assert_tag :tag => 'meta', :attributes => { :name => 'twitter:description', :content => assigns(:environment).name } | |
506 | - assert_no_tag :tag => 'meta', :attributes => { :name => 'twitter:image' } | |
507 | - assert_tag :tag => 'meta', :attributes => { :property => 'og:type', :content => 'website' } | |
508 | - assert_tag :tag => 'meta', :attributes => { :property => 'og:url', :content => assigns(:environment).top_url } | |
509 | - assert_tag :tag => 'meta', :attributes => { :property => 'og:title', :content => assigns(:environment).name } | |
510 | - assert_tag :tag => 'meta', :attributes => { :property => 'og:site_name', :content => assigns(:environment).name } | |
511 | - assert_tag :tag => 'meta', :attributes => { :property => 'og:description', :content => assigns(:environment).name } | |
512 | - assert_no_tag :tag => 'meta', :attributes => { :property => 'article:published_time' } | |
513 | - assert_no_tag :tag => 'meta', :attributes => { :property => 'og:image' } | |
514 | - end | |
515 | - | |
516 | 501 | should 'register search_term occurrence on find_by_contents' do |
517 | 502 | controller = ApplicationController.new |
518 | 503 | controller.stubs(:environment).returns(Environment.default) | ... | ... |