iqvoc 3.5.6 → 3.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/CHANGELOG.md +9 -0
  2. data/Gemfile +3 -2
  3. data/Gemfile.lock +71 -65
  4. data/README.md +5 -4
  5. data/app/assets/javascripts/framework.js +1 -1
  6. data/app/assets/javascripts/iqvoc/entityselect.js.erb +20 -19
  7. data/app/assets/javascripts/iqvoc/entityselect_qualified.js.erb +45 -0
  8. data/app/assets/javascripts/iqvoc/iqvoc.js +2 -2
  9. data/app/assets/javascripts/iqvoc/manifest.js +1 -0
  10. data/app/assets/stylesheets/framework.css +1 -1
  11. data/app/assets/stylesheets/iqvoc/iqvoc.css.erb +28 -22
  12. data/app/controllers/collections/hierarchical_controller.rb +2 -2
  13. data/app/controllers/collections_controller.rb +0 -1
  14. data/app/controllers/concepts/alphabetical_controller.rb +0 -1
  15. data/app/controllers/concepts/hierarchical_controller.rb +0 -1
  16. data/app/controllers/concepts/untranslated_controller.rb +0 -1
  17. data/app/controllers/concepts_controller.rb +0 -1
  18. data/app/controllers/instance_configuration_controller.rb +2 -2
  19. data/app/controllers/pages_controller.rb +0 -1
  20. data/app/controllers/rdf_controller.rb +0 -2
  21. data/app/controllers/search_results_controller.rb +0 -1
  22. data/app/controllers/user_sessions_controller.rb +5 -4
  23. data/app/helpers/application_helper.rb +8 -4
  24. data/app/helpers/widget_helper.rb +39 -0
  25. data/app/models/collection/base.rb +4 -0
  26. data/app/models/concept/base.rb +59 -10
  27. data/app/models/concept/relation/base.rb +20 -0
  28. data/app/models/concept/relation/reverse_relation_extension.rb +4 -3
  29. data/app/models/concept/skos/base.rb +1 -1
  30. data/app/views/collections/_collection.html.erb +5 -0
  31. data/app/views/concepts/_visualization.html.erb +1 -1
  32. data/app/views/errors/access_denied.html.erb +6 -2
  33. data/app/views/layouts/_controls.html.erb +1 -1
  34. data/app/views/layouts/application.html.erb +2 -3
  35. data/app/views/pages/about.html.erb +2 -0
  36. data/app/views/partials/concept/relation/_base.html.erb +1 -1
  37. data/app/views/partials/concept/relation/_edit_base.html.erb +2 -5
  38. data/app/views/partials/concept/relation/_edit_ranked.html.erb +13 -0
  39. data/app/views/partials/concept/relation/_ranked.html.erb +12 -0
  40. data/app/views/partials/concept/relation/skos/broader/_mono.html.erb +1 -1
  41. data/app/views/partials/note/_base.html.erb +1 -1
  42. data/app/views/user_sessions/_form.html.erb +10 -0
  43. data/app/views/user_sessions/new.html.erb +1 -9
  44. data/config/application.rb +4 -1
  45. data/config/database.yml +8 -0
  46. data/config/initializers/heroku.rb +24 -0
  47. data/config/initializers/iqvoc.rb +2 -2
  48. data/config/locales/activerecord.en.yml +1 -1
  49. data/config/locales/de.yml +1 -3
  50. data/config/locales/en.yml +1 -3
  51. data/db/migrate/20101208103531_add_type_to_collection_contents.rb +0 -2
  52. data/db/migrate/20120326102037_add_rank_to_concept_relations.rb +5 -0
  53. data/db/schema.rb +12 -1
  54. data/lib/iqvoc/ability.rb +3 -1
  55. data/lib/iqvoc/controller_extensions.rb +12 -29
  56. data/lib/iqvoc/environments/production.rb +2 -0
  57. data/lib/iqvoc/environments/test.rb +0 -3
  58. data/lib/iqvoc/{data_helper.rb → inline_data_helper.rb} +1 -3
  59. data/lib/iqvoc/maker.rb +2 -1
  60. data/lib/iqvoc/origin.rb +23 -24
  61. data/lib/iqvoc/rankable.rb +34 -0
  62. data/lib/iqvoc/version.rb +1 -1
  63. data/test/factories.rb +1 -1
  64. data/test/integration/alphabetical_test.rb +2 -1
  65. data/test/integration/authentication_test.rb +1 -1
  66. data/test/integration/browse_concepts_and_labels_test.rb +2 -1
  67. data/test/integration/concept_scheme_test.rb +1 -1
  68. data/test/integration/edit_concepts_test.rb +1 -1
  69. data/test/integration/instance_configuration_test.rb +1 -1
  70. data/test/integration/search_test.rb +6 -5
  71. data/test/integration/tree_test.rb +1 -1
  72. data/test/integration/untranslated_test.rb +2 -1
  73. data/test/integration_test_helper.rb +0 -29
  74. data/test/unit/concept_test.rb +17 -6
  75. data/test/unit/hygiene_test.rb +15 -5
  76. data/test/unit/origin_test.rb +7 -4
  77. data/vendor/assets/javascripts/{jquery-ui-1.8.16.custom.js → jquery-ui-1.8.20.custom.js} +146 -71
  78. data/vendor/assets/stylesheets/{jquery-ui-1.8.16.custom.css → jquery-ui-1.8.20.custom.css} +16 -19
  79. metadata +32 -27
  80. data/app/views/errors/multiple_choices.html.erb +0 -11
  81. data/lib/iqvoc/rdf_helper.rb +0 -67
  82. data/lib/ojdbc14.jar +0 -0
