iqvoc_skosxl 2.3.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +17 -7
  3. data/Gemfile.lock +200 -156
  4. data/README.md +8 -0
  5. data/app/assets/stylesheets/iqvoc_skosxl/{entity_select.css → entity_select.css.scss} +1 -1
  6. data/app/assets/stylesheets/iqvoc_skosxl/manifest.css.scss +1 -0
  7. data/app/assets/stylesheets/manifest.css.scss +3 -0
  8. data/app/controllers/labels/versions_controller.rb +33 -37
  9. data/app/controllers/labels_controller.rb +32 -31
  10. data/app/controllers/rdf_controller.rb +6 -7
  11. data/app/helpers/iqvoc_skosxl_helper.rb +2 -9
  12. data/app/helpers/labels_helper.rb +7 -9
  13. data/app/models/concept/skosxl/extension.rb +2 -4
  14. data/app/models/label/relation/base.rb +10 -12
  15. data/app/models/label/relation/skosxl/base.rb +5 -3
  16. data/app/models/label/skosxl/base.rb +44 -70
  17. data/app/models/label/skosxl/properties/literal_form.rb +23 -0
  18. data/app/models/label/skosxl/validations.rb +28 -0
  19. data/app/models/labeling/skosxl/alt_label.rb +0 -2
  20. data/app/models/labeling/skosxl/base.rb +22 -16
  21. data/app/models/labeling/skosxl/hidden_label.rb +1 -3
  22. data/app/models/labeling/skosxl/pref_label.rb +0 -2
  23. data/app/views/labels/_form.html.erb +12 -10
  24. data/app/views/labels/_sidebar.html.erb +1 -0
  25. data/app/views/labels/show_published.html.erb +2 -2
  26. data/app/views/labels/show_unpublished.html.erb +6 -6
  27. data/app/views/partials/label/relation/_edit_base.html.erb +1 -1
  28. data/app/views/partials/label/skosxl/_new_link_base.html.erb +5 -5
  29. data/app/views/partials/labeling/skosxl/_edit_base.html.erb +13 -13
  30. data/app/views/rdf/show_label.iqrdf +2 -2
  31. data/config/application.rb +4 -34
  32. data/config/boot.rb +3 -12
  33. data/config/engine.rb +2 -4
  34. data/config/environment.rb +3 -3
  35. data/config/initializers/backtrace_silencers.rb +7 -0
  36. data/config/initializers/cookies_serializer.rb +3 -0
  37. data/config/initializers/filter_parameter_logging.rb +4 -0
  38. data/config/initializers/inflections.rb +16 -0
  39. data/config/initializers/iqvoc.rb +49 -3
  40. data/config/initializers/mime_types.rb +4 -0
  41. data/config/initializers/session_store.rb +1 -1
  42. data/config/initializers/wrap_parameters.rb +14 -0
  43. data/config/routes.rb +16 -8
  44. data/config/secrets.yml +11 -0
  45. data/db/migrate/20110408121540_extend_label.rb +9 -12
  46. data/db/migrate/20110408123644_add_label_relations.rb +11 -13
  47. data/iqvoc_skosxl.gemspec +15 -14
  48. data/lib/iqvoc/skosxl/version.rb +1 -1
  49. data/lib/iqvoc/xllabel.rb +1 -5
  50. data/lib/iqvoc_skosxl.rb +13 -12
  51. data/test/{functional → controllers}/routing_test.rb +4 -6
  52. data/test/fixtures/hobbies.nt +11 -0
  53. data/test/integration/concept_label_language_test.rb +44 -45
  54. data/test/integration/dashboard_test.rb +10 -12
  55. data/test/integration/edit_labels_test.rb +12 -14
  56. data/test/integration/label_creation_test.rb +43 -0
  57. data/test/integration/labels_order_test.rb +17 -17
  58. data/test/integration_test_helper.rb +29 -0
  59. data/test/models/label_test.rb +54 -0
  60. data/test/models/skos_importer_test.rb +55 -0
  61. data/test/test_helper.rb +6 -12
  62. metadata +45 -24
  63. data/app/assets/stylesheets/iqvoc_skosxl/manifest.css +0 -3
  64. data/app/assets/stylesheets/manifest.css +0 -5
  65. data/config/initializers/secret_token.rb +0 -10
  66. data/config/initializers/secret_token.rb.template +0 -9
  67. data/test/factories.rb +0 -22
  68. data/test/unit/label_test.rb +0 -41
