Revision 1430:04cc33a44d4c plugins/redmine_bibliography/test

View differences:

plugins/redmine_bibliography/test/fixtures/authors.yml
1
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
1
# authors.yml
2
---
2 3
one:
3 4
  id: 1
4
  user_id: 
5
  name: MyString
5
  user_id: 1
6
  name:
6 7
two:
7 8
  id: 2
8
  user_id: 
9
  name: MyString
10
one:
9
  user_id:
10
  name:
11
three:
11 12
  id: 3
12
  user_id: 
13
  name: MyString
14
two:
13
  user_id:
14
  name:
15
four:
15 16
  id: 4
16
  user_id: 
17
  name: MyString
17
  user_id:
18
  name:
plugins/redmine_bibliography/test/fixtures/authorships.yml
1
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
1
# authorships.yml
2
---
2 3
one:
3 4
  id: 1
4 5
  author_id: 1
5 6
  publication_id: 1
6 7
  name_on_paper: Yih-Farn R. Chen
7
  order: 1
8
  institution: 
9
  email: MyString
8
  auth_order: 1
9
  institution: Imperial College London
10
  email: chen@imperial.ac.uk
10 11
two:
11 12
  id: 2
12 13
  author_id: 2
13 14
  publication_id: 1
14 15
  name_on_paper: Glenn S. Fowler
15
  order: 2
16
  institution: 
16
  auth_order: 2
17
  institution:
17 18
  email: MyString
18 19
three:
19 20
  id: 3
20
  author_id: 1
21
  author_id: 3
21 22
  publication_id: 1
22
  name_on_paper: Yih-Farn R. Chen
23
  order: 1
24
  institution: 
25
  email: MyString
23
  name_on_paper: Jackie Brown
24
  auth_order: 1
25
  institution:
26
  email: j.brown@m.com
26 27
four:
27 28
  id: 4
28
  author_id: 2
29
  author_id: 4
29 30
  publication_id: 1
30
  name_on_paper: Glenn S. Fowler
31
  order: 2
32
  institution: 
33
  email: MyString
31
  name_on_paper: Captain Boomtime
32
  auth_order: 2
33
  institution:
34
  email: cpt.boom@time.co.uk
35
five:
36
  id: 5
37
  author_id: 1
38
  publication_id: 2
39
  name_on_paper: Yih-Farn Chen
40
  auth_order: 1
41
  institution: "Imperial College, London"
42
  email: yfc@gmail.com
plugins/redmine_bibliography/test/fixtures/bibtex_entries.yml
1
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
1
# bibtex_entries.yml
2
---
2 3
one:
3 4
  id: 1
4 5
  entry_type: InProceedings
plugins/redmine_bibliography/test/fixtures/publications.yml
1 1
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2 2
one:
3
  id: 1
4
  title: Test Fixture Title No1
5
  bibtex_entry_id: 1
3
    id: 1
4
    title: Publication Number 1
5
    reviewed: true
6
    external_url:
7
    doi:
6 8
two:
7
  id: 2
8
  title: MyString
9
  bibtex_entry_id: MyString
9
    id: 2
10
    title: Publication Number 2
11
    reviewed: false
12
    external_url:
13
    doi:
plugins/redmine_bibliography/test/fixtures/users.yml
1
# users.yml
2
---
3
users_004:
4
  created_on: 2006-07-19 19:34:07 +02:00
5
  status: 1
6
  last_login_on:
7
  language: en
8
  # password = foo
9
  salt: 3126f764c3c5ac61cbfc103f25f934cf
10
  hashed_password: 9e4dd7eeb172c12a0691a6d9d3a269f7e9fe671b
11
  updated_on: 2006-07-19 19:34:07 +02:00
12
  admin: false
13
  mail: rhill@somenet.foo
14
  lastname: Hill
15
  firstname: Robert
16
  id: 4
17
  auth_source_id:
18
  mail_notification: all
19
  login: rhill
20
  type: User
21
users_001:
22
  created_on: 2006-07-19 19:12:21 +02:00
23
  status: 1
24
  last_login_on: 2006-07-19 22:57:52 +02:00
25
  language: en
26
  # password = admin
27
  salt: 82090c953c4a0000a7db253b0691a6b4
