changeset 1371:a8d468e143f7 bibliography_testing

Started adding a few real test cases.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 22 Aug 2013 11:44:31 +0100
parents 0b169a5e3837
children a8832968d927
files plugins/redmine_bibliography/test/fixtures/authors.yml plugins/redmine_bibliography/test/fixtures/authorships.yml plugins/redmine_bibliography/test/fixtures/publications.yml plugins/redmine_bibliography/test/fixtures/users.yml plugins/redmine_bibliography/test/functional/authors_controller_test.rb plugins/redmine_bibliography/test/test_helper.rb plugins/redmine_bibliography/test/unit/author_test.rb plugins/redmine_bibliography/test/unit/publication_test.rb
diffstat 8 files changed, 87 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/redmine_bibliography/test/fixtures/authors.yml	Wed Aug 21 18:57:34 2013 +0100
+++ b/plugins/redmine_bibliography/test/fixtures/authors.yml	Thu Aug 22 11:44:31 2013 +0100
@@ -1,17 +1,18 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+# authors.yml
+---
 one:
   id: 1
   user_id: 1
-  name: Luis
+  name:
 two:
   id: 2
   user_id:
-  name: Manel
+  name:
 three:
   id: 3
   user_id:
-  name: MyString1
+  name:
 four:
   id: 4
   user_id:
-  name: MyString2
+  name:
--- a/plugins/redmine_bibliography/test/fixtures/authorships.yml	Wed Aug 21 18:57:34 2013 +0100
+++ b/plugins/redmine_bibliography/test/fixtures/authorships.yml	Thu Aug 22 11:44:31 2013 +0100
@@ -1,33 +1,34 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+# authorships.yml
+---
 one:
   id: 1
   author_id: 1
   publication_id: 1
   name_on_paper: Yih-Farn R. Chen
-  order: 1
-  institution:
+  auth_order: 1
+  institution: Imperial College London
   email: MyString
 two:
   id: 2
   author_id: 2
   publication_id: 1
   name_on_paper: Glenn S. Fowler
-  order: 2
+  auth_order: 2
   institution:
   email: MyString
 three:
   id: 3
-  author_id: 1
+  author_id: 3
   publication_id: 1
   name_on_paper: Yih-Farn R. Chen
-  order: 1
+  auth_order: 1
   institution:
   email: MyString
 four:
   id: 4
-  author_id: 2
+  author_id: 4
   publication_id: 1
   name_on_paper: Glenn S. Fowler
-  order: 2
+  auth_order: 2
   institution:
   email: MyString
--- a/plugins/redmine_bibliography/test/fixtures/publications.yml	Wed Aug 21 18:57:34 2013 +0100
+++ b/plugins/redmine_bibliography/test/fixtures/publications.yml	Thu Aug 22 11:44:31 2013 +0100
@@ -1,9 +1,13 @@
 # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
 one:
-  id: 1
-  title: Test Fixture Title No1
-  bibtex_entry_id: 1
+    id: 1
+    title: Publication Number 1
+    reviewed: true
+    external_url:
+    doi:
 two:
-  id: 2
-  title: MyString
-  bibtex_entry_id: MyString
+    id: 2
+    title: Publication Number 2
+    reviewed: false
+    external_url:
+    doi:
--- a/plugins/redmine_bibliography/test/fixtures/users.yml	Wed Aug 21 18:57:34 2013 +0100
+++ b/plugins/redmine_bibliography/test/fixtures/users.yml	Thu Aug 22 11:44:31 2013 +0100
@@ -1,8 +1,9 @@
---- 
-users_004: 
+# users.yml
+---
+users_004:
   created_on: 2006-07-19 19:34:07 +02:00
   status: 1
-  last_login_on: 
+  last_login_on:
   language: en
   # password = foo
   salt: 3126f764c3c5ac61cbfc103f25f934cf
@@ -13,11 +14,11 @@
   lastname: Hill
   firstname: Robert
   id: 4
-  auth_source_id: 
+  auth_source_id:
   mail_notification: all
   login: rhill
   type: User
-users_001: 
+users_001:
   created_on: 2006-07-19 19:12:21 +02:00
   status: 1
   last_login_on: 2006-07-19 22:57:52 +02:00
@@ -31,11 +32,11 @@
   lastname: Admin
   firstname: redMine
   id: 1
-  auth_source_id: 
+  auth_source_id:
   mail_notification: all
   login: admin
   type: User
-users_002: 
+users_002:
   created_on: 2006-07-19 19:32:09 +02:00
   status: 1
   last_login_on: 2006-07-19 22:42:15 +02:00
@@ -49,14 +50,14 @@
   lastname: Smith
   firstname: John
   id: 2
-  auth_source_id: 
+  auth_source_id:
   mail_notification: all
   login: jsmith
   type: User
-users_003: 
+users_003:
   created_on: 2006-07-19 19:33:19 +02:00
   status: 1
-  last_login_on: 
+  last_login_on:
   language: en
   # password = foo
   salt: 7599f9963ec07b5a3b55b354407120c0
@@ -67,16 +68,16 @@
   lastname: Lopper
   firstname: Dave
   id: 3
-  auth_source_id: 
+  auth_source_id:
   mail_notification: all
   login: dlopper
   type: User
-users_005: 
+users_005:
   id: 5
   created_on: 2006-07-19 19:33:19 +02:00
   # Locked
   status: 3
