changeset 1386:e4c393cebb1a luisf

Merger from testing branch.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 24 Sep 2013 16:25:05 +0100
parents bfef1bf3bedd (current diff) 95a6d8cecdb8 (diff)
children 765e83814c28
files
diffstat 10 files changed, 287 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/redmine_bibliography/test/fixtures/authors.yml	Fri Sep 20 19:54:06 2013 +0100
+++ b/plugins/redmine_bibliography/test/fixtures/authors.yml	Tue Sep 24 16:25:05 2013 +0100
@@ -1,17 +1,18 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+# authors.yml
+---
 one:
   id: 1
-  user_id: 
-  name: MyString
+  user_id: 1
+  name:
 two:
   id: 2
-  user_id: 
-  name: MyString
-one:
+  user_id:
+  name:
+three:
   id: 3
-  user_id: 
-  name: MyString
-two:
+  user_id:
+  name:
+four:
   id: 4
-  user_id: 
-  name: MyString
+  user_id:
+  name:
--- a/plugins/redmine_bibliography/test/fixtures/authorships.yml	Fri Sep 20 19:54:06 2013 +0100
+++ b/plugins/redmine_bibliography/test/fixtures/authorships.yml	Tue Sep 24 16:25:05 2013 +0100
@@ -1,33 +1,42 @@
-# 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: 
-  email: MyString
+  auth_order: 1
+  institution: Imperial College London
+  email: chen@imperial.ac.uk
 two:
   id: 2
   author_id: 2
   publication_id: 1
   name_on_paper: Glenn S. Fowler
-  order: 2
-  institution: 
+  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
-  institution: 
-  email: MyString
+  name_on_paper: Jackie Brown
+  auth_order: 1
+  institution:
+  email: j.brown@m.com
 four:
   id: 4
-  author_id: 2
+  author_id: 4
   publication_id: 1
-  name_on_paper: Glenn S. Fowler
-  order: 2
-  institution: 
-  email: MyString
+  name_on_paper: Captain Boomtime
+  auth_order: 2
+  institution:
+  email: cpt.boom@time.co.uk
+five:
+  id: 5
+  author_id: 1
+  publication_id: 2
+  name_on_paper: Yih-Farn Chen
+  auth_order: 1
+  institution: "Imperial College, London"
+  email: yfc@gmail.com
--- a/plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml	Fri Sep 20 19:54:06 2013 +0100
+++ b/plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml	Tue Sep 24 16:25:05 2013 +0100
@@ -1,4 +1,5 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+# bibtex_entries.yml
+---
 one:
   id: 1
   entry_type: InProceedings
--- a/plugins/redmine_bibliography/test/fixtures/publications.yml	Fri Sep 20 19:54:06 2013 +0100
+++ b/plugins/redmine_bibliography/test/fixtures/publications.yml	Tue Sep 24 16:25:05 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:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/redmine_bibliography/test/fixtures/users.yml	Tue Sep 24 16:25:05 2013 +0100
@@ -0,0 +1,167 @@
+# users.yml
+---
+users_004:
+  created_on: 2006-07-19 19:34:07 +02:00
+  status: 1
+  last_login_on:
+  language: en
+  # password = foo
+  salt: 3126f764c3c5ac61cbfc103f25f934cf
+  hashed_password: 9e4dd7eeb172c12a0691a6d9d3a269f7e9fe671b
+  updated_on: 2006-07-19 19:34:07 +02:00
+  admin: false
+  mail: rhill@somenet.foo
+  lastname: Hill
+  firstname: Robert
+  id: 4
+  auth_source_id:
+  mail_notification: all
+  login: rhill
+  type: User
+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
+  language: en
+  # password = admin
+  salt: 82090c953c4a0000a7db253b0691a6b4
+  hashed_password: b5b6ff9543bf1387374cdfa27a54c96d236a7150
+  updated_on: 2006-07-19 22:57:52 +02:00
+  admin: true
+  mail: admin@somenet.foo
+  lastname: Admin
+  firstname: redMine
+  id: 1
+  auth_source_id:
+  mail_notification: all
+  login: admin
+  type: User
+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
+  language: en
+  # password = jsmith
+  salt: 67eb4732624d5a7753dcea7ce0bb7d7d
+  hashed_password: bfbe06043353a677d0215b26a5800d128d5413bc
+  updated_on: 2006-07-19 22:42:15 +02:00
+  admin: false
+  mail: jsmith@somenet.foo
+  lastname: Smith
+  firstname: John
+  id: 2
+  auth_source_id:
+  mail_notification: all
+  login: jsmith
+  type: User
+users_003:
+  created_on: 2006-07-19 19:33:19 +02:00
+  status: 1
+  last_login_on:
+  language: en
+  # password = foo
+  salt: 7599f9963ec07b5a3b55b354407120c0
+  hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed
+  updated_on: 2006-07-19 19:33:19 +02:00
+  admin: false
+  mail: dlopper@somenet.foo
+  lastname: Lopper
+  firstname: Dave
+  id: 3
+  auth_source_id:
+  mail_notification: all
+  login: dlopper
+  type: User
+users_005:
+  id: 5
+  created_on: 2006-07-19 19:33:19 +02:00
+  # Locked
+  status: 3
+  last_login_on:
+  language: en
+  hashed_password: 1
+  updated_on: 2006-07-19 19:33:19 +02:00
+  admin: false
+  mail: dlopper2@somenet.foo
+  lastname: Lopper2
+  firstname: Dave2
+  auth_source_id:
+  mail_notification: all
+  login: dlopper2
+  type: User
+users_006:
+  id: 6
+  created_on: 2006-07-19 19:33:19 +02:00
+  status: 0
+  last_login_on:
+  language: ''
+  hashed_password: 1
+  updated_on: 2006-07-19 19:33:19 +02:00
+  admin: false
+  mail: ''
+  lastname: Anonymous
+  firstname: ''
+  auth_source_id:
+  mail_notification: only_my_events
+  login: ''
+  type: AnonymousUser
+users_007:
+  id: 7
+  created_on: 2006-07-19 19:33:19 +02:00
+  status: 1
+  last_login_on:
+  language: ''
+  hashed_password: 1
+  updated_on: 2006-07-19 19:33:19 +02:00
+  admin: false
+  mail: someone@foo.bar
+  lastname: One
+  firstname: Some
+  auth_source_id:
+  mail_notification: only_my_events
+  login: someone
+  type: User
+users_008:
+  id: 8
+  created_on: 2006-07-19 19:33:19 +02:00
+  status: 1
+  last_login_on:
+  language: 'it'
+  # password = foo
+  salt: 7599f9963ec07b5a3b55b354407120c0
+  hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed
+  updated_on: 2006-07-19 19:33:19 +02:00
+  admin: false
+  mail: miscuser8@foo.bar
+  lastname: Misc
+  firstname: User
+  auth_source_id:
+  mail_notification: only_my_events
+  login: miscuser8
+  type: User
+users_009:
+  id: 9
+  created_on: 2006-07-19 19:33:19 +02:00
+  status: 1
+  last_login_on:
+  language: 'it'
+  hashed_password: 1
+  updated_on: 2006-07-19 19:33:19 +02:00
+  admin: false
+  mail: miscuser9@foo.bar
+  lastname: Misc
+  firstname: User
+  auth_source_id:
+  mail_notification: only_my_events
+  login: miscuser9
+  type: User
+groups_010:
+  id: 10
+  lastname: A Team
+  type: Group
+groups_011:
+  id: 11
+  lastname: B Team
+  type: Group
+
+
--- a/plugins/redmine_bibliography/test/functional/authors_controller_test.rb	Fri Sep 20 19:54:06 2013 +0100
+++ b/plugins/redmine_bibliography/test/functional/authors_controller_test.rb	Tue Sep 24 16:25:05 2013 +0100
@@ -1,8 +1,13 @@
-require File.dirname(__FILE__) + '/../test_helper'
+# authors_controller_test.rb
+
+require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
 
 class AuthorsControllerTest < ActionController::TestCase