28
  hashed_password: b5b6ff9543bf1387374cdfa27a54c96d236a7150
29
  updated_on: 2006-07-19 22:57:52 +02:00
30
  admin: true
31
  mail: admin@somenet.foo
32
  lastname: Admin
33
  firstname: redMine
34
  id: 1
35
  auth_source_id:
36
  mail_notification: all
37
  login: admin
38
  type: User
39
users_002:
40
  created_on: 2006-07-19 19:32:09 +02:00
41
  status: 1
42
  last_login_on: 2006-07-19 22:42:15 +02:00
43
  language: en
44
  # password = jsmith
45
  salt: 67eb4732624d5a7753dcea7ce0bb7d7d
46
  hashed_password: bfbe06043353a677d0215b26a5800d128d5413bc
47
  updated_on: 2006-07-19 22:42:15 +02:00
48
  admin: false
49
  mail: jsmith@somenet.foo
50
  lastname: Smith
51
  firstname: John
52
  id: 2
53
  auth_source_id:
54
  mail_notification: all
55
  login: jsmith
56
  type: User
57
users_003:
58
  created_on: 2006-07-19 19:33:19 +02:00
59
  status: 1
60
  last_login_on:
61
  language: en
62
  # password = foo
63
  salt: 7599f9963ec07b5a3b55b354407120c0
64
  hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed
65
  updated_on: 2006-07-19 19:33:19 +02:00
66
  admin: false
67
  mail: dlopper@somenet.foo
68
  lastname: Lopper
69
  firstname: Dave
70
  id: 3
71
  auth_source_id:
72
  mail_notification: all
73
  login: dlopper
74
  type: User
75
users_005:
76
  id: 5
77
  created_on: 2006-07-19 19:33:19 +02:00
78
  # Locked
79
  status: 3
80
  last_login_on:
81
  language: en
82
  hashed_password: 1
83
  updated_on: 2006-07-19 19:33:19 +02:00
84
  admin: false
85
  mail: dlopper2@somenet.foo
86
  lastname: Lopper2
87
  firstname: Dave2
88
  auth_source_id:
89
  mail_notification: all
90
  login: dlopper2
91
  type: User
92
users_006:
93
  id: 6
94
  created_on: 2006-07-19 19:33:19 +02:00
95
  status: 0
96
  last_login_on:
97
  language: ''
98
  hashed_password: 1
99
  updated_on: 2006-07-19 19:33:19 +02:00
100
  admin: false
101
  mail: ''
102
  lastname: Anonymous
103
  firstname: ''
104
  auth_source_id:
105
  mail_notification: only_my_events
106
  login: ''
107
  type: AnonymousUser
108
users_007:
109
  id: 7
110
  created_on: 2006-07-19 19:33:19 +02:00
111
  status: 1
112
  last_login_on:
113
  language: ''
114
  hashed_password: 1
115
  updated_on: 2006-07-19 19:33:19 +02:00
116
  admin: false
117
  mail: someone@foo.bar
118
  lastname: One
119
  firstname: Some
120
  auth_source_id:
121
  mail_notification: only_my_events
122
  login: someone
123
  type: User
124
users_008:
125
  id: 8
126
  created_on: 2006-07-19 19:33:19 +02:00
127
  status: 1
128
  last_login_on:
129
  language: 'it'
130
  # password = foo
131
  salt: 7599f9963ec07b5a3b55b354407120c0
132
  hashed_password: 8f659c8d7c072f189374edacfa90d6abbc26d8ed
133
  updated_on: 2006-07-19 19:33:19 +02:00
134
  admin: false
135
  mail: miscuser8@foo.bar
136
  lastname: Misc
137
  firstname: User
138
  auth_source_id:
139
  mail_notification: only_my_events
140
  login: miscuser8
141
  type: User
142
users_009:
143
  id: 9
144
  created_on: 2006-07-19 19:33:19 +02:00
145
  status: 1
146
  last_login_on:
147
  language: 'it'
148
  hashed_password: 1
149
  updated_on: 2006-07-19 19:33:19 +02:00
150
  admin: false
151
  mail: miscuser9@foo.bar
152
  lastname: Misc