@@ -1,5 +1,5 @@
1
- # Load the rails application
1
+ # Load the Rails application.
2
2
  require File.expand_path('../application', __FILE__)
3
3
 
4
- # Initialize the rails application
5
- Iqvoc::SKOSXL::Application.initialize!
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -2,6 +2,52 @@ silence_warnings do
2
2
  Iqvoc::Label = nil
3
3
  end
4
4
 
5
- Iqvoc.searchable_class_names = { 'Labeling::SKOSXL::Base' => 'labels',
6
- 'Labeling::SKOSXL::PrefLabel' => 'pref_labels',
7
- 'Labeling::SKOSXL::AltLabel' => 'alt_labels' }
5
+ Iqvoc.searchable_class_names = {
6
+ 'Labeling::SKOSXL::Base' => 'labels',
7
+ 'Labeling::SKOSXL::PrefLabel' => 'pref_labels',
8
+ 'Labeling::SKOSXL::AltLabel' => 'alt_labels'
9
+ }
10
+
11
+ module SkosXlExporterExtensions
12
+ extend ActiveSupport::Concern
13
+ include LabelsHelper
14
+
15
+ def add_skos_xl_labels(document)
16
+ @logger.info 'Exporting xl labels...'
17
+
18
+ offset = 0
19
+ while true
20
+ labels = Iqvoc::XLLabel.base_class.published.published.order('id').limit(100).offset(offset)
21
+ limit = labels.size < 100 ? labels.size : 100
22
+ break if labels.size == 0
23
+
24
+ labels.each do |label|
25
+ render_label_rdf(document, label)
26
+ end
27
+
28
+ @logger.info "Labels #{offset+1}-#{offset+limit} exported."
29
+ offset += labels.size # Size is important!
30
+ end
31
+
32
+ @logger.info "Finished exporting xl labels (#{offset} labels exported)."
33
+ end
34
+ end
35
+
36
+ module Iqvoc
37
+ class SkosExporter
38
+ include SkosXlExporterExtensions
39
+ end
40
+ end
41
+
42
+ ActiveSupport.on_load :rdf_export_before_save do
43
+ add_skos_xl_labels(@document)
44
+ end
45
+
46
+ ActiveSupport.on_load :skos_importer do
47
+ Iqvoc::SkosImporter.prepend_first_level_object_classes(Iqvoc::XLLabel.base_class)
48
+ Iqvoc::SkosImporter.second_level_object_classes +=
49
+ [Label::SKOSXL::Properties::LiteralForm] +
50
+ Iqvoc::XLLabel.note_classes +
51
+ Iqvoc::XLLabel.relation_classes +
52
+ Iqvoc::XLLabel.additional_association_classes.keys
53
+ end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -1,6 +1,6 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
  if Iqvoc::SKOSXL.const_defined?(:Application)
3
- Iqvoc::SKOSXL::Application.config.session_store :cookie_store, :key => '_iqvoc_skosxl_session'
3
+ Iqvoc::SKOSXL::Application.config.session_store :cookie_store, key: '_iqvoc_skosxl_session'
4
4
  end
5
5
  # Use the database for sessions instead of the cookie-based default,
6
6
  # which shouldn't be used to store highly confidential information
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
data/config/routes.rb CHANGED
@@ -1,10 +1,18 @@
1
- Iqvoc.localized_routes << lambda do |routing|
2
- routing.resources :labels
1
+ Rails.application.routes.draw do
2
+ scope ':lang', constraints: Iqvoc.routing_constraint do
3
+ resources :labels
3
4
 