-  # Replace this with your real tests.
+  self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
+  fixtures :users, :authors, :authorships
+
   def test_truth
     assert true
   end
+
 end
--- a/plugins/redmine_bibliography/test/test_helper.rb	Fri Sep 20 19:54:06 2013 +0100
+++ b/plugins/redmine_bibliography/test/test_helper.rb	Tue Sep 24 16:25:05 2013 +0100
@@ -1,24 +1,27 @@
+ENV['RAILS_ENV'] ||= 'test'
+
 # Load the normal Rails helper
-require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
-require 'publications_controller'
-
-# Ensure that we are using the temporary fixture path
-Engines::Testing.set_fixture_path
+require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
+require File.expand_path(File.dirname(__FILE__) + '/../app/controllers/publications_controller')
 
 class BibliographyControllerTest < ActionController::TestCase
-  fixtures :all
+  self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
+
+  fixtures :authors
 
   def setup
+
   end
 
-  def test_publication
-  
+  def test_truth
+    assert true
   end
-  
 
-  def test_routing
-    assert_routing(
-          {:method => :get, :path => '/requirements'},
-          :controller => 'requirements', :action => 'index'
-        )
-  end
+  # def test_routing
+  #   assert_routing(
+  #         {:method => :get, :path => '/requirements'},
+  #         :controller => 'requirements', :action => 'index'
+  #       )
+  # end
+
+end
--- a/plugins/redmine_bibliography/test/unit/author_test.rb	Fri Sep 20 19:54:06 2013 +0100
+++ b/plugins/redmine_bibliography/test/unit/author_test.rb	Tue Sep 24 16:25:05 2013 +0100
@@ -1,10 +1,17 @@
-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
-    assert true
-  end
+    def test_relationships
+        author = Author.find(1)
+
+        assert_equal(author.authorships.first.name_on_paper, "Yih-Farn R. Chen")
+        assert_equal(author.authorships.count, 2)
+
+    end
+
 end
--- a/plugins/redmine_bibliography/test/unit/authorship_test.rb	Fri Sep 20 19:54:06 2013 +0100
+++ b/plugins/redmine_bibliography/test/unit/authorship_test.rb	Tue Sep 24 16:25:05 2013 +0100
@@ -5,6 +5,12 @@
 
   # Replace this with your real tests.
   def test_truth
+        luis = Author.first
+
+
     assert true
   end
+
+
+
 end
--- a/plugins/redmine_bibliography/test/unit/publication_test.rb	Fri Sep 20 19:54:06 2013 +0100
+++ b/plugins/redmine_bibliography/test/unit/publication_test.rb	Tue Sep 24 16:25:05 2013 +0100
@@ -1,10 +1,31 @@
-require File.dirname(__FILE__) + '/../test_helper'
+# publication_test
+
+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 4, publication.authorships.count
+    end
+
+    def test_new_publication_validations
+        pub = Publication.create
+
+        assert !pub.valid?, "!pub.valid?"
+        assert_equal 2, pub.errors.count, "Number of errors"
+        assert_equal ["can't be blank"], pub.errors[:title]
+        assert_equal ["Please add at least one author to this publication."], pub.errors[:authorships]
+    end
+
 end