-  last_login_on: 
+  last_login_on:
   language: en
   hashed_password: 1
   updated_on: 2006-07-19 19:33:19 +02:00
@@ -84,15 +85,15 @@
   mail: dlopper2@somenet.foo
   lastname: Lopper2
   firstname: Dave2
-  auth_source_id: 
+  auth_source_id:
   mail_notification: all
   login: dlopper2
   type: User
-users_006: 
+users_006:
   id: 6
   created_on: 2006-07-19 19:33:19 +02:00
   status: 0
-  last_login_on: 
+  last_login_on:
   language: ''
   hashed_password: 1
   updated_on: 2006-07-19 19:33:19 +02:00
@@ -100,15 +101,15 @@
   mail: ''
   lastname: Anonymous
   firstname: ''
-  auth_source_id: 
+  auth_source_id:
   mail_notification: only_my_events
   login: ''
   type: AnonymousUser
-users_007: 
+users_007:
   id: 7
   created_on: 2006-07-19 19:33:19 +02:00
   status: 1
-  last_login_on: 
+  last_login_on:
   language: ''
   hashed_password: 1
   updated_on: 2006-07-19 19:33:19 +02:00
@@ -116,15 +117,15 @@
   mail: someone@foo.bar
   lastname: One
   firstname: Some
-  auth_source_id: 
+  auth_source_id:
   mail_notification: only_my_events
   login: someone
   type: User
-users_008: 
+users_008:
   id: 8
   created_on: 2006-07-19 19:33:19 +02:00
   status: 1
-  last_login_on: 
+  last_login_on:
   language: 'it'
   # password = foo
   salt: 7599f9963ec07b5a3b55b354407120c0
@@ -134,15 +135,15 @@
   mail: miscuser8@foo.bar
   lastname: Misc
   firstname: User
-  auth_source_id: 
+  auth_source_id:
   mail_notification: only_my_events
   login: miscuser8
   type: User
-users_009: 
+users_009:
   id: 9
   created_on: 2006-07-19 19:33:19 +02:00
   status: 1
-  last_login_on: 
+  last_login_on:
   language: 'it'
   hashed_password: 1
   updated_on: 2006-07-19 19:33:19 +02:00
@@ -150,17 +151,17 @@
   mail: miscuser9@foo.bar
   lastname: Misc
   firstname: User
-  auth_source_id: 
+  auth_source_id:
   mail_notification: only_my_events
   login: miscuser9
   type: User
-groups_010: 
+groups_010:
   id: 10
   lastname: A Team
   type: Group
-groups_011: 
+groups_011:
   id: 11
   lastname: B Team
   type: Group
 
-  
+
--- a/plugins/redmine_bibliography/test/functional/authors_controller_test.rb	Wed Aug 21 18:57:34 2013 +0100
+++ b/plugins/redmine_bibliography/test/functional/authors_controller_test.rb	Thu Aug 22 11:44:31 2013 +0100
@@ -1,11 +1,13 @@
+# authors_controller_test.rb
+
 require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
 
 class AuthorsControllerTest < ActionController::TestCase
   self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
-  fixtures :users, :authors
+  fixtures :users, :authors, :authorships
 
-  def test_users_authors_relationship
-    assert Author.first.user.name == "redMine Admin"
+  def test_truth
+    assert true
   end
 
 end
--- a/plugins/redmine_bibliography/test/test_helper.rb	Wed Aug 21 18:57:34 2013 +0100
+++ b/plugins/redmine_bibliography/test/test_helper.rb	Thu Aug 22 11:44:31 2013 +0100
@@ -13,10 +13,8 @@
 
   end
 
-  def test_publication
-    pub = Publication.first
-
-    assert 1 == 0
+  def test_truth
+    assert true
   end
 
   # def test_routing
--- a/plugins/redmine_bibliography/test/unit/author_test.rb	Wed Aug 21 18:57:34 2013 +0100
+++ b/plugins/redmine_bibliography/test/unit/author_test.rb	Thu Aug 22 11:44:31 2013 +0100
@@ -1,12 +1,14 @@
-require File.dirname(__FILE__) + '/../test_helper'
+# author_test.rb
+
+require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
 
 class AuthorTest < ActiveSupport::TestCase
-  fixtures :authors
+    self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
+    fixtures :users, :authors, :authorships
 
-  # Replace this with your real tests.
-  def test_truth
-    luis = Author.first
+    def test_relationships
+        author = Author.find(1)
+        assert author.authorships.first.name_on_paper == "Yih-Farn R. Chen"
+    end
 
-    assert true
-  end
 end
--- a/plugins/redmine_bibliography/test/unit/publication_test.rb	Wed Aug 21 18:57:34 2013 +0100
+++ b/plugins/redmine_bibliography/test/unit/publication_test.rb	Thu Aug 22 11:44:31 2013 +0100
@@ -1,10 +1,20 @@
-require File.dirname(__FILE__) + '/../test_helper'
+require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
 
 class PublicationTest < ActiveSupport::TestCase
-  fixtures :publications
+    self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
 
-  # Replace this with your real tests.
-  def test_truth
-    assert true
-  end
+    fixtures :publications, :authorships
+
+    # Replace this with your real tests.
+    def test_truth
+        assert true
+    end
+
+    def test_relationships
+        # test authorships - publication relationship
+        publication = Publication.find(1)
+
+        assert publication.authorships.count == 4
+    end
+
 end