data/lib/iqvoc/ability.rb CHANGED
@@ -11,6 +11,7 @@ module Iqvoc
11
11
 
12
12
  if user # Every logged in user ...
13
13
  can :use, :dashboard
14
+ can :destroy, UserSession
14
15
 
15
16
  if user.owns_role?(:editor) || user.owns_role?(:publisher) || user.owns_role?(:administrator) # Editors and above ...
16
17
  can :manage, ::Collection::Base
@@ -36,7 +37,8 @@ module Iqvoc
36
37
  can :full_export, ::Concept::Base
37
38
  can :import, ::Concept::Base
38
39
  end
39
-
40
+ else # no user
41
+ can :create, UserSession
40
42
  end
41
43
 
42
44
  end
@@ -7,7 +7,6 @@ module Iqvoc
7
7
  included do
8
8
  prepend_before_filter :set_locale
9
9
  before_filter :ensure_extension
10
- before_filter :require_user
11
10
 
12
11
  helper :all
13
12
  helper_method :current_user_session, :current_user, :concept_widget_data, :collection_widget_data, :label_widget_data
@@ -26,7 +25,7 @@ module Iqvoc
26
25
 
27
26
  # Force an extension to every url. (LOD)
28
27
  def ensure_extension
29
- unless params[:format] || request.method != "GET"
28
+ unless params[:format] || !request.get?
30
29
  flash.keep
31
30
  redirect_to url_for(params.merge(:format => (request.format && request.format.symbol) || :html))
32
31
  end
@@ -34,17 +33,15 @@ module Iqvoc
34
33
 
35
34
  def handle_access_denied(exception)
36
35
  @exception = exception
36
+ @status = current_user ? 403 : 401
37
+ @user_session = UserSession.new if @status == 401
38
+ @return_url = request.fullpath
37
39
  respond_to do |format|
38
- format.html { render :template => 'errors/access_denied', :status => 403 }
39
- format.any { head 404 }
40
+ format.html { render :template => 'errors/access_denied', :status => @status }
41
+ format.any { head @status }
40
42
  end
41
43
  end
42
44
 
43
- def handle_multiple_choices(exception)
44
- @exception = exception
45
- render :template => 'errors/multiple_choices', :status => :multiple_choices
46
- end
47
-
48
45
  def handle_not_found(exception)
49
46
  @exception = exception
50
47
  SearchResultsController.prepare_basic_variables(self)
@@ -65,11 +62,13 @@ module Iqvoc
65
62
  end
66
63
  end
67
64
 