4
- routing.post "labels/versions/:origin/branch(.:format)" => "labels/versions#branch", :as => "label_versions_branch"
5
- routing.post "labels/versions/:origin/merge(.:format)" => "labels/versions#merge", :as => "label_versions_merge"
6
- routing.post "labels/versions/:origin/lock(.:format)" => "labels/versions#lock", :as => "label_versions_lock"
7
- routing.post "labels/versions/:origin/unlock(.:format)" => "labels/versions#unlock", :as => "label_versions_unlock"
8
- routing.post "labels/versions/:origin/to_review(.:format)" => "labels/versions#to_review", :as => "label_versions_to_review"
9
- routing.get "labels/versions/:origin/consistency_check(.:format)" => "labels/versions#consistency_check", :as => "label_versions_consistency_check"
5
+ post 'labels/versions/:origin/branch' => 'labels/versions#branch',
6
+ :as => 'label_versions_branch'
7
+ post 'labels/versions/:origin/merge' => 'labels/versions#merge',
8
+ :as => 'label_versions_merge'
9
+ post 'labels/versions/:origin/lock' => 'labels/versions#lock',
10
+ :as => 'label_versions_lock'
11
+ post 'labels/versions/:origin/unlock' => 'labels/versions#unlock',
12
+ :as => 'label_versions_unlock'
13
+ post 'labels/versions/:origin/to_review' => 'labels/versions#to_review',
14
+ :as => 'label_versions_to_review'
15
+ get 'labels/versions/:origin/consistency_check' => 'labels/versions#consistency_check',
16
+ :as => 'label_versions_consistency_check'
17
+ end
10
18
  end
@@ -0,0 +1,11 @@
1
+ development:
2
+ secret_key_base: development
3
+
4
+ test:
5
+ secret_key_base: test
6
+
7
+ production:
8
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
9
+
10
+ heroku:
11
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -1,14 +1,13 @@
1
1
  class ExtendLabel < ActiveRecord::Migration
2
-
3
2
  FIELDS = [
4
- {"rev" => {:type => :integer, :options => {:default => 1}}},
5
- {"published_version_id" => {:type => :integer}},
6
- {"published_at" => {:type => :date}},
7
- {"locked_by" => {:type => :integer}},
8
- {"expired_at" => {:type => :date}},
9
- {"follow_up" => {:type => :date}},
10
- {"to_review" => {:type => :boolean}},
11
- {"rdf_updated_at" => {:type => :date}}
3
+ {'rev' => {type: :integer, options: {default: 1}}},
4
+ {'published_version_id' => {type: :integer}},
5
+ {'published_at' => {type: :date}},
6
+ {'locked_by' => {type: :integer}},
7
+ {'expired_at' => {type: :date}},
8
+ {'follow_up' => {type: :date}},
9
+ {'to_review' => {type: :boolean}},
10
+ {'rdf_updated_at' => {type: :date}}
12
11
  ]
13
12
 
14
13
  def self.up
@@ -20,8 +19,7 @@ class ExtendLabel < ActiveRecord::Migration
20
19
  end
21
20
  end
22
21
 
23
- add_index :labels, "published_version_id", :name => "ix_labels_on_published_v" unless index_exists?(:labels, "published_version_id", :name => "ix_labels_on_published_v")
24
-
22
+ add_index :labels, 'published_version_id', name: 'ix_labels_on_published_v' unless index_exists?(:labels, 'published_version_id', name: 'ix_labels_on_published_v')
25
23
  end
26
24
 
27
25
  def self.down
@@ -33,5 +31,4 @@ class ExtendLabel < ActiveRecord::Migration
33
31
  end
34
32
  end
35
33
  end
36
-
37
34
  end
@@ -1,24 +1,22 @@
1
1
  class AddLabelRelations < ActiveRecord::Migration
2
-
3
2
  def self.up
