enju_question 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +36 -0
  4. data/app/controllers/answers_controller.rb +140 -0
  5. data/app/controllers/questions_controller.rb +171 -0
  6. data/app/models/answer.rb +59 -0
  7. data/app/models/answer_has_item.rb +20 -0
  8. data/app/models/question.rb +87 -0
  9. data/app/models/question_sweeper.rb +17 -0
  10. data/app/views/answers/_form.html.erb +33 -0
  11. data/app/views/answers/edit.html.erb +13 -0
  12. data/app/views/answers/index.atom.builder +16 -0
  13. data/app/views/answers/index.html.erb +44 -0
  14. data/app/views/answers/index.rss.builder +31 -0
  15. data/app/views/answers/new.html.erb +14 -0
  16. data/app/views/answers/new.mobile.erb +35 -0
  17. data/app/views/answers/show.html.erb +54 -0
  18. data/app/views/questions/_crd.html.erb +24 -0
  19. data/app/views/questions/_index.html.erb +22 -0
  20. data/app/views/questions/_index_user.html.erb +18 -0
  21. data/app/views/questions/_list.html.erb +69 -0
  22. data/app/views/questions/_solved_facet.html.erb +21 -0
  23. data/app/views/questions/edit.html.erb +44 -0
  24. data/app/views/questions/index.atom.builder +16 -0
  25. data/app/views/questions/index.html.erb +5 -0
  26. data/app/views/questions/index.js.erb +2 -0
  27. data/app/views/questions/index.mobile.erb +21 -0
  28. data/app/views/questions/index.rss.builder +41 -0
  29. data/app/views/questions/index_crd.xml.builder +36 -0
  30. data/app/views/questions/new.html.erb +35 -0
  31. data/app/views/questions/show.html.erb +62 -0
  32. data/app/views/questions/show.mobile.erb +46 -0
  33. data/app/views/questions/show_crd.xml.builder +34 -0
  34. data/config/routes.rb +10 -0
  35. data/db/migrate/098_create_questions.rb +21 -0
  36. data/db/migrate/099_create_answers.rb +21 -0
  37. data/db/migrate/20100217054028_create_answer_has_items.rb +17 -0
  38. data/lib/enju_question/engine.rb +4 -0
  39. data/lib/enju_question/version.rb +3 -0
  40. data/lib/enju_question.rb +4 -0
  41. data/lib/tasks/enju_question_tasks.rake +4 -0
  42. data/spec/cassette_library/enju_ndl/crd.yml +440 -0
  43. data/spec/controllers/answers_controller_spec.rb +486 -0
  44. data/spec/controllers/questions_controller_spec.rb +559 -0
  45. data/spec/dummy/Rakefile +7 -0
  46. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  47. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  48. data/spec/dummy/app/controllers/application_controller.rb +106 -0
  49. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  50. data/spec/dummy/app/models/ability.rb +42 -0
  51. data/spec/dummy/app/models/item.rb +5 -0
  52. data/spec/dummy/app/models/role.rb +8 -0
  53. data/spec/dummy/app/models/user.rb +29 -0
  54. data/spec/dummy/app/models/user_group.rb +2 -0
  55. data/spec/dummy/app/models/user_has_role.rb +4 -0
  56. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  57. data/spec/dummy/app/views/page/403.html.erb +9 -0
  58. data/spec/dummy/app/views/page/403.mobile.erb +5 -0
  59. data/spec/dummy/app/views/page/403.xml.erb +4 -0
  60. data/spec/dummy/app/views/page/404.html.erb +9 -0
  61. data/spec/dummy/app/views/page/404.mobile.erb +5 -0
  62. data/spec/dummy/app/views/page/404.xml.erb +4 -0
  63. data/spec/dummy/config/application.rb +46 -0
  64. data/spec/dummy/config/boot.rb +10 -0
  65. data/spec/dummy/config/database.yml +25 -0
  66. data/spec/dummy/config/environment.rb +5 -0
  67. data/spec/dummy/config/environments/development.rb +30 -0
  68. data/spec/dummy/config/environments/production.rb +60 -0
  69. data/spec/dummy/config/environments/test.rb +39 -0
  70. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  71. data/spec/dummy/config/initializers/devise.rb +209 -0
  72. data/spec/dummy/config/initializers/inflections.rb +10 -0
  73. data/spec/dummy/config/initializers/mime_types.rb +6 -0
  74. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  75. data/spec/dummy/config/initializers/session_store.rb +8 -0
  76. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  77. data/spec/dummy/config/locales/en.yml +5 -0
  78. data/spec/dummy/config/routes.rb +60 -0
  79. data/spec/dummy/config.ru +4 -0
  80. data/spec/dummy/db/development.sqlite3 +0 -0
  81. data/spec/dummy/db/migrate/006_create_items.rb +36 -0
  82. data/spec/dummy/db/migrate/20100525171356_acts_as_taggable_on_migration.rb +30 -0
  83. data/spec/dummy/db/migrate/20111201121636_create_languages.rb +16 -0
  84. data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
  85. data/spec/dummy/db/migrate/20111201155456_create_users.rb +13 -0
  86. data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
  87. data/spec/dummy/db/migrate/20111201163342_create_user_groups.rb +12 -0
  88. data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
  89. data/spec/dummy/db/schema.rb +168 -0
  90. data/spec/dummy/db/test.sqlite3 +0 -0
  91. data/spec/dummy/lib/expire_editable_fragment.rb +62 -0
  92. data/spec/dummy/log/development.log +2 -0
  93. data/spec/dummy/log/sunspot-solr-test.log +222 -0
  94. data/spec/dummy/log/test.log +77918 -0
  95. data/spec/dummy/public/404.html +26 -0
  96. data/spec/dummy/public/422.html +26 -0
  97. data/spec/dummy/public/500.html +26 -0
  98. data/spec/dummy/public/favicon.ico +0 -0
  99. data/spec/dummy/script/rails +6 -0
  100. data/spec/dummy/solr/conf/admin-extra.html +31 -0
  101. data/spec/dummy/solr/conf/elevate.xml +36 -0
  102. data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  103. data/spec/dummy/solr/conf/protwords.txt +21 -0
  104. data/spec/dummy/solr/conf/schema.xml +238 -0
  105. data/spec/dummy/solr/conf/scripts.conf +24 -0
  106. data/spec/dummy/solr/conf/solrconfig.xml +934 -0
  107. data/spec/dummy/solr/conf/spellings.txt +2 -0
  108. data/spec/dummy/solr/conf/stopwords.txt +58 -0
  109. data/spec/dummy/solr/conf/synonyms.txt +31 -0
  110. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  111. data/spec/dummy/solr/data/test/index/segments_1 +0 -0
  112. data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
  113. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  114. data/spec/factories/answer.rb +7 -0
  115. data/spec/factories/question.rb +6 -0
  116. data/spec/factories/user.rb +34 -0
  117. data/spec/fixtures/answer_has_items.yml +26 -0
  118. data/spec/fixtures/answers.yml +61 -0
  119. data/spec/fixtures/questions.yml +61 -0
  120. data/spec/fixtures/roles.yml +21 -0
  121. data/spec/fixtures/user_groups.yml +25 -0
  122. data/spec/fixtures/user_has_roles.yml +41 -0
  123. data/spec/fixtures/users.yml +69 -0
  124. data/spec/models/answer_has_item_spec.rb +20 -0
  125. data/spec/models/answer_spec.rb +25 -0
  126. data/spec/spec_helper.rb +48 -0
  127. data/spec/support/controller_macros.rb +48 -0
  128. data/spec/support/devise.rb +4 -0
  129. data/spec/support/vcr.rb +6 -0
  130. metadata +306 -0