68
- def concept_widget_data(concept)
69
- {
65
+ def concept_widget_data(concept, rank = nil)
66
+ data = {
70
67
  :id => concept.origin,
71
68
  :name => concept.pref_label.value.to_s + (concept.additional_info ? " (#{concept.additional_info })" : "")
72
69
  }
70
+ data[:rank] = rank if rank
71
+ data
73
72
  end
74
73
 
75
74
  def collection_widget_data(collection)
@@ -92,27 +91,11 @@ module Iqvoc
92
91
  end
93
92
 
94
93
  def current_user_session
95
- return @current_user_session if defined?(@current_user_session)
96
- @current_user_session = UserSession.find
94
+ @current_user_session ||= UserSession.find
97
95
  end
98
96
 
99
97
  def current_user
100
- return @current_user if defined?(@current_user)
101
- @current_user = current_user_session && current_user_session.user
102
- end
103
-
104
- # TODO: Don't require an user (this is skipped in nearly every controller).
105
- # Use Abilitys instead and handle the AccessDeniedException: (#handle_access_denied)
106
- # * User logged in: Exception!
107
- # * User not logged in: Redirect to login path!
108
- # Don't forget to delete this method and all the /.*before_filter :require_user/
109
- # statements in the controllers.
110
- def require_user
111
- unless current_user
112
- flash[:error] = I18n.t("txt.controllers.application.login_required")
113
- redirect_to new_user_session_url(:back_to => request.fullpath)
114
- return false
115
- end
98
+ @current_user ||= current_user_session && current_user_session.user
116
99
  end
117
100
 
118
101
  end
@@ -14,6 +14,8 @@ module Iqvoc::Environments
14
14
  # Specifies the header that your server uses for sending files
15
15
  config.action_dispatch.x_sendfile_header = "X-Sendfile"
16
16
 
17
+ config.autoflush_log = true
18
+
17
19
  # For nginx:
18
20
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
19
21
 
@@ -32,9 +32,6 @@ module Iqvoc::Environments
32
32
  # like if you have constraints or database-specific column types
33
33
  # config.active_record.schema_format = :sql
34
34
 
35
- # Print deprecation notices to the stderr
36
- config.active_support.deprecation = :stderr
37
-
38
35
  # Configure static asset server for tests with Cache-Control for performance
39
36
  config.serve_static_assets = true
40
37
  config.static_cache_control = "public, max-age=3600"
@@ -15,9 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module Iqvoc
18
- class InlineDataHelper # TODO: Module should have the same name as the file! "Helper" has an other meaning in Rails. I would suggest "InlineData".
19
-
20
- # TODO: Non class constants should be written UPPER_CASE
18
+ module InlineDataHelper
21
19
 
22
20
  # delimiters for strings representing a list of values
23
21
  Joiner = ", "
data/lib/iqvoc/maker.rb CHANGED
@@ -122,7 +122,8 @@ module Iqvoc
122
122
  }
123
123
  attributes = defaults.merge(attributes)
124
124
 
125
- label = Iqvoc::XLLabel.base_class.create!(attributes)
125
+ klass = Iqvoc::XLLabel rescue Iqvoc::Label # FIXME: breaks encapsulation (hard-coded iqvoc_skosxl dependency)
126
+ label = klass.base_class.create!(attributes)
126
127
 