153
  firstname: User
154
  auth_source_id:
155
  mail_notification: only_my_events
156
  login: miscuser9
157
  type: User
158
groups_010:
159
  id: 10
160
  lastname: A Team
161
  type: Group
162
groups_011:
163
  id: 11
164
  lastname: B Team
165
  type: Group
166

  
167

  
plugins/redmine_bibliography/test/functional/authors_controller_test.rb
1
require File.dirname(__FILE__) + '/../test_helper'
1
# authors_controller_test.rb
2

  
3
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2 4

  
3 5
class AuthorsControllerTest < ActionController::TestCase
4
  # Replace this with your real tests.
6
  self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
7
  fixtures :users, :authors, :authorships
8

  
5 9
  def test_truth
6 10
    assert true
7 11
  end
12

  
8 13
end
plugins/redmine_bibliography/test/test_helper.rb
1
ENV['RAILS_ENV'] ||= 'test'
2

  
1 3
# Load the normal Rails helper
2
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
3
require 'publications_controller'
4

  
5
# Ensure that we are using the temporary fixture path
6
Engines::Testing.set_fixture_path
4
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
5
require File.expand_path(File.dirname(__FILE__) + '/../app/controllers/publications_controller')
7 6

  
8 7
class BibliographyControllerTest < ActionController::TestCase
9
  fixtures :all
8
  self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
9

  
10
  fixtures :authors
10 11

  
11 12
  def setup
13

  
12 14
  end
13 15

  
14
  def test_publication
15
  
16
  def test_truth
17
    assert true
16 18
  end
17
  
18 19

  
19
  def test_routing
20
    assert_routing(
21
          {:method => :get, :path => '/requirements'},
22
          :controller => 'requirements', :action => 'index'
23
        )
24
  end
20
  # def test_routing
21
  #   assert_routing(
22
  #         {:method => :get, :path => '/requirements'},
23
  #         :controller => 'requirements', :action => 'index'
24
  #       )
25
  # end
26

  
27
end
plugins/redmine_bibliography/test/unit/author_test.rb
1
require File.dirname(__FILE__) + '/../test_helper'
1
# author_test.rb
2

  
3
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2 4

  
3 5
class AuthorTest < ActiveSupport::TestCase
4
  fixtures :authors
6
    self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
7
    fixtures :users, :authors, :authorships
5 8

  
6
  # Replace this with your real tests.
7
  def test_truth
8
    assert true
9
  end
9
    def test_relationships
10
        author = Author.find(1)
11

  
12
        assert_equal(author.authorships.first.name_on_paper, "Yih-Farn R. Chen")
13
        assert_equal(author.authorships.count, 2)
14

  
15
    end
16

  
10 17
end
plugins/redmine_bibliography/test/unit/authorship_test.rb
5 5

  
6 6
  # Replace this with your real tests.
7 7
  def test_truth
8
        luis = Author.first
9

  
10

  
8 11
    assert true
9 12
  end
13

  
14

  
15

  
10 16
end
plugins/redmine_bibliography/test/unit/publication_test.rb
1
require File.dirname(__FILE__) + '/../test_helper'
1
# publication_test
2

  
3
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2 4

  
3 5
class PublicationTest < ActiveSupport::TestCase
4
  fixtures :publications
6
    self.fixture_path = File.dirname(__FILE__) + "/../fixtures/"
5 7

  
6
  # Replace this with your real tests.
7
  def test_truth
8
    assert true
9
  end
8
    fixtures :publications, :authorships
9

  
10
    # Replace this with your real tests.
11
    def test_truth
12
        assert true
13
    end
14

  
15
    def test_relationships
16
        # test authorships - publication relationship
17
        publication = Publication.find(1)
18

  
19
        assert 4, publication.authorships.count
20
    end
21

  
22
    def test_new_publication_validations
23
        pub = Publication.create
24

  
25
        assert !pub.valid?, "!pub.valid?"
26
        assert_equal 2, pub.errors.count, "Number of errors"
27
        assert_equal ["can't be blank"], pub.errors[:title]
28
        assert_equal ["Please add at least one author to this publication."], pub.errors[:authorships]
29
    end
30

  
10 31
end

Also available in: Unified diff