@@ -0,0 +1,2 @@
1
+ pizza
2
+ history
@@ -0,0 +1,58 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright ownership.
4
+ # The ASF licenses this file to You under the Apache License, Version 2.0
5
+ # (the "License"); you may not use this file except in compliance with
6
+ # the License. You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ #-----------------------------------------------------------------------
17
+ # a couple of test stopwords to test that the words are really being
18
+ # configured from this file:
19
+ stopworda
20
+ stopwordb
21
+
22
+ #Standard english stop words taken from Lucene's StopAnalyzer
23
+ a
24
+ an
25
+ and
26
+ are
27
+ as
28
+ at
29
+ be
30
+ but
31
+ by
32
+ for
33
+ if
34
+ in
35
+ into
36
+ is
37
+ it
38
+ no
39
+ not
40
+ of
41
+ on
42
+ or
43
+ s
44
+ such
45
+ t
46
+ that
47
+ the
48
+ their
49
+ then
50
+ there
51
+ these
52
+ they
53
+ this
54
+ to
55
+ was
56
+ will
57
+ with
58
+
@@ -0,0 +1,31 @@
1
+ # The ASF licenses this file to You under the Apache License, Version 2.0
2
+ # (the "License"); you may not use this file except in compliance with
3
+ # the License. You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+
13
+ #-----------------------------------------------------------------------
14
+ #some test synonym mappings unlikely to appear in real input text
15
+ aaa => aaaa
16
+ bbb => bbbb1 bbbb2
17
+ ccc => cccc1,cccc2
18
+ a\=>a => b\=>b
19
+ a\,a => b\,b
20
+ fooaaa,baraaa,bazaaa
21
+
22
+ # Some synonym groups specific to this example
23
+ GB,gib,gigabyte,gigabytes
24
+ MB,mib,megabyte,megabytes
25
+ Television, Televisions, TV, TVs
26
+ #notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming
27
+ #after us won't split it into two words.
28
+
29
+ # Synonym mappings can be used for spelling correction too
30
+ pixima => pixma
31
+
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :answer do |f|
3
+ f.sequence(:body){|n| "answer_#{n}"}
4
+ f.question_id{FactoryGirl.create(:question).id}
5
+ f.user_id{FactoryGirl.create(:user).id}
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :question do |f|
3
+ f.sequence(:body){|n| "question_#{n}"}
4
+ f.user_id{FactoryGirl.create(:user).id}
5
+ end
6
+ end
@@ -0,0 +1,34 @@
1
+ FactoryGirl.define do
2
+ factory :admin, :class => User do |f|
3
+ f.sequence(:username){|n| "admin_#{n}"}
4
+ f.sequence(:email){|n| "admin_#{n}@example.jp"}
5
+ f.role {Role.find_by_name('Administrator')}
6
+ f.password 'adminpassword'
7
+ f.password_confirmation 'adminpassword'
8
+ f.user_group {UserGroup.first}
9
+ f.required_role {Role.find_by_name('User')}
10
+ end
11
+
12
+ factory :librarian, :class => User do |f|
13
+ f.sequence(:username){|n| "librarian_#{n}"}
14
+ f.sequence(:email){|n| "librarian_#{n}@example.jp"}
15
+ f.role {Role.find_by_name('Librarian')}
16
+ f.password 'librarianpassword'
17
+ f.password_confirmation 'librarianpassword'
18
+ f.user_group {UserGroup.first}
19
+ f.required_role {Role.find_by_name('User')}
20
+ end
21
+
22
+ factory :user, :class => User do |f|
23
+ f.sequence(:username){|n| "user_#{n}"}
24
+ f.sequence(:email){|n| "user_#{n}@example.jp"}
25
+ f.role {Role.find_by_name('User')}
26
+ f.password 'userpassword'
27
+ f.password_confirmation 'userpassword'
28
+ f.user_group {UserGroup.first}
29
+ f.required_role {Role.find_by_name('User')}
30
+ end
31
+
32
+ factory :invalid_user, :class => User do |f|
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ ---
2
+ answer_has_item00001:
3
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
4
+ item_id: 1
5
+ answer_id: 1
6
+ id: 1
7
+ created_at: 2007-12-26 02:28:47.252993 +09:00
8
+ answer_has_item00002:
9
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
10
+ item_id: 2
11
+ answer_id: 2
12
+ id: 2
13
+ created_at: 2007-12-26 02:28:47.252993 +09:00
14
+
15
+ # == Schema Information
16
+ #
17
+ # Table name: answer_has_items
18
+ #
19
+ # id :integer not null, primary key
20
+ # answer_id :integer
21
+ # item_id :integer
22
+ # position :integer
23
+ # created_at :datetime
24
+ # updated_at :datetime
25
+ #
26
+
@@ -0,0 +1,61 @@
1
+ ---
2
+ answer_00001:
3
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
4
+ body: test
5
+ question_id: 1
6
+ id: 1
7
+ user_id: 1
8
+ created_at: 2007-12-26 02:28:47.252993 +09:00
9
+ answer_00002:
10
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
11
+ body: test
12
+ question_id: 1
13
+ id: 2
14
+ user_id: 2
15
+ created_at: 2007-12-26 02:28:47.252993 +09:00
16
+ answer_00003:
17
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
18
+ body: test
19
+ question_id: 1
20
+ id: 3
21
+ user_id: 3
22
+ created_at: 2007-12-26 02:28:47.252993 +09:00
23
+ answer_00004:
24
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
25
+ body: test
26
+ question_id: 2
27
+ id: 4
28
+ user_id: 4
29
+ created_at: 2007-12-26 02:28:47.252993 +09:00
30
+ answer_00005:
31
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
32
+ body: test
33
+ question_id: 2
34
+ id: 5
35
+ user_id: 5
36
+ created_at: 2007-12-26 02:28:47.252993 +09:00
37
+ answer_00006:
38
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
39
+ body: test
40
+ question_id: 2
41
+ id: 6
42
+ user_id: 1
43
+ created_at: 2007-12-26 02:28:47.252993 +09:00
44
+
45
+
46
+ # == Schema Information
47
+ #
48
+ # Table name: answers
49
+ #
50
+ # id :integer not null, primary key
51
+ # user_id :integer not null
52
+ # question_id :integer not null
53
+ # body :text
54
+ # created_at :datetime
55
+ # updated_at :datetime
56
+ # deleted_at :datetime
57
+ # state :string(255)
58
+ # item_identifier_list :text
59
+ # url_list :text
60
+ #
61
+
@@ -0,0 +1,61 @@
1
+ ---
2
+ question_00001:
3
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
4
+ body: Yahoo
5
+ id: 1
6
+ user_id: 1
7
+ shared: true
8
+ created_at: 2007-12-26 02:28:47.252993 +09:00
9
+ question_00002:
10
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
11
+ body: test
12
+ id: 2
13
+ user_id: 2
14
+ shared: false
15
+ created_at: 2007-12-26 02:28:47.252993 +09:00
16
+ question_00003:
17
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
18
+ body: test
19
+ id: 3
20
+ user_id: 3
21
+ shared: false
22
+ created_at: 2007-12-26 02:28:47.252993 +09:00
23
+ question_00004:
24
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
25
+ body: test
26
+ id: 4
27
+ user_id: 4
28
+ shared: false
29
+ created_at: 2007-12-26 02:28:47.252993 +09:00
30
+ question_00005:
31
+ updated_at: 2007-12-26 02:28:48.252993 +09:00
32
+ body: test
33
+ id: 5
34
+ user_id: 5
35
+ shared: true
36
+ created_at: 2007-12-26 02:28:47.252993 +09:00
37
+ question_00006:
38
+ updated_at: 2007-12-26 02:28:47.252993 +09:00
39
+ body: test
40
+ id: 6
41
+ user_id: 1
42
+ shared: false
43
+ created_at: 2007-12-26 02:28:47.252993 +09:00
44
+
45
+ # == Schema Information
46
+ #
47
+ # Table name: questions
48
+ #
49
+ # id :integer not null, primary key
50
+ # user_id :integer not null
51
+ # body :text
52
+ # shared :boolean default(TRUE), not null
53
+ # answers_count :integer default(0), not null
54
+ # created_at :datetime
55
+ # updated_at :datetime
56
+ # deleted_at :datetime
57
+ # state :string(255)
58
+ # solved :boolean default(FALSE), not null
59
+ # note :text
60
+ #
61
+
@@ -0,0 +1,21 @@
1
+ ---
2
+ role_00001:
3
+ name: Guest
4
+ display_name: Guest
5
+ id: 1
6
+ note:
7
+ role_00002:
8
+ name: User
9
+ display_name: User
10
+ id: 2
11
+ note:
12
+ role_00003:
13
+ name: Librarian
14
+ display_name: Librarian
15
+ id: 3
16
+ note:
17
+ role_00004:
18
+ name: Administrator
19
+ display_name: Administrator
20
+ id: 4
21
+ note:
@@ -0,0 +1,25 @@
1
+ ---
2
+ user_group_00001:
3
+ name: (not specified)
4
+ display_name: (not specified)
5
+ updated_at: 2007-12-13 21:00:51.564542 +09:00
6
+ id: 1
7
+ note: ""
8
+ created_at: 2007-12-13 21:00:01.674976 +09:00
9
+ position: 1
10
+ user_group_00002:
11
+ name: User
12
+ display_name: User
13
+ updated_at: 2007-12-23 03:14:56.836548 +09:00
14
+ id: 2
15
+ note: ""
16
+ created_at: 2007-12-23 03:14:40.173954 +09:00
17
+ position: 2
18
+ user_group_00003:
19
+ name: Faculty
20
+ display_name: Faculty
21
+ updated_at: 2007-12-23 03:15:05.134351 +09:00
22
+ id: 3
23
+ note: ""
24
+ created_at: 2007-12-23 03:15:05.126457 +09:00
25
+ position: 3
@@ -0,0 +1,41 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
3
+ admin:
4
+ user_id: 1
5
+ role_id: 4
6
+
7
+ librarian1:
8
+ user_id: 2
9
+ role_id: 3
10
+
11
+ user1:
12
+ user_id: 3
13
+ role_id: 2
14
+
15
+ librarian2:
16
+ user_id: 4
17
+ role_id: 3
18
+
19
+ user2:
20
+ user_id: 5
21
+ role_id: 2
22
+
23
+ user3:
24
+ user_id: 6
25
+ role_id: 2
26
+
27
+ user4:
28
+ user_id: 7
29
+ role_id: 2
30
+
31
+ # == Schema Information
32
+ #
33
+ # Table name: user_has_roles
34
+ #
35
+ # id :integer not null, primary key
36
+ # user_id :integer
37
+ # role_id :integer
38
+ # created_at :datetime
39
+ # updated_at :datetime
40
+ #
41
+
@@ -0,0 +1,69 @@
1
+ ---
2
+ admin:
3
+ updated_at: 2008-05-31 13:16:30.163731 +09:00
4
+ encrypted_password: $2a$10$vHohD1WflnTIqAa8zMkF9evwAgIZRw3XuR4d3bi29M.jph/MB/AJi
5
+ user_group_id: 2
6
+ id: 1
7
+ note:
8
+ username: admin
9
+ email: tanabe@kamata.lib.teu.ac.jp
10
+ created_at: 2007-11-19 16:58:32.111941 +09:00
11
+ required_role_id: 4
12
+ librarian1:
13
+ updated_at: 2008-05-31 12:41:16.337474 +09:00
14
+ encrypted_password: $2a$10$9O2VuTccN4gHq36ARg0QReSrb1D7WrBBhZZ759RM9moHbB0W5zCzS
15
+ user_group_id: 1
16
+ id: 2
17
+ note:
18
+ username: librarian1
19
+ email: librarian1@kamata.lib.teu.ac.jp
20
+ created_at: 2007-11-19 16:58:33.172441 +09:00
21
+ required_role_id: 1
22
+ user1:
23
+ updated_at: 2008-05-31 13:02:25.101261 +09:00
24
+ encrypted_password: $2a$10$JthS59A0BNkDOoFpCXM0V.GhhffKaoWKbzpPahYp/vTFrOyM7h/uW
25
+ user_group_id: 1
26
+ id: 3
27
+ note:
28
+ username: user1
29
+ email: user1@kamata.lib.teu.ac.jp
30
+ created_at: 2007-11-19 16:58:34.637413 +09:00
31
+ required_role_id: 3
32
+ librarian2:
33
+ updated_at: 2008-05-31 12:42:23.340575 +09:00
34
+ encrypted_password: $2a$10$YmmTGrYQ1Ir6oc7wXnp.GuNeO1eYLoP3sv8wMSIrTdaGw2BPwRrpS
35
+ user_group_id: 1
36
+ id: 4
37
+ note:
38
+ username: librarian2
39
+ created_at: 2008-01-18 12:24:04.222344 +09:00
40
+ required_role_id: 1
41
+ user2:
42
+ updated_at: 2008-05-31 12:42:44.711117 +09:00
43
+ encrypted_password: $2a$10$i7UjJhLVrJM/J7qaTwW39OXw1NiwowUEbtNHVDV0sqMLjX9.UO9ca
44
+ user_group_id: 1
45
+ id: 5
46
+ note:
47
+ username: user2
48
+ created_at: 2008-01-18 13:29:06.922728 +09:00
49
+ required_role_id: 2
50
+ user3:
51
+ updated_at: 2008-05-31 13:02:25.101261 +09:00
52
+ encrypted_password: cc53de0c2d9a1a228daa9a673ec824473747e17507a6c3c4f7e5eff8821f531d4b9e23616b3ddc66fe17006b2298a556fbd567ac080e87f00f37eef8cee6c417
53
+ user_group_id: 1
54
+ id: 6
55
+ note:
56
+ username: user3
57
+ email: user3@kamata.lib.teu.ac.jp
58
+ created_at: 2007-11-19 16:58:34.637413 +09:00
59
+ required_role_id: 3
60
+ user4:
61
+ updated_at: 2008-05-31 13:02:25.101261 +09:00
62
+ encrypted_password: cc53de0c2d9a1a228daa9a673ec824473747e17507a6c3c4f7e5eff8821f531d4b9e23616b3ddc66fe17006b2298a556fbd567ac080e87f00f37eef8cee6c417
63
+ user_group_id: 1
64
+ id: 7
65
+ note:
66
+ username: user4
67
+ email: user4@kamata.lib.teu.ac.jp
68
+ created_at: 2007-11-19 16:58:34.637413 +09:00
69
+ required_role_id: 3
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe AnswerHasItem do
5
+ #pending "add some examples to (or delete) #{__FILE__}"
6
+
7
+ end
8
+
9
+ # == Schema Information
10
+ #
11
+ # Table name: answer_has_items
12
+ #
13
+ # id :integer not null, primary key
14
+ # answer_id :integer
15
+ # item_id :integer
16
+ # position :integer
17
+ # created_at :datetime
18
+ # updated_at :datetime
19
+ #
20
+
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe Answer do
5
+ #pending "add some examples to (or delete) #{__FILE__}"
6
+
7
+ end
8
+
9
+
10
+ # == Schema Information
11
+ #
12
+ # Table name: answers
13
+ #
14
+ # id :integer not null, primary key
15
+ # user_id :integer not null
16
+ # question_id :integer not null
17
+ # body :text
18
+ # created_at :datetime
19
+ # updated_at :datetime
20
+ # deleted_at :datetime
21
+ # state :string(255)
22
+ # item_identifier_list :text
23
+ # url_list :text
24
+ #
25
+
@@ -0,0 +1,48 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'factory_girl'
6
+ require 'vcr'
7
+
8
+ # Requires supporting ruby files with custom matchers and macros, etc,
9
+ # in spec/support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ RSpec.configure do |config|
13
+ # == Mock Framework
14
+ #
15
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
16
+ #
17
+ # config.mock_with :mocha
18
+ # config.mock_with :flexmock
19
+ # config.mock_with :rr
20
+ config.mock_with :rspec
21
+
22
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
23
+ config.fixture_path = "#{::Rails.root}/../../spec/fixtures"
24
+
25
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
26
+ # examples within a transaction, remove the following line or assign false
27
+ # instead of true.
28
+ config.use_transactional_fixtures = true
29
+
30
+ config.extend ControllerMacros, :type => :controller
31
+
32
+ $original_sunspot_session = Sunspot.session
33
+
34
+ config.before do
35
+ Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session)
36
+ end
37
+
38
+ config.before :each, :solr => true do
39
+ Sunspot::Rails::Tester.start_original_sunspot_session
40
+ Sunspot.session = $original_sunspot_session
41
+ #Sunspot.remove_all!
42
+ end
43
+
44
+ config.extend VCR::RSpec::Macros
45
+ end
46
+
47
+ FactoryGirl.definition_file_paths << "#{::Rails.root}/../../spec/factories"
48
+ FactoryGirl.find_definitions
@@ -0,0 +1,48 @@
1
+ module ControllerMacros
2
+ def login_admin
3
+ before(:each) do
4
+ @request.env["devise.mapping"] = Devise.mappings[:admin]
5
+ sign_in Factory.create(:admin)
6
+ end
7
+ end
8
+
9
+ def login_librarian
10
+ before(:each) do
11
+ @request.env["devise.mapping"] = Devise.mappings[:user]
12
+ user = Factory.create(:librarian)
13
+ sign_in user
14
+ end
15
+ end
16
+
17
+ def login_user
18
+ before(:each) do
19
+ @request.env["devise.mapping"] = Devise.mappings[:user]
20
+ user = Factory.create(:user)
21
+ sign_in user
22
+ end
23
+ end
24
+
25
+ def login_fixture_admin
26
+ before(:each) do
27
+ @request.env["devise.mapping"] = Devise.mappings[:admin]
28
+ @user = users(:admin)
29
+ sign_in @user
30
+ end
31
+ end
32
+
33
+ def login_fixture_librarian
34
+ before(:each) do
35
+ @request.env["devise.mapping"] = Devise.mappings[:user]
36
+ @user = users(:librarian1)
37
+ sign_in @user
38
+ end
39
+ end
40
+
41
+ def login_fixture_user
42
+ before(:each) do
43
+ @request.env["devise.mapping"] = Devise.mappings[:user]
44
+ @user = users(:user1)
45
+ sign_in @user
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,4 @@
1
+ RSpec.configure do |config|
2
+ config.include Devise::TestHelpers, :type => :controller
3
+ config.include Devise::TestHelpers, :type => :view
4
+ end
@@ -0,0 +1,6 @@
1
+ VCR.configure do |c|
2
+ c.cassette_library_dir = 'spec/cassette_library'
3
+ c.hook_into :fakeweb
4
+ c.ignore_localhost = true
5
+ c.default_cassette_options = { :record => :none }
6
+ end