127
128
  inflectionals.each { |inf|
128
129
  label.inflectionals.create!(:value => inf)
data/lib/iqvoc/origin.rb CHANGED
@@ -22,7 +22,7 @@
22
22
  # Just calling "to_s" runs all registered filters.
23
23
  # Prepending "to_s" with a specific filter method only runs the given filter:
24
24
  # Iqvoc::Origin.new("fübar").replace_umlauts.to_s # => "fuebar"
25
- #
25
+ #
26
26
  # Adding your own filter classes is easy:
27
27
  # class FoobarStripper < Iqvoc::Origin::Filters::GenericFilter
28
28
  # def call(obj, str)
@@ -31,7 +31,7 @@
31
31
  # end
32
32
  # end
33
33
  # Iqvoc::Origin::Filters.register(:strip_foobars, FoobarStripper)
34
- #
34
+ #
35
35
  module Iqvoc
36
36
  class Origin
37
37
  module Filters
@@ -41,7 +41,7 @@ module Iqvoc
41
41
  # afterwards: make sure to pass "obj" and your modified "str" to "run()"
42
42
  run(obj, str)
43
43
  end
44
-
44
+
45
45
  def run(obj, str)
46
46
  obj.tap do |obj|
47
47
  obj.value = str
@@ -58,7 +58,7 @@ module Iqvoc
58
58
  gsub(/ä/, 'ae').
59
59
  gsub(/ü/, 'ue').
60
60
  gsub(/ß/, 'ss')
61
-
61
+
62
62
  run(obj, str)
63
63
  end
64
64
  end
@@ -72,60 +72,59 @@ module Iqvoc
72
72
  run(obj, str)
73
73
  end
74
74
  end
75
-
75
+
76
76
  class SpecialCharReplacer < GenericFilter
77
77
  def call(obj, str)
78
78
  str = str.gsub(/[(\[:]/, "--").
79
79
  gsub(/[)\]'""]/, "").
80
80
  gsub(/[,\.\/&;]/, '-')
81
-
81
+
82
82
  run(obj, str)
83
83
  end
84
84
  end
85
-
85
+
86
86
  class LeadingNumberHandler < GenericFilter
87
87
  def call(obj, str)
88
88
  str = str.gsub(/^[0-9].*$/) do |match|
89
89
  "_#{match}"
90
90
  end
91
-
91
+
92
92
  run(obj, str)
93
93
  end
94
94
  end
95
-
96
- @filters = {
97
- :replace_umlauts => UmlautReplacer,
98
- :replace_whitespace => WhitespaceReplacer,
99
- :replace_special_chars => SpecialCharReplacer,
100
- :handle_leading_numbers => LeadingNumberHandler
101
- }
102
-
95
+
96
+ @filters = ActiveSupport::OrderedHash.new
97
+ @filters[:replace_umlauts] = UmlautReplacer
98
+ @filters[:replace_whitespace] = WhitespaceReplacer
99
+ @filters[:replace_special_chars] = SpecialCharReplacer
100
+ @filters[:handle_leading_numbers] = LeadingNumberHandler
101
+
103
102
  def self.register(name, klass)
104
103
  @filters[name.to_sym] = klass
105
104
  end
106
-
105
+
107
106
  def self.registered
108
107
  @filters
109
108
  end
110
109
  end
111
-
110
+
112
111
  attr_accessor :initial_value, :value, :filters
113
-
112
+
114
113
  def initialize(value)
115
114
  self.initial_value = value.to_s
116
115
  self.value = initial_value
117
116
  end
118
-
117
+
119
118
  def touched?
120
119
  value != initial_value
121
120
  end
122
-
121
+
123
122
  def run_filters!
124
123
  Filters.registered.each do |key, filter_class|
125
124
  filter_class.new.call(self, value)
126
125
  end
127
126
  end
128
-
127
+
129
128
  def method_missing(meth, *args)
130
129
  if Filters.registered.keys.include?(meth.to_sym)
131
130
  Filters.registered[meth.to_sym].new.call(self, value)
@@ -133,13 +132,13 @@ module Iqvoc
133
132
  super
134
133
  end
135
134
  end
136
-
135
+
137
136
  def to_s
138
137
  return value if touched?
139
138
  run_filters!
140
139
  value
141
140
  end
142
-
141
+
143
142
  def inspect
144
143
  "#<Iqvoc::Origin:0x%08x>" % object_id
145
144
  end
@@ -0,0 +1,34 @@
1
+ require 'active_support/concern'
2
+
3
+ module Iqvoc
4
+ module Rankable
5
+ extend ActiveSupport::Concern
6
+
7
+ def build_rdf(document, subject)
8
+ super
9
+ if self.class.rankable?
10
+ predicate = "ranked#{rdf_predicate.titleize}"
11
+
12
+ subject.Schema.build_predicate(predicate) do |blank_node|
13
+ blank_node.Schema.relationWeight(rank)
14
+ blank_node.Schema.relationTarget(IqRdf.build_uri(target.origin))
15
+ end
16
+ end
17
+ end
18
+
19
+ module ClassMethods
20
+ def rankable?
21
+ true
22
+ end
23
+
24
+ def partial_name(obj)
25
+ 'partials/concept/relation/ranked'
26
+ end
27
+
28
+ def edit_partial_name(obj)
29
+ 'partials/concept/relation/edit_ranked'
30
+ end
31
+ end
32
+
33
+ end
34
+ end
data/lib/iqvoc/version.rb CHANGED
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module Iqvoc
18
- VERSION = "3.5.6"
18
+ VERSION = "3.5.7"
19
19
  end
data/test/factories.rb CHANGED
@@ -38,7 +38,7 @@ FactoryGirl.define do
38
38
  FactoryGirl.create(:pref_labeling, :target => FactoryGirl.create(:pref_label, :value => 'Some narrower relation'))
39
39
  ])
40
40
  }