4
- unless table_exists?("label_relations")
5
- create_table "label_relations", :force => true do |t|
6
- t.string "type"
7
- t.integer "domain_id"
8
- t.integer "range_id"
9
- t.datetime "created_at"
10
- t.datetime "updated_at"
3
+ unless table_exists?('label_relations')
4
+ create_table 'label_relations', force: true do |t|
5
+ t.string 'type'
6
+ t.integer 'domain_id'
7
+ t.integer 'range_id'
8
+ t.datetime 'created_at'
9
+ t.datetime 'updated_at'
11
10
  end
12
11
 
13
- add_index "label_relations", ["domain_id", "range_id", "type"], :name => "ix_label_rel_dom_rng_type"
14
- add_index "label_relations", ["type"], :name => "ix_label_relations_on_type"
12
+ add_index 'label_relations', ['domain_id', 'range_id', 'type'], name: 'ix_label_rel_dom_rng_type'
13
+ add_index 'label_relations', ['type'], name: 'ix_label_relations_on_type'
15
14
  end
16
15
  end
17
16
 
18
17
  def self.down
19
- if table_exists?("label_relations")
20
- drop_table("label_relations")
18
+ if table_exists?('label_relations')
19
+ drop_table('label_relations')
21
20
  end
22
21
  end
23
-
24
22
  end
data/iqvoc_skosxl.gemspec CHANGED
@@ -1,22 +1,23 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "iqvoc/skosxl/version"
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'iqvoc/skosxl/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "iqvoc_skosxl"
6
+ s.name = 'iqvoc_skosxl'
7
7
  s.version = Iqvoc::SKOSXL::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Robert Glaser", "Till Schulte-Coerne", "Frederik Dohr"]
10
- s.email = ["till.schulte-coerne@innoq.com"]
11
- s.homepage = "http://innoq.com"
12
- s.summary = "iQvoc SKOS-XL extension"
13
- s.description = ""
9
+ s.authors = ['Robert Glaser', 'Till Schulte-Coerne', 'Frederik Dohr']
10
+ s.email = ['till.schulte-coerne@innoq.com']
11
+ s.homepage = 'http://iqvoc.net'
12
+ s.summary = 'iQvoc SKOS-XL extension'
13
+ s.license = 'Apache License 2.0'
14
+ s.description = 'iQvoc - a SKOS(-XL) vocabulary management system built on the Semantic Web'
14
15
 
15
- s.add_dependency "iqvoc", "~> 4.3.0"
16
- s.add_dependency "bundler"
16
+ s.add_dependency 'iqvoc', '>= 4.5.0', '~> 4.6'
17
+ s.add_development_dependency 'bundler', '~> 1.6'
17
18
 
18
- s.files = %w(README.md Gemfile Gemfile.lock Rakefile iqvoc_skosxl.gemspec) + Dir.glob("{app,config,db,public,lib,test}/**/*")
19
- s.test_files = Dir.glob("{test}/**/*")
20
- s.executables = Dir.glob("{bin}/**/*")
21
- s.require_paths = ["lib"]
19
+ s.files = %w(README.md Gemfile Gemfile.lock Rakefile iqvoc_skosxl.gemspec) +
20
+ Dir.glob('{app,config,db,public,lib,test}/**/*')
21
+ s.test_files = s.files.grep(%r{^test/})
22
+ s.require_paths = ['lib']
22
23
  end
@@ -1,5 +1,5 @@
1
1
  module Iqvoc
2
2
  module SKOSXL
3
- VERSION = "2.3.1"
3
+ VERSION = '2.5.0'
4
4
  end
5
5
  end
data/lib/iqvoc/xllabel.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  module Iqvoc
2
-
3
2
  module XLLabel # These are the settings when using SKOS-XL
4
-
5
3
  Iqvoc.first_level_class_configuration_modules << self
6
4
 
7
5
  mattr_accessor :base_class_name,
@@ -20,7 +18,7 @@ module Iqvoc
20
18
 
21
19
  self.additional_association_class_names = {}
