enju_event 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +36 -0
- data/app/controllers/calendar_controller.rb +34 -0
- data/app/controllers/event_categories_controller.rb +18 -0
- data/app/controllers/event_import_files_controller.rb +95 -0
- data/app/controllers/event_import_results_controller.rb +15 -0
- data/app/controllers/events_controller.rb +152 -0
- data/app/controllers/participates_controller.rb +81 -0
- data/app/helpers/calendar_helper.rb +31 -0
- data/app/models/event.rb +87 -0
- data/app/models/event_category.rb +23 -0
- data/app/models/event_import_file.rb +166 -0
- data/app/models/event_import_result.rb +23 -0
- data/app/models/participate.rb +25 -0
- data/app/views/calendar/index.html.erb +45 -0
- data/app/views/event_categories/_form.html.erb +19 -0
- data/app/views/event_categories/edit.html.erb +13 -0
- data/app/views/event_categories/index.html.erb +46 -0
- data/app/views/event_categories/new.html.erb +12 -0
- data/app/views/event_categories/show.html.erb +29 -0
- data/app/views/event_import_files/edit.html.erb +25 -0
- data/app/views/event_import_files/index.html.erb +40 -0
- data/app/views/event_import_files/new.html.erb +37 -0
- data/app/views/event_import_files/show.html.erb +64 -0
- data/app/views/event_import_results/index.csv.erb +3 -0
- data/app/views/event_import_results/index.html.erb +50 -0
- data/app/views/event_import_results/show.html.erb +33 -0
- data/app/views/events/_all_day.html.erb +24 -0
- data/app/views/events/_form.html.erb +44 -0
- data/app/views/events/edit.html.erb +14 -0
- data/app/views/events/index.atom.builder +10 -0
- data/app/views/events/index.csv.erb +4 -0
- data/app/views/events/index.html.erb +105 -0
- data/app/views/events/index.ics.erb +13 -0
- data/app/views/events/index.mobile.erb +49 -0
- data/app/views/events/index.rss.builder +34 -0
- data/app/views/events/new.html.erb +17 -0
- data/app/views/events/show.html.erb +50 -0
- data/app/views/events/show.mobile.erb +42 -0
- data/app/views/participates/edit.html.erb +28 -0
- data/app/views/participates/index.html.erb +30 -0
- data/app/views/participates/new.html.erb +27 -0
- data/app/views/participates/show.html.erb +24 -0
- data/config/routes.rb +10 -0
- data/db/fixtures/event_categories.yml +13 -0
- data/db/migrate/113_create_events.rb +23 -0
- data/db/migrate/114_create_event_categories.rb +16 -0
- data/db/migrate/20081028093607_create_event_import_files.rb +29 -0
- data/db/migrate/20090519203307_create_participates.rb +17 -0
- data/db/migrate/20100925074639_create_event_import_results.rb +15 -0
- data/lib/enju_event.rb +5 -0
- data/lib/enju_event/engine.rb +18 -0
- data/lib/enju_event/version.rb +3 -0
- data/lib/tasks/enju_event_tasks.rake +5 -0
- data/spec/controllers/event_categories_controller_spec.rb +483 -0
- data/spec/controllers/event_import_files_controller_spec.rb +321 -0
- data/spec/controllers/events_controller_spec.rb +506 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +99 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/notifier.rb +28 -0
- data/spec/dummy/app/models/ability.rb +39 -0
- data/spec/dummy/app/models/language.rb +4 -0
- data/spec/dummy/app/models/library.rb +128 -0
- data/spec/dummy/app/models/library_group.rb +86 -0
- data/spec/dummy/app/models/patron.rb +163 -0
- data/spec/dummy/app/models/patron_type.rb +19 -0
- data/spec/dummy/app/models/role.rb +8 -0
- data/spec/dummy/app/models/shelf.rb +54 -0
- data/spec/dummy/app/models/user.rb +43 -0
- data/spec/dummy/app/models/user_group.rb +2 -0
- data/spec/dummy/app/models/user_has_role.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/page/403.html.erb +9 -0
- data/spec/dummy/app/views/page/403.mobile.erb +5 -0
- data/spec/dummy/app/views/page/403.xml.erb +4 -0
- data/spec/dummy/app/views/page/404.html.erb +9 -0
- data/spec/dummy/app/views/page/404.mobile.erb +5 -0
- data/spec/dummy/app/views/page/404.xml.erb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +209 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +7 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/db/migrate/001_create_patrons.rb +62 -0
- data/spec/dummy/db/migrate/059_create_libraries.rb +34 -0
- data/spec/dummy/db/migrate/069_create_shelves.rb +19 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +25 -0
- data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +16 -0
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +27 -0
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100527113752_create_delayed_jobs.rb +21 -0
- data/spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +11 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +14 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
- data/spec/dummy/db/migrate/20111201163342_create_user_groups.rb +12 -0
- data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
- data/spec/dummy/db/schema.rb +293 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/enju_leaf.rb +4 -0
- data/spec/dummy/lib/enju_leaf/import_file.rb +13 -0
- data/spec/dummy/lib/enju_leaf/localized_name.rb +13 -0
- data/spec/dummy/lib/enju_leaf/master_model.rb +41 -0
- data/spec/dummy/lib/enju_leaf/url_validator.rb +10 -0
- data/spec/dummy/log/sunspot-solr-test.log +222 -0
- data/spec/dummy/log/test.log +145759 -0
- data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample1.tsv +5 -0
- data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample2.tsv +3 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/solr/conf/admin-extra.html +31 -0
- data/spec/dummy/solr/conf/elevate.xml +36 -0
- data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/spec/dummy/solr/conf/protwords.txt +21 -0
- data/spec/dummy/solr/conf/schema.xml +238 -0
- data/spec/dummy/solr/conf/scripts.conf +24 -0
- data/spec/dummy/solr/conf/solrconfig.xml +934 -0
- data/spec/dummy/solr/conf/spellings.txt +2 -0
- data/spec/dummy/solr/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/conf/synonyms.txt +31 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_1 +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
- data/spec/factories/event.rb +7 -0
- data/spec/factories/event_category.rb +5 -0
- data/spec/factories/library.rb +13 -0
- data/spec/factories/user.rb +34 -0
- data/spec/fixtures/event_categories.yml +55 -0
- data/spec/fixtures/event_import_files.yml +49 -0
- data/spec/fixtures/event_import_results.yml +24 -0
- data/spec/fixtures/events.yml +142 -0
- data/spec/fixtures/languages.yml +1901 -0
- data/spec/fixtures/libraries.yml +108 -0
- data/spec/fixtures/library_groups.yml +34 -0
- data/spec/fixtures/patron_types.yml +35 -0
- data/spec/fixtures/patrons.yml +338 -0
- data/spec/fixtures/roles.yml +21 -0
- data/spec/fixtures/shelves.yml +46 -0
- data/spec/fixtures/user_groups.yml +25 -0
- data/spec/fixtures/user_has_roles.yml +41 -0
- data/spec/fixtures/users.yml +69 -0
- data/spec/models/event_category_spec.rb +21 -0
- data/spec/models/event_import_file_spec.rb +62 -0
- data/spec/models/event_import_result_spec.rb +20 -0
- data/spec/models/event_spec.rb +39 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/controller_macros.rb +48 -0
- data/spec/support/devise.rb +4 -0
- metadata +541 -0
@@ -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,46 @@
|
|
1
|
+
---
|
2
|
+
shelf_00001:
|
3
|
+
name: web
|
4
|
+
display_name: Library bookmark
|
5
|
+
id: 1
|
6
|
+
note:
|
7
|
+
library_id: 1
|
8
|
+
position: 1
|
9
|
+
shelf_00002:
|
10
|
+
name: first_shelf
|
11
|
+
display_name: First shelf
|
12
|
+
id: 2
|
13
|
+
note:
|
14
|
+
library_id: 2
|
15
|
+
position: 2
|
16
|
+
shelf_00003:
|
17
|
+
name: second_shelf
|
18
|
+
display_name: Second shelf
|
19
|
+
id: 3
|
20
|
+
note:
|
21
|
+
library_id: 2
|
22
|
+
position: 3
|
23
|
+
shelf_00004:
|
24
|
+
name: third_shelf
|
25
|
+
display_name: Third shelf
|
26
|
+
id: 4
|
27
|
+
note:
|
28
|
+
library_id: 3
|
29
|
+
position: 4
|
30
|
+
|
31
|
+
# == Schema Information
|
32
|
+
#
|
33
|
+
# Table name: shelves
|
34
|
+
#
|
35
|
+
# id :integer not null, primary key
|
36
|
+
# name :string(255) not null
|
37
|
+
# display_name :text
|
38
|
+
# note :text
|
39
|
+
# library_id :integer default(1), not null
|
40
|
+
# items_count :integer default(0), not null
|
41
|
+
# position :integer
|
42
|
+
# created_at :datetime
|
43
|
+
# updated_at :datetime
|
44
|
+
# deleted_at :datetime
|
45
|
+
#
|
46
|
+
|
@@ -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,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe EventCategory do
|
5
|
+
#pending "add some examples to (or delete) #{__FILE__}"
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
# == Schema Information
|
10
|
+
#
|
11
|
+
# Table name: event_categories
|
12
|
+
#
|
13
|
+
# id :integer not null, primary key
|
14
|
+
# name :string(255) not null
|
15
|
+
# display_name :text
|
16
|
+
# note :text
|
17
|
+
# position :integer
|
18
|
+
# created_at :datetime
|
19
|
+
# updated_at :datetime
|
20
|
+
#
|
21
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe EventImportFile do
|
5
|
+
#pending "add some examples to (or delete) #{__FILE__}"
|
6
|
+
|
7
|
+
describe "When it is written in utf-8" do
|
8
|
+
before(:each) do
|
9
|
+
@file = EventImportFile.create :event_import => File.new("#{Rails.root.to_s}/../../examples/event_import_file_sample1.tsv")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be imported" do
|
13
|
+
closing_days_size = Event.closing_days.size
|
14
|
+
old_events_count = Event.count
|
15
|
+
old_import_results_count = EventImportResult.count
|
16
|
+
@file.import_start.should eq({:imported => 3, :failed => 0})
|
17
|
+
Event.count.should eq old_events_count + 3
|
18
|
+
Event.closing_days.size.should eq closing_days_size + 1
|
19
|
+
EventImportResult.count.should eq old_import_results_count + 4
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "When it is written in shift_jis" do
|
24
|
+
before(:each) do
|
25
|
+
@file = EventImportFile.create :event_import => File.new("#{Rails.root.to_s}/../../examples/event_import_file_sample2.tsv")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be imported" do
|
29
|
+
old_event_count = Event.count
|
30
|
+
old_import_results_count = EventImportResult.count
|
31
|
+
@file.import_start
|
32
|
+
Event.order('id DESC').first.name.should eq '日本語の催し物2'
|
33
|
+
Event.count.should eq old_event_count + 2
|
34
|
+
EventImportResult.count.should eq old_import_results_count + 3
|
35
|
+
Event.order('id DESC').first.start_at.should eq Time.zone.parse('2011-03-26').beginning_of_day
|
36
|
+
Event.order('id DESC').first.end_at.to_s.should eq Time.zone.parse('2011-03-27').end_of_day.to_s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# == Schema Information
|
42
|
+
#
|
43
|
+
# Table name: event_import_files
|
44
|
+
#
|
45
|
+
# id :integer not null, primary key
|
46
|
+
# parent_id :integer
|
47
|
+
# content_type :string(255)
|
48
|
+
# size :integer
|
49
|
+
# file_hash :string(255)
|
50
|
+
# user_id :integer
|
51
|
+
# note :text
|
52
|
+
# imported_at :datetime
|
53
|
+
# state :string(255)
|
54
|
+
# event_import_file_name :string(255)
|
55
|
+
# event_import_content_type :string(255)
|
56
|
+
# event_import_file_size :integer
|
57
|
+
# event_import_updated_at :datetime
|
58
|
+
# created_at :datetime
|
59
|
+
# updated_at :datetime
|
60
|
+
# edit_mode :string(255)
|
61
|
+
#
|
62
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe EventImportResult do
|
5
|
+
#pending "add some examples to (or delete) #{__FILE__}"
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
# == Schema Information
|
10
|
+
#
|
11
|
+
# Table name: event_import_results
|
12
|
+
#
|
13
|
+
# id :integer not null, primary key
|
14
|
+
# event_import_file_id :integer
|
15
|
+
# event_id :integer
|
16
|
+
# body :text
|
17
|
+
# created_at :datetime
|
18
|
+
# updated_at :datetime
|
19
|
+
#
|
20
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Event do
|
5
|
+
fixtures :events
|
6
|
+
|
7
|
+
it "should set_all_day" do
|
8
|
+
event = events(:event_00001)
|
9
|
+
event.all_day = true
|
10
|
+
event.set_all_day
|
11
|
+
event.all_day.should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should set all_day and beginning_of_day" do
|
15
|
+
event = events(:event_00008)
|
16
|
+
event.all_day = true
|
17
|
+
event.set_all_day
|
18
|
+
event.start_at.should eq event.end_at.beginning_of_day
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# == Schema Information
|
23
|
+
#
|
24
|
+
# Table name: events
|
25
|
+
#
|
26
|
+
# id :integer not null, primary key
|
27
|
+
# library_id :integer default(1), not null
|
28
|
+
# event_category_id :integer default(1), not null
|
29
|
+
# name :string(255)
|
30
|
+
# note :text
|
31
|
+
# start_at :datetime
|
32
|
+
# end_at :datetime
|
33
|
+
# all_day :boolean default(FALSE), not null
|
34
|
+
# deleted_at :datetime
|
35
|
+
# created_at :datetime
|
36
|
+
# updated_at :datetime
|
37
|
+
# display_name :text
|
38
|
+
#
|
39
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,45 @@
|
|
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
|
+
|
7
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
8
|
+
# in spec/support/ and its subdirectories.
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
# == Mock Framework
|
13
|
+
#
|
14
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
15
|
+
#
|
16
|
+
# config.mock_with :mocha
|
17
|
+
# config.mock_with :flexmock
|
18
|
+
# config.mock_with :rr
|
19
|
+
config.mock_with :rspec
|
20
|
+
|
21
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
22
|
+
config.fixture_path = "#{::Rails.root}/../../spec/fixtures"
|
23
|
+
|
24
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
25
|
+
# examples within a transaction, remove the following line or assign false
|
26
|
+
# instead of true.
|
27
|
+
config.use_transactional_fixtures = true
|
28
|
+
|
29
|
+
config.extend ControllerMacros, :type => :controller
|
30
|
+
|
31
|
+
$original_sunspot_session = Sunspot.session
|
32
|
+
|
33
|
+
config.before do
|
34
|
+
Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session)
|
35
|
+
end
|
36
|
+
|
37
|
+
config.before :each, :solr => true do
|
38
|
+
Sunspot::Rails::Tester.start_original_sunspot_session
|
39
|
+
Sunspot.session = $original_sunspot_session
|
40
|
+
#Sunspot.remove_all!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
FactoryGirl.definition_file_paths << "#{::Rails.root}/../../spec/factories"
|
45
|
+
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
|