41
- rel.after_create { |new_relation| Factory(:stupid_broader_relation, :owner => new_relation.target, :target => new_relation.owner) }
41
+ rel.after_create { |new_relation| FactoryGirl.create(:stupid_broader_relation, :owner => new_relation.target, :target => new_relation.owner) }
42
42
  end
43
43
 
44
44
  factory :pref_labeling, :class => Iqvoc::Concept.pref_labeling_class do |lab|
@@ -24,7 +24,8 @@ class AlphabeticalConceptsTest < ActionDispatch::IntegrationTest
24
24
  ].map do |hsh|
25
25
  labelings = []
26
26
  hsh.each do |lang, val|
27
- labelings << Factory(:pref_labeling, :target => Factory(:pref_label, :language => lang, :value => val))
27
+ labelings << FactoryGirl.create(:pref_labeling,
28
+ :target => FactoryGirl.create(:pref_label, :language => lang, :value => val))
28
29
  end
29
30
  FactoryGirl.create(:concept, :pref_labelings => labelings)
30
31
  end
@@ -21,7 +21,7 @@ class AuthenticationTest < ActionDispatch::IntegrationTest
21
21
  test "sign in" do
22
22
  user
23
23
  visit dashboard_path(:lang => :de)
24
- assert page.has_content?("Sie müssen angemeldet sein, um diese Seite aufzurufen")
24
+ assert page.has_content?("Keine Berechtigung")
25
25
  visit new_user_session_path(:lang => :de)
26
26
  fill_in "E-Mail", :with => user.email
27
27
  fill_in "Passwort", :with => user.password
@@ -25,7 +25,8 @@ class BrowseConceptsAndLabelsTest < ActionDispatch::IntegrationTest
25
25
  [:de, "Baum"],
26
26
  [:de, "Forst"]
27
27
  ].map { |lang, text|
28
- FactoryGirl.create(:concept, :pref_labelings => [Factory(:pref_labeling, :target => Factory(:pref_label, :language => lang, :value => text))])
28
+ FactoryGirl.create(:concept, :pref_labelings => [FactoryGirl.create(:pref_labeling,
29
+ :target => FactoryGirl.create(:pref_label, :language => lang, :value => text))])
29
30
  }
30
31
  end
31
32
 
@@ -19,7 +19,7 @@ require 'integration_test_helper'
19
19
  class ConceptSchemeTest < ActionDispatch::IntegrationTest
20
20
 
21
21
  setup do
22
- @concept = Factory(:concept, :broader_relations => [])
22
+ @concept = FactoryGirl.create(:concept, :broader_relations => [])
23
23
  end
24
24
 
25
25
  test "list top concepts in rdf scheme" do
@@ -19,7 +19,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '../integration_test
19
19
  class EditConceptsTest < ActionDispatch::IntegrationTest
20
20
 
21
21
  setup do
22
- @concept = Factory(:concept)
22
+ @concept = FactoryGirl.create(:concept)
23
23
  end
24
24
 
25
25
  test "Create a new concept version" do
@@ -24,7 +24,7 @@ class InstanceConfigurationTest < ActionDispatch::IntegrationTest
24
24
 