22
20
 
23
- self.view_sections = ["main", "concepts", "relations", "notes"]
21
+ self.view_sections = ['main', 'concepts', 'relations', 'notes']
24
22
 
25
23
  # Set this to true if you're having a migration which extends the labels table
26
24
  # and you want to be able to edit these fields.
@@ -54,7 +52,5 @@ module Iqvoc
54
52
  hash[class_name.constantize] = additional_association_class_names[class_name]
55
53
  end
56
54
  end
57
-
58
55
  end
59
-
60
56
  end
data/lib/iqvoc_skosxl.rb CHANGED
@@ -1,28 +1,29 @@
1
1
  module IqvocSKOSXL
2
-
3
- require File.join(File.dirname(__FILE__), '../config/engine') unless Iqvoc.const_defined?(:SKOSXL) && Iqvoc::SKOSXL.const_defined?(:Application)
2
+ unless Iqvoc.const_defined?(:SKOSXL) && Iqvoc::SKOSXL.const_defined?(:Application)
3
+ require File.join(File.dirname(__FILE__), '../config/engine')
4
+ end
4
5
 
5
6
  ActiveSupport.on_load(:after_iqvoc_config) do
6
7
  require 'iqvoc'
7
8
 
8
9
  Iqvoc.config do |cfg|
9
- prefix = "languages.further_labelings."
10
+ prefix = 'languages.further_labelings.'
10
11
  cfg.deregister_setting("#{prefix}Labeling::SKOS::AltLabel") # iQvoc core default
11
12
  cfg.register_settings({
12
- "title" => "iQvoc SKOS-XL",
13
- "#{prefix}Labeling::SKOSXL::AltLabel" => ["en", "de"]
13
+ 'title' => 'iQvoc SKOS-XL',
14
+ "#{prefix}Labeling::SKOSXL::AltLabel" => ['en', 'de']
14
15
  })
15
16
  end
16
17
 
17
- Iqvoc.rdf_namespaces[:skosxl] = "http://www.w3.org/2008/05/skos-xl#" unless Iqvoc.rdf_namespaces[:skosxl]
18
-
19
- Iqvoc.default_rdf_namespace_helper_methods << :iqvoc_skosxl_default_rdf_namespaces
20
-
21
- Iqvoc::Concept.include_module_names << "Concept::SKOSXL::Extension"
18
+ unless Iqvoc.rdf_namespaces[:skosxl]
19
+ Iqvoc.rdf_namespaces[:skosxl] = 'http://www.w3.org/2008/05/skos-xl#'
20
+ end
22
21
 
22
+ Iqvoc::Concept.include_module_names << 'Concept::SKOSXL::Extension'
23
23
  Iqvoc::Concept.pref_labeling_class_name = 'Labeling::SKOSXL::PrefLabel'
24
24
 
25
- # TODO Iqvoc.searchable_class_names = Iqvoc::Concept.labeling_class_names.keys + Iqvoc::Concept.note_class_names
25
+ # TODO
26
+ # Iqvoc.searchable_class_names = Iqvoc::Concept.labeling_class_names.keys +
27
+ # Iqvoc::Concept.note_class_names
26
28
  end
27
-
28
29
  end
@@ -4,16 +4,14 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '../test_helper')
4
4
  require 'iqvoc/rdfapi' # XXX: only required with Zeus
5
5
 
6
6
  class RoutingTest < ActionController::TestCase
7
-
8
7
  setup do
9
8
  @controller = LabelsController.new
10
- @label = Iqvoc::XLLabel.base_class.create :value => "foo",
11
- :language => "en", :published_at => Time.now
9
+ @label = Iqvoc::XLLabel.base_class.create value: 'foo',
10
+ language: 'en', published_at: Time.now
12
11
  end
13
12
 
14
- test "routing" do
15
- get :show, :lang => "en", :format => "html", :id => @label.origin
13
+ test 'routing' do
14
+ get :show, lang: 'en', format: 'html', id: @label.origin
16
15
  assert_response :success
