Commit 84a50fe97684117607766b87cb36b5619080458d
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'virtuoso_integration' into stable
Showing
3 changed files
with
22 additions
and
14 deletions
Show diff stats
plugins/virtuoso/lib/virtuoso_plugin/triples_template.rb
... | ... | @@ -28,7 +28,7 @@ class VirtuosoPlugin::TriplesTemplate < Article |
28 | 28 | def to_html(options = {}) |
29 | 29 | article = self |
30 | 30 | proc do |
31 | - render :file => 'content_viewer/triples_template', :locals => {:article => article} | |
31 | + render :file => 'content_viewer/triples_template', :locals => {:article => article, :page => params[:npage]} | |
32 | 32 | end |
33 | 33 | end |
34 | 34 | |
... | ... | @@ -36,11 +36,17 @@ class VirtuosoPlugin::TriplesTemplate < Article |
36 | 36 | @plugin ||= VirtuosoPlugin.new(self) |
37 | 37 | end |
38 | 38 | |
39 | + attr_reader :results | |
40 | + | |
39 | 41 | def template_content(page=1) |
40 | 42 | begin |
41 | - results = plugin.virtuoso_readonly_client.query(query).paginate({:per_page => per_page, :page => page}) | |
43 | + @results ||= plugin.virtuoso_readonly_client.query(query).paginate({:per_page => per_page, :page => page}) | |
42 | 44 | liquid_template = Liquid::Template.parse(template) |
43 | - rendered_template = liquid_template.render('results' => results) | |
45 | + rendered_template = liquid_template.render('results' => results, | |
46 | + 'total_pages' => results.total_pages, | |
47 | + 'current_page' => results.current_page, | |
48 | + 'per_page' => results.per_page, | |
49 | + 'total_entries' => results.total_entries) | |
44 | 50 | transform_html(rendered_template) |
45 | 51 | rescue => ex |
46 | 52 | logger.info ex.to_s | ... | ... |
plugins/virtuoso/test/unit/dspace_harvest_test.rb
... | ... | @@ -7,7 +7,7 @@ class DspaceHarvestTest < ActiveSupport::TestCase |
7 | 7 | end |
8 | 8 | |
9 | 9 | attr_reader :environment |
10 | - | |
10 | + | |
11 | 11 | def mock_settings |
12 | 12 | { :virtuoso_uri=>"http://virtuoso.noosfero.com", |
13 | 13 | :virtuoso_username=>"username", |
... | ... | @@ -20,44 +20,44 @@ class DspaceHarvestTest < ActiveSupport::TestCase |
20 | 20 | {"dspace_uri"=>"http://dspace3.noosfero.com"} |
21 | 21 | ] |
22 | 22 | } |
23 | - end | |
23 | + end | |
24 | 24 | |
25 | 25 | should 'create delayed job when start' do |
26 | - harvest = VirtuosoPlugin::DspaceHarvest.new(environment) | |
26 | + harvest = VirtuosoPlugin::DspaceHarvest.new(environment, "http://dspace1.noosfero.com") | |
27 | 27 | assert !harvest.find_job.present? |
28 | 28 | harvest.start |
29 | 29 | assert harvest.find_job.present? |
30 | 30 | end |
31 | 31 | |
32 | 32 | should 'not duplicate harvest job' do |
33 | - harvest = VirtuosoPlugin::DspaceHarvest.new(environment) | |
33 | + harvest = VirtuosoPlugin::DspaceHarvest.new(environment, "http://dspace1.noosfero.com") | |
34 | 34 | assert_difference "harvest.find_job.count", 1 do |
35 | 35 | 5.times { harvest.start } |
36 | 36 | end |
37 | 37 | end |
38 | - | |
38 | + | |
39 | 39 | should 'harvest all dspaces from start' do |
40 | 40 | VirtuosoPlugin::DspaceHarvest.harvest_all(environment, true) |
41 | 41 | end |
42 | - | |
42 | + | |
43 | 43 | should 'try to harvest all dspaces from start without any setting' do |
44 | 44 | VirtuosoPlugin::DspaceHarvest.harvest_all(environment, true) |
45 | 45 | end |
46 | - | |
46 | + | |
47 | 47 | should 'try to harvest all dspaces from start with mock configuration' do |
48 | 48 | @settings = Noosfero::Plugin::Settings.new(environment, VirtuosoPlugin, mock_settings) |
49 | 49 | @settings.save! |
50 | 50 | VirtuosoPlugin::DspaceHarvest.harvest_all(environment, true) |
51 | 51 | end |
52 | - | |
52 | + | |
53 | 53 | should 'try to harvest all dspaces without any setting' do |
54 | 54 | VirtuosoPlugin::DspaceHarvest.harvest_all(environment, false) |
55 | 55 | end |
56 | - | |
56 | + | |
57 | 57 | should 'try to harvest all dspaces with mock configuration' do |
58 | 58 | @settings = Noosfero::Plugin::Settings.new(environment, VirtuosoPlugin, mock_settings) |
59 | 59 | @settings.save! |
60 | 60 | VirtuosoPlugin::DspaceHarvest.harvest_all(environment, false) |
61 | - end | |
61 | + end | |
62 | 62 | |
63 | 63 | end | ... | ... |
plugins/virtuoso/views/content_viewer/triples_template.html.erb