25
25
  # guest
26
26
  visit uri
27
- assert_equal "/en/user_session/new.html", page.current_path
27
+ assert page.has_content?("No permission")
28
28
 
29
29
  ["reader", "editor", "publisher"].each do |role|
30
30
  login role
@@ -25,15 +25,16 @@ class SearchTest < ActionDispatch::IntegrationTest
25
25
 
26
26
  @concepts = ["Tree", "Forest"].map do |english_label_value|
27
27
  FactoryGirl.create(:concept, :pref_labelings => [
28
- Factory(:pref_labeling, :target => Factory(:pref_label, :language => :en, :value => english_label_value))
28
+ FactoryGirl.create(:pref_labeling, :target => FactoryGirl.create(:pref_label,
29
+ :language => :en, :value => english_label_value))
29
30
  ])
30
31
  end
31
32
 
32
33
  # create collection
33
34
  @collection = FactoryGirl.create(:collection, :concepts => @concepts,
34
35
  :labelings => [], :pref_labelings => [
35
- Factory(:pref_labeling,
36
- :target => Factory(:pref_label, :language => :en, :value => "Alpha"))
36
+ FactoryGirl.create(:pref_labeling,
37
+ :target => FactoryGirl.create(:pref_label, :language => :en, :value => "Alpha"))
37
38
  ])
38
39
  end
39
40
 
@@ -167,8 +168,8 @@ class SearchTest < ActionDispatch::IntegrationTest
167
168
  # create a large number of concepts