17
16
  end
18
-
19
17
  end
@@ -0,0 +1,11 @@
1
+ <http://hobbies.com/computer_programming> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept> .
2
+ <http://hobbies.com/computer_programming> <http://www.w3.org/2004/02/skos/core#prefLabel> "Computer programming"@en .
3
+ <http://hobbies.com/computer_programming> <http://www.w3.org/2008/05/skos-xl#prefLabel> <http://hobbies.com/computer_programming-xl-preflabel-en> .
4
+ <http://hobbies.com/computer_programming> <http://www.w3.org/2008/05/skos-xl#altLabel> <http://hobbies.com/computer_programming-xl-altlabel-en> .
5
+ <http://hobbies.com/computer_programming-xl-preflabel-en> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
6
+ <http://hobbies.com/computer_programming-xl-preflabel-en> <http://www.w3.org/2008/05/skos-xl#literalForm> "Computer programming (used as xl:prefLabel)"@en .
7
+ <http://hobbies.com/computer_programming-xl-preflabel-en> <http://www.w3.org/2004/02/skos/core#definition> "Bla bla bla"@en .
8
+ <http://hobbies.com/computer_programming-xl-altlabel-en> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
9
+ <http://hobbies.com/computer_programming-xl-altlabel-en> <http://www.w3.org/2008/05/skos-xl#literalForm> "Computer programming (used as xl:altLabel)"@en .
10
+ <http://hobbies.com/computer_programming-xl-altlabel-en> <http://www.w3.org/2004/02/skos/core#definition> "Yadda yadda"@en .
11
+ <http://hobbies.com/computer_programming-xl-altlabel-en> <http://foo.bar/xl#test-relation> <http://hobbies.com/computer_programming-xl-preflabel-en> .
@@ -14,82 +14,81 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require Iqvoc::Engine.root.join('test', 'integration_test_helper')
17
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../integration_test_helper')
18
18
 
19
19
  class ConceptLabelLanguageTest < ActionDispatch::IntegrationTest
20
-
21
20
  setup do
22
21
  # create a few XL labels
23
22
  @labels = {}
24
23
  {
25
- "English" => "en",
26
- "Deutsch" => "de"
24
+ 'English' => 'en',
25
+ 'Deutsch' => 'de'
27
26
  }.each { |name, lang|
28
- @labels[name] = FactoryGirl.create(:xllabel, :origin => "_#{name}",
29
- :language => lang, :value => name, :published_at => Time.now)
27
+ @labels[name] = Iqvoc::XLLabel.base_class.create(
28
+ origin: "_#{name}", language: lang, value: name, published_at: Time.now)
30
29
  }
31
30
  end
32
31
 
33
- test "invalid alt label languages are rejected" do
34
- login("administrator")
32
+ test 'invalid alt label languages are rejected' do
33
+ login('administrator')
35
34
 
36
- visit new_concept_path(:lang => "de", :format => "html")
35
+ visit new_concept_path(lang: 'de', format: 'html')
37
36
  # NB: label language does not match relation language
38
- fill_in "labeling_skosxl_alt_labels_en",
39
- :with => "#{@labels["Deutsch"].origin},"
40
- click_button "Speichern"
37
+ fill_in 'labeling_skosxl_alt_labels_en',
38
+ with: "#{@labels['Deutsch'].origin},"
39
+ click_button 'Speichern'
41
40
 
42
- assert page.has_css?(".alert-error")
43
- assert page.has_css?("#new_concept")
41
+ assert page.has_css?('.alert-danger')
42
+ assert page.has_css?('#new_concept')
44
43
  assert page.source.include?( # XXX: page.has_content? didn't work
45
- I18n.t("txt.controllers.versioned_concept.label_error") % "Deutsch")
44
+ I18n.t('txt.controllers.versioned_concept.label_error') % 'Deutsch')
46
45
 
47
46
  # ensure concept was not saved
