Commit 5c1641f3595d162184bcec55ec7cad53b6d16966
Committed by
Daniela Feitosa
1 parent
fd23e874
Exists in
master
and in
29 other branches
curriculum_lattes_plugin: Improvements and test
Showing
5 changed files
with
75 additions
and
9 deletions
Show diff stats
plugins/lattes_curriculum/features/lattes_curriculum.feature
@@ -9,16 +9,53 @@ Feature: import lattes information | @@ -9,16 +9,53 @@ Feature: import lattes information | ||
9 | And I go to /admin/plugins | 9 | And I go to /admin/plugins |
10 | And I check "LattesCurriculumPlugin" | 10 | And I check "LattesCurriculumPlugin" |
11 | And I press "Save changes" | 11 | And I press "Save changes" |
12 | + And I go to /admin/features/manage_fields | ||
13 | + Given I follow "Person's fields" | ||
14 | + And I check "person_fields_lattes_url_active" | ||
15 | + And I check "person_fields_lattes_url_signup" | ||
16 | + And I press "save_person_fields" | ||
17 | + And feature "skip_new_user_email_confirmation" is enabled on environment | ||
12 | And I am not logged in | 18 | And I am not logged in |
13 | 19 | ||
14 | @selenium | 20 | @selenium |
15 | Scenario: Import lattes informations after singup | 21 | Scenario: Import lattes informations after singup |
16 | Given I am on signup page | 22 | Given I am on signup page |
17 | - And I fill in "e-Mail" with "josesilva@example.com" | 23 | + When I fill in "e-Mail" with "josesilva@example.com" |
18 | And I fill in "Username" with "josesilva" | 24 | And I fill in "Username" with "josesilva" |
19 | And I fill in "Full name" with "João Silva" | 25 | And I fill in "Full name" with "João Silva" |
20 | And I fill in "Password" with "secret" | 26 | And I fill in "Password" with "secret" |
21 | And I fill in "Password confirmation" with "secret" | 27 | And I fill in "Password confirmation" with "secret" |
22 | - And I fill in "URL Lattes" with "http://lattes.cnpq.br/2864976228727880" | 28 | + And I fill in "Lattes URL" with "http://lattes.cnpq.br/2864976228727880" |
23 | And wait for the captcha signup time | 29 | And wait for the captcha signup time |
24 | - And I press "Create my account" | ||
25 | \ No newline at end of file | 30 | \ No newline at end of file |
31 | + And I press "Create my account" | ||
32 | + And I go to /profile/josesilva | ||
33 | + And I follow "Lattes" within "#ui-tabs-anchor" | ||
34 | + Then I should see "Endereço para acessar este CV: http://lattes.cnpq.br/2864976228727880" | ||
35 | + | ||
36 | + @selenium | ||
37 | + Scenario: Don't show lattes informations for blank lattes urls | ||
38 | + Given I am on signup page | ||
39 | + When I fill in "e-Mail" with "josesilva@example.com" | ||
40 | + And I fill in "Username" with "josesilva" | ||
41 | + And I fill in "Full name" with "João Silva" | ||
42 | + And I fill in "Password" with "secret" | ||
43 | + And I fill in "Password confirmation" with "secret" | ||
44 | + And wait for the captcha signup time | ||
45 | + And I press "Create my account" | ||
46 | + And I go to /profile/josesilva | ||
47 | + Then I should not see "Lattes" within "#ui-tabs-anchor" | ||
48 | + | ||
49 | + @selenium | ||
50 | + Scenario: Inform problem if the informed lattes doesn't exist | ||
51 | + Given I am on signup page | ||
52 | + When I fill in "e-Mail" with "josesilva@example.com" | ||
53 | + And I fill in "Username" with "josesilva" | ||
54 | + And I fill in "Full name" with "João Silva" | ||
55 | + And I fill in "Password" with "secret" | ||
56 | + And I fill in "Password confirmation" with "secret" | ||
57 | + And I fill in "Lattes URL" with "http://lattes.cnpq.br/123456" | ||
58 | + And wait for the captcha signup time | ||
59 | + And I press "Create my account" | ||
60 | + And I go to /profile/josesilva | ||
61 | + And I follow "Lattes" within "#ui-tabs-anchor" | ||
62 | + Then I should see "Lattes not found. Please, make sure the informed URL is correct." | ||
26 | \ No newline at end of file | 63 | \ No newline at end of file |
plugins/lattes_curriculum/lib/html_parser.rb
@@ -15,8 +15,8 @@ class Html_parser | @@ -15,8 +15,8 @@ class Html_parser | ||
15 | page = remove_select(page) | 15 | page = remove_select(page) |
16 | page = remove_footer(page) | 16 | page = remove_footer(page) |
17 | page = remove_further_informations(page) | 17 | page = remove_further_informations(page) |
18 | - rescue | ||
19 | - page = "" | 18 | + rescue OpenURI::HTTPError => e |
19 | + page = _("Lattes not found. Please, make sure the informed URL is correct.") | ||
20 | end | 20 | end |
21 | end | 21 | end |
22 | 22 |
plugins/lattes_curriculum/lib/lattes_curriculum_plugin.rb
@@ -49,7 +49,7 @@ class LattesCurriculumPlugin < Noosfero::Plugin | @@ -49,7 +49,7 @@ class LattesCurriculumPlugin < Noosfero::Plugin | ||
49 | end | 49 | end |
50 | 50 | ||
51 | def profile_tabs | 51 | def profile_tabs |
52 | - unless context.profile.academic_info.nil? || context.profile.academic_info.lattes_url.nil? | 52 | + unless context.profile.academic_info.nil? || context.profile.academic_info.lattes_url.blank? |
53 | href = context.profile.academic_info.lattes_url | 53 | href = context.profile.academic_info.lattes_url |
54 | html_parser = Html_parser.new | 54 | html_parser = Html_parser.new |
55 | { | 55 | { |
plugins/lattes_curriculum/test/unit/academic_info_test.rb
0 → 100644
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +require "test_helper" | ||
2 | + | ||
3 | +class AcademicInfoTest < ActiveSupport::TestCase | ||
4 | + | ||
5 | + def setup | ||
6 | + @academic_info = AcademicInfo.new | ||
7 | + end | ||
8 | + | ||
9 | + should 'not ve invalid lattes url' do | ||
10 | + @academic_info.lattes_url = "http://softwarelivre.org/" | ||
11 | + assert !@academic_info.save | ||
12 | + end | ||
13 | + | ||
14 | + should 'accept blank lattes url' do | ||
15 | + @academic_info.lattes_url = "" | ||
16 | + assert @academic_info.save | ||
17 | + end | ||
18 | + | ||
19 | + should 'save with correct lattes url' do | ||
20 | + @academic_info.lattes_url = "http://lattes.cnpq.br/2193972715230641" | ||
21 | + assert @academic_info.save | ||
22 | + end | ||
23 | + | ||
24 | + | ||
25 | +end |
plugins/lattes_curriculum/test/unit/html_parser_test.rb
1 | +#!/bin/env ruby | ||
2 | +# encoding: utf-8 | ||
3 | + | ||
1 | require "test_helper" | 4 | require "test_helper" |
2 | 5 | ||
3 | class HtmlParserTest < ActiveSupport::TestCase | 6 | class HtmlParserTest < ActiveSupport::TestCase |
@@ -11,11 +14,12 @@ class HtmlParserTest < ActiveSupport::TestCase | @@ -11,11 +14,12 @@ class HtmlParserTest < ActiveSupport::TestCase | ||
11 | end | 14 | end |
12 | 15 | ||
13 | should 'be not nil the return get_html' do | 16 | should 'be not nil the return get_html' do |
14 | - assert_not_nil @parser.get_html("http://lattes.cnpq.br/2193972715230641") | 17 | + result = @parser.get_html("http://lattes.cnpq.br/2193972715230641") |
18 | + assert result.include?("Endereço para acessar este CV") | ||
15 | end | 19 | end |
16 | 20 | ||
17 | - should 'return a string the return get_html' do | ||
18 | - assert_equal "", @parser.get_html() | 21 | + should 'inform that lattes was not found' do |
22 | + assert_equal "Lattes not found. Please, make sure the informed URL is correct.", @parser.get_html("http://lattes.cnpq.br/123") | ||
19 | end | 23 | end |
20 | 24 | ||
21 | end | 25 | end |