168
169
  12.times { |i|
169
170
  FactoryGirl.create(:concept,
170
- :pref_labelings => [Factory(:pref_labeling,
171
- :target => Factory(:pref_label, :language => :en,
171
+ :pref_labelings => [FactoryGirl.create(:pref_labeling,
172
+ :target => FactoryGirl.create(:pref_label, :language => :en,
172
173
  :value => "sample_#{sprintf("_%04d", i + 1)}"))])
173
174
  }
174
175
 
@@ -19,7 +19,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '../integration_test
19
19
  class TreeTest < ActionDispatch::IntegrationTest
20
20
 
21
21
  test "Browse hierarchical concepts tree" do
22
- concept = Factory(:concept, :broader_relations => [])
22
+ concept = FactoryGirl.create(:concept, :broader_relations => [])
23
23
  narrower_concept = concept.narrower_relations.first.target
24
24
 
25
25
  visit hierarchical_concepts_path(:lang => :de, :format => :html)
@@ -26,7 +26,8 @@ class UntranslatedConceptsTest < ActionDispatch::IntegrationTest
26
26
  ].map do |hsh|
27
27
  labelings = []
28
28
  hsh.each do |lang, val|
29
- labelings << Factory(:pref_labeling, :target => Factory(:pref_label, :language => lang, :value => val))
29
+ labelings << FactoryGirl.create(:pref_labeling,
30
+ :target => FactoryGirl.create(:pref_label, :language => lang, :value => val))
30
31
  end
31
32
  FactoryGirl.create(:concept, :pref_labelings => labelings)
32
33
  end
@@ -16,9 +16,6 @@
16
16
 
17
17
  require File.join(File.expand_path(File.dirname(__FILE__)), 'test_helper')
18
18
  require 'capybara/rails'
19
- require 'test/unit/failure'
20
- require 'test/unit/error'
21
- require 'fileutils'
22
19
 
23
20
  module ActionController
24
21
  class IntegrationTest
@@ -60,29 +57,3 @@ module ActionController
60
57
 
61
58
  end
62
59
  end
63
-
64
- module Test
65
- module Unit
66
-
67
- module FailureHandler
68
-
69
- def add_failure_with_snapshot(*args)
70
- create_snapshot
71
- add_failure_without_snapshot(*args)
72
- end
73
- alias_method_chain :add_failure, :snapshot
74
-
75
- end
76
-
77
- module ErrorHandler
78
-
79
- def add_error_with_snapshot(*args)
80
- create_snapshot
81
- add_error_without_snapshot(*args)
82
- end
83
- alias_method_chain :add_error, :snapshot
84
-
85
- end
86
-
87
- end
88
- end
@@ -22,11 +22,20 @@ class ConceptTest < ActiveSupport::TestCase
22
22
  @current_concept = FactoryGirl.create(:concept)
23
23
  end
24
24
 
25
- test "should not create more than two versions of a concept" do
26
- first_new_concept = Concept::Base.new(@current_concept.attributes)
27
- second_new_concept = Concept::Base.new(@current_concept.attributes)
28
- assert first_new_concept.save
29
- assert_equal second_new_concept.save, false
25
+ test "should not allow identical concepts" do
26
+ origin = "foo"
27
+ c1 = Concept::Base.new(:origin => origin)
28
+ c2 = Concept::Base.new(:origin => origin, :published_at => Time.now)
29
+ assert c1.save
30
+ assert c2.save
31
+
32
+ origin = "bar"
33
+ c1 = Concept::Base.new(:origin => origin)
34
+ c2 = Concept::Base.new(:origin => origin)
35
+ assert c1.save
36
+ assert_raise ActiveRecord::RecordInvalid do
37
+ c2.save!
38
+ end
30
39
  end
31
40
 
32
41
  test "should not save concept with empty preflabel" do
@@ -63,7 +72,9 @@ class ConceptTest < ActiveSupport::TestCase
63
72
 
64
73
  test "concepts can have multiple preferred labels" do
65
74
  concept = FactoryGirl.build(:concept)
66
- concept.labelings << FactoryGirl.build(:pref_labeling, :target => Factory(:pref_label, :language => Iqvoc::Concept.pref_labeling_languages.second))
75
+ concept.labelings << FactoryGirl.build(:pref_labeling,
76
+ :target => FactoryGirl.create(:pref_label,
77
+ :language => Iqvoc::Concept.pref_labeling_languages.second))
67
78
  concept.save!
68
79
  concept.reload
69
80
 
@@ -1,13 +1,23 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ # Copyright 2011 innoQ Deutschland GmbH
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
3
17
  class HygieneTest < ActiveSupport::TestCase
4
18
 
5
19
  test "trailing whitespace" do
6
- begin
7
- assert_no_occurrence '[[:blank:]]$', "trailing whitespace"
8
- rescue Test::Unit::AssertionFailedError => exc
9
- warn "[WARNING] #{exc}"
10
- end
20
+ assert_no_occurrence '[[:blank:]]$', "trailing whitespace"
11
21
  end
12
22
 
13
23
  test "mixed whitespace" do
@@ -54,7 +54,8 @@ class OriginTest < ActiveSupport::TestCase
54
54
  end
55
55
 
56
56
  def test_should_replace_brackets
57
- assert_equal "--Energie-Ressource", Iqvoc::Origin.new("[Energie/Ressource]").to_s
57
+ assert_equal "--Energie-Ressource",
58
+ Iqvoc::Origin.new("[Energie/Ressource]").to_s
58
59
  end
59
60
 
60
61
  def test_should_replace_comma
@@ -62,10 +63,12 @@ class OriginTest < ActiveSupport::TestCase
62
63
  end
63
64
 
64
65
  def test_should_merge_all_together
65
- assert_equal "--Energie-Ressource", Iqvoc::Origin.new("[Energie - Ressource]").to_s
66
- assert_equal "--Hydrosphaere-WasserUndGewaesser", Iqvoc::Origin.new("[Hydrosphäre - Wasser und Gewässer]").to_s
66
+ assert_equal "--Energie-Ressource",
67
+ Iqvoc::Origin.new("[Energie - Ressource]").to_s
68
+ assert_equal "--Hydrosphaere-WasserUndGewaesser",
69
+ Iqvoc::Origin.new("[Hydrosphäre - Wasser und Gewässer]").to_s
67
70
  end
68
-
71
+
69
72
  def test_register_custom_filter
70
73
  Iqvoc::Origin::Filters.register(:strip_foobars, FoobarStripper)
71
74
  assert_equal "trololo_", Iqvoc::Origin.new("trololo_foobar").strip_foobars.to_s