48
- visit dashboard_path(:lang => "de", :format => "html")
49
- assert page.has_no_css?("td")
47
+ visit dashboard_path(lang: 'de', format: 'html')
48
+ assert page.has_no_css?('td')
50
49
  end
51
50
 
52
- test "invalid pref label languages are rejected during creation" do
53
- login("administrator")
51
+ test 'invalid pref label languages are rejected during creation' do
52
+ login('administrator')
54
53
 
55
- visit new_concept_path(:lang => "de", :format => "html")
54
+ visit new_concept_path(lang: 'de', format: 'html')
56
55
  # NB: label language does not match relation language
57
- fill_in "labeling_skosxl_pref_labels_en",
58
- :with => "#{@labels["Deutsch"].origin},"
59
- click_button "Speichern"
56
+ fill_in 'labeling_skosxl_pref_labels_en',
57
+ with: "#{@labels['Deutsch'].origin},"
58
+ click_button 'Speichern'
60
59
 
61
- assert page.has_css?(".alert-error")
62
- assert page.has_css?("#new_concept")
60
+ assert page.has_css?('.alert-danger')
61
+ assert page.has_css?('#new_concept')
63
62
  assert page.source.include?( # XXX: page.has_content? didn't work
64
- I18n.t("txt.controllers.versioned_concept.label_error") % "Deutsch")
63
+ I18n.t('txt.controllers.versioned_concept.label_error') % 'Deutsch')
65
64
 
66
65
  # ensure concept was not saved
67
- visit dashboard_path(:lang => "de", :format => "html")
68
- assert page.has_no_css?("td")
66
+ visit dashboard_path(lang: 'de', format: 'html')
67
+ assert page.has_no_css?('td')
69
68
  end
70
69
 
71
- test "invalid label languages are rejected during update" do
72
- login("administrator")
70
+ test 'invalid label languages are rejected during update' do
71
+ login('administrator')
73
72
 
74
73
  # create, then edit concept
75
- visit new_concept_path(:lang => "de", :format => "html")
76
- click_button "Speichern"
77
- visit dashboard_path(:lang => "de", :format => "html")
78
- page.find("td a").click
79
- page.click_link_or_button "In Bearbeitung versetzen"
74
+ visit new_concept_path(lang: 'de', format: 'html')
75
+ click_button 'Speichern'
76
+ visit dashboard_path(lang: 'de', format: 'html')
77
+ page.find('td a').click
78
+ page.click_link_or_button 'In Bearbeitung versetzen'
80
79
 
81
80
  # NB: label languages do not match relation languages
82
- fill_in "labeling_skosxl_pref_labels_en",
83
- :with => "#{@labels["Deutsch"].origin},"
84
- fill_in "labeling_skosxl_alt_labels_de",
85
- :with => "#{@labels["English"].origin},"
86
- click_button "Speichern"
87
-
88
- assert page.has_css?(".alert-error")
89
- assert page.has_css?("#edit_concept")
81
+ fill_in 'labeling_skosxl_pref_labels_en',
82
+ with: "#{@labels['Deutsch'].origin},"
83
+ fill_in 'labeling_skosxl_alt_labels_de',
84
+ with: "#{@labels['English'].origin},"
85
+ click_button 'Speichern'
86
+
87
+ assert page.has_css?('.alert-danger')
88
+ assert page.has_css?('#edit_concept')
90
89
  assert page.source.include?( # XXX: page.has_content? didn't work
91
- I18n.t("txt.controllers.versioned_concept.label_error") % "English")
90
+ I18n.t('txt.controllers.versioned_concept.label_error') % 'English')
92
91
  assert page.source.include?( # XXX: page.has_content? didn't work
93
- I18n.t("txt.controllers.versioned_concept.label_error") % "Deutsch")
92
+ I18n.t('txt.controllers.versioned_concept.label_error') % 'Deutsch')
94
93
  end
95
94
  end
@@ -14,31 +14,29 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require 'test_helper'
18
- require Iqvoc::Engine.root.join('test', 'integration_test_helper')
17
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../integration_test_helper')
19
18
 
20
19
  class DashboardTest < ActionDispatch::IntegrationTest
21
-
22
20
  setup do
23
- @label = FactoryGirl.create(:xllabel, :published_at => nil)
21
+ @label = Iqvoc::XLLabel.base_class.create(
22
+ language: 'en', value: 'Forest', published_at: nil)
24
23
  end
25
24
 
26
- test "labels appearing in dashboard" do
25
+ test 'labels appearing in dashboard' do
27
26
  assert !@label.published?
28
27
  login('administrator')
29
28
 
30
- visit dashboard_path(:lang => 'de', :format => 'html')
29
+ visit dashboard_path(lang: 'de', format: 'html')
31
30
  assert page.has_link?(@label.value.to_s), "Couldn't find Label link '#{@label.value.to_s}' in dashboards concepts + labels list"
32
31
  click_link_or_button(@label.value.to_s)
33
- assert_equal label_path(@label, :lang => 'de', :format => 'html'), current_path
32
+ assert_equal label_path(@label, lang: 'de', format: 'html'), current_path
34
33
  end
35
34
 
36
- test "new label link in dashboard" do
35
+ test 'new label link in dashboard' do
37
36
  login('administrator')
38
37
 
39
- visit dashboard_path(:lang => 'de', :format => 'html')
40
- click_link_or_button("de")
41
- assert_equal new_label_path(:lang => 'de', :format => 'html'), current_path
38
+ visit dashboard_path(lang: 'de', format: 'html')
39
+ click_link_or_button('de')
40
+ assert_equal new_label_path(lang: 'de', format: 'html'), current_path
42
41
  end
43
-
44
42
  end
@@ -14,28 +14,26 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
- require 'test_helper'
18
- require Iqvoc::Engine.root.join('test', 'integration_test_helper')
17
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../integration_test_helper')
19
18
 
20
19
  class EditConceptsTest < ActionDispatch::IntegrationTest
21
-
22
20
  setup do
23
- @label = FactoryGirl.create(:xllabel)
21
+ @label = Iqvoc::XLLabel.base_class.create(
22
+ language: 'en', value: 'Forest', published_at: 3.days.ago)
24
23
  end
25
24
 
26
- test "Create a new concept version" do
25
+ test 'Create a new concept version' do
27
26
  assert @label.published?
28
27
  login('administrator')
29
28
 
30
- visit label_path(@label, :lang => 'de', :format => 'html')
31
- assert page.has_button?("Neue Version erstellen"), "Button 'Neue Version erstellen' is missing on labels#show"
32
- click_link_or_button("Neue Version erstellen")
33
- assert_equal edit_label_path(@label, :lang => 'de', :format => 'html'), current_path
29
+ visit label_path(@label, lang: 'de', format: 'html')
30
+ assert page.has_button?('Neue Version erstellen'), "Button 'Neue Version erstellen' is missing on labels#show"
31
+ click_link_or_button('Neue Version erstellen')
32
+ assert_equal edit_label_path(@label, lang: 'de', format: 'html'), current_path
34
33
 
35
- visit label_path(@label, :lang => 'de', :format => 'html')
36
- assert !page.has_button?("Neue Version erstellen"), "Button 'Neue Version erstellen' although there already is a new version"
37
- assert page.has_link?("Vorschau der Version in Bearbeitung"), "Link 'Vorschau der Version in Bearbeitung' is missing"
38
- click_link_or_button("Vorschau der Version in Bearbeitung")
34
+ visit label_path(@label, lang: 'de', format: 'html')
35
+ assert !page.has_button?('Neue Version erstellen'), "Button 'Neue Version erstellen' although there already is a new version"
36
+ assert page.has_link?('Vorschau der Version in Bearbeitung'), "Link 'Vorschau der Version in Bearbeitung' is missing"
37
+ click_link_or_button('Vorschau der Version in Bearbeitung')
39
38
  end
40
-
41
39
  end