card 1.93.3 → 1.93.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/db/migrate/20170908114452_increase_text_size_for_delayed_jobs.rb +9 -0
- data/db/migrate_core_cards/data/cards/*header +2 -2
- data/lib/card/format/nest.rb +12 -5
- data/lib/card/format/nest/fetch.rb +1 -2
- data/lib/card/format/render.rb +2 -2
- data/lib/card/model/save_helper.rb +1 -1
- data/lib/card/set/format/haml_views.rb +7 -3
- data/lib/card/subcards.rb +27 -228
- data/lib/card/subcards/add.rb +121 -0
- data/lib/card/subcards/relate.rb +27 -0
- data/lib/card/subcards/remove.rb +42 -0
- data/lib/card/tasks/card/create.rake +35 -132
- data/lib/card/tasks/card/file_card_creator.rb +25 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card.rb +44 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card/migration_file.rb +49 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card/ruby_file.rb +30 -0
- data/lib/card/tasks/card/file_card_creator/abstract_file_card/source_file.rb +36 -0
- data/lib/card/tasks/card/file_card_creator/haml_card.rb +42 -0
- data/lib/card/tasks/card/file_card_creator/output_helper.rb +50 -0
- data/lib/card/tasks/card/file_card_creator/script_card.rb +33 -0
- data/lib/card/tasks/card/file_card_creator/style_card.rb +25 -0
- data/lib/generators/card/template/template_generator.rb +1 -1
- data/mod/account/set/self/account_links.rb +1 -1
- data/mod/basic_formats/set/all/all_csv.rb +63 -0
- data/mod/basic_formats/set/all/json.rb +4 -1
- data/mod/bootstrap/db/migrate_cards/20170719163733_update_bootswatch_themes_to_4_beta.rb +5 -2
- data/mod/carrierwave/set/abstract/attachment.rb +1 -2
- data/mod/core/set/abstract/haml_file.rb +20 -0
- data/mod/core/set/all/chunk.rb +125 -0
- data/mod/core/set/all/collection.rb +2 -351
- data/mod/core/set/all/content.rb +26 -7
- data/mod/core/set/all/extended.rb +45 -0
- data/mod/core/set/all/haml.rb +3 -7
- data/mod/core/set/all/item.rb +92 -0
- data/mod/core/set/all/name.rb +36 -0
- data/mod/core/set/all/subcards.rb +21 -12
- data/mod/core/set/all/tabs.rb +50 -0
- data/mod/core/set/all/trash.rb +4 -0
- data/mod/core/spec/set/all/chunk_spec.rb +45 -0
- data/mod/core/spec/set/all/collection_spec.rb +6 -6
- data/mod/history/set/all/action_view.rb +1 -1
- data/mod/machines/lib/javascript/decko.js.coffee +3 -0
- data/mod/pointer/set/abstract/02_pointer/edit.rb +0 -2
- data/mod/search/set/abstract/search.rb +1 -1
- data/mod/search/set/all/filter.rb +0 -2
- data/mod/search/template/all/filter/_filter_input.haml +1 -1
- data/mod/search/template/all/filter/filter_form.haml +1 -1
- data/mod/standard/set/all/rich_html/editing.rb +1 -1
- data/mod/standard/set/all/rich_html/form.rb +6 -7
- data/mod/standard/set/all/rich_html/menu.rb +2 -3
- data/mod/standard/set/all/rich_html/toolbar.rb +3 -4
- data/mod/standard/set/type/cardtype.rb +1 -1
- data/mod/standard/spec/set/all/rich_html/editing_spec.rb +15 -4
- data/mod/tinymce_editor/db/migrate_cards/{20171113233150_update_tinymce_config.rb → 20171113233151_update_tinymce_config.rb} +1 -0
- metadata +25 -161
- data/.rspec +0 -4
- data/card.gemspec +0 -87
- data/db/seed/test/fixtures/.gitkeep +0 -0
- data/mod/bootstrap/vendor/bootstrap/.babelrc.js +0 -16
- data/mod/bootstrap/vendor/bootstrap/.editorconfig +0 -17
- data/mod/bootstrap/vendor/bootstrap/.eslintignore +0 -3
- data/mod/bootstrap/vendor/bootstrap/.gitattributes +0 -16
- data/mod/bootstrap/vendor/bootstrap/.github/CONTRIBUTING.md +0 -252
- data/mod/bootstrap/vendor/bootstrap/.github/ISSUE_TEMPLATE.md +0 -22
- data/mod/bootstrap/vendor/bootstrap/.gitignore +0 -46
- data/mod/bootstrap/vendor/bootstrap/.hound.yml +0 -19
- data/mod/bootstrap/vendor/bootstrap/.houndignore +0 -4
- data/mod/bootstrap/vendor/bootstrap/.travis.yml +0 -32
- data/mod/bootstrap/vendor/bootstrap/build/.htmllintrc +0 -19
- data/mod/bootstrap/vendor/bootstrap/build/.stylelintrc +0 -248
- data/mod/bootstrap/vendor/bootstrap/docs/4.0/examples/.stylelintrc +0 -12
- data/mod/bootstrap/vendor/bootstrap/js/.eslintrc.json +0 -240
- data/mod/bootstrap/vendor/bootstrap/js/tests/.eslintrc.json +0 -46
- data/mod/bootstrap/vendor/bootswatch/.gitignore +0 -7
- data/mod/bootstrap/vendor/bootswatch/.npmignore +0 -12
- data/mod/bootstrap/vendor/bootswatch/.travis.yml +0 -21
- data/mod/bootstrap/vendor/bootswatch/docs/.nojekyll +0 -0
- data/mod/bootstrap/vendor/bootswatch/docs/2/.travis.yml +0 -15
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.bower.json +0 -20
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.gitignore +0 -37
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/.travis.yml +0 -3
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/bootstrap/js/.jshintrc +0 -12
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/jquery/.bower.json +0 -20
- data/mod/bootstrap/vendor/bootswatch/docs/2/bower_components/jquery/.gitignore +0 -1
- data/mod/bootstrap/vendor/bootswatch/docs/2/swatchmaker/.gitignore +0 -1
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap-sass-official/.bower.json +0 -45
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/.bower.json +0 -44
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/grunt/.jshintrc +0 -7
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/js/.jscsrc +0 -42
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/js/.jshintrc +0 -15
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/less/.csscomb.json +0 -304
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/bootstrap/less/.csslintrc +0 -19
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/font-awesome/.bower.json +0 -14
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/font-awesome/.gitignore +0 -32
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/html5shiv/.bower.json +0 -25
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/jquery/.bower.json +0 -38
- data/mod/bootstrap/vendor/bootswatch/docs/3/bower_components/respond/.bower.json +0 -20
- data/mod/bootstrap/vendor/select2/.editorconfig +0 -6
- data/mod/bootstrap/vendor/select2/.github/CONTRIBUTING.md +0 -204
- data/mod/bootstrap/vendor/select2/.github/ISSUE_TEMPLATE.md +0 -46
- data/mod/bootstrap/vendor/select2/.github/PULL_REQUEST_TEMPLATE.md +0 -13
- data/mod/bootstrap/vendor/select2/.gitignore +0 -3
- data/mod/bootstrap/vendor/select2/.jshintignore +0 -4
- data/mod/bootstrap/vendor/select2/.jshintrc +0 -25
- data/mod/bootstrap/vendor/select2/.travis.yml +0 -22
- data/script/fetch_bootswatch_themes.rb +0 -38
- data/spec/config/initializers/core_extensions_spec.rb +0 -47
- data/spec/config/initializers/patches/active_job_spec.rb +0 -7
- data/spec/lib/card/action_spec.rb +0 -15
- data/spec/lib/card/auth_spec.rb +0 -58
- data/spec/lib/card/cache_spec.rb +0 -116
- data/spec/lib/card/chunk_spec.rb +0 -18
- data/spec/lib/card/codename_spec.rb +0 -66
- data/spec/lib/card/content_spec.rb +0 -428
- data/spec/lib/card/diff_spec.rb +0 -208
- data/spec/lib/card/format/nest_spec.rb +0 -13
- data/spec/lib/card/format/render_spec.rb +0 -26
- data/spec/lib/card/format_spec.rb +0 -117
- data/spec/lib/card/i18n_spec.rb +0 -24
- data/spec/lib/card/loader/Modfile +0 -2
- data/spec/lib/card/loader_spec.rb +0 -98
- data/spec/lib/card/migration/import_spec.rb +0 -80
- data/spec/lib/card/mod/loader/mod_dirs.rb +0 -8
- data/spec/lib/card/mod/loader/set_loader_spec.rb +0 -19
- data/spec/lib/card/mod/loader/set_pattern_loader_spec.rb +0 -19
- data/spec/lib/card/name/fields_and_traits_spec.rb +0 -18
- data/spec/lib/card/name_spec.rb +0 -70
- data/spec/lib/card/query/sorting_spec.rb +0 -68
- data/spec/lib/card/query_spec.rb +0 -574
- data/spec/lib/card/reference_spec.rb +0 -212
- data/spec/lib/card/set/event_spec.rb +0 -22
- data/spec/lib/card/set/trait_spec.rb +0 -80
- data/spec/lib/card/set_pattern_spec.rb +0 -59
- data/spec/lib/card/set_spec.rb +0 -89
- data/spec/lib/card/stage_director_spec.rb +0 -482
- data/spec/lib/card/subcards_spec.rb +0 -177
- data/spec/lib/card/success_spec.rb +0 -148
- data/spec/lib/card/view_cache_spec.rb +0 -27
- data/spec/mailers/mailer_spec.rb +0 -62
- data/spec/models/card/create_spec.rb +0 -119
- data/spec/models/card/trash_spec.rb +0 -189
- data/spec/models/card_spec.rb +0 -136
- data/spec/spec_helper.rb +0 -45
- data/spec/support/card_spec_helper.rb +0 -74
- data/spec/support/card_spec_loader.rb +0 -112
- data/spec/support/helper/card_helper.rb +0 -58
- data/spec/support/helper/event_helper.rb +0 -94
- data/spec/support/helper/render_helper.rb +0 -44
- data/spec/support/helper/save_helper.rb +0 -30
- data/spec/support/helper/set_helper.rb +0 -80
- data/spec/support/matchers/card_matchers.rb +0 -160
- data/spec/support/matchers/expectations.rb +0 -5
- data/spec/support/matchers/file_matchers.rb +0 -71
- data/spec/support/matchers/html_matchers.rb +0 -29
- data/spec/support/matchers/negated_matchers.rb +0 -2
- data/spec/support/simplecov_helper.rb +0 -70
- data/spec/support/test_mods/mod1/set/all/test_set.rb +0 -3
- data/spec/support/test_mods/mod2/set_pattern/test_pattern.rb +0 -0
@@ -1,189 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
require "card/action"
|
4
|
-
|
5
|
-
describe Card, "deleting card" do
|
6
|
-
it "requires permission" do
|
7
|
-
a = Card["a"]
|
8
|
-
Card::Auth.as :anonymous do
|
9
|
-
expect(a.ok?(:delete)).to eq(false)
|
10
|
-
expect(a.delete).to eq(false)
|
11
|
-
expect(a.errors[:permission_denied]).not_to be_empty
|
12
|
-
expect(Card["a"].trash).to eq(false)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe Card, "in trash" do
|
18
|
-
it "is retrieved by fetch with new" do
|
19
|
-
Card.create(name: "Betty").delete
|
20
|
-
c = Card.fetch "Betty", new: {}
|
21
|
-
c.save
|
22
|
-
expect(Card["Betty"]).to be_instance_of(Card)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe Card, "plus cards" do
|
27
|
-
it "is deleted when root is" do
|
28
|
-
Card::Auth.as "joe_admin" do
|
29
|
-
c = Card.create! name: "zz+top"
|
30
|
-
root = Card["zz"]
|
31
|
-
root.delete
|
32
|
-
# Rails.logger.info "ERRORS = #{root.errors.full_messages*''}"
|
33
|
-
expect(Card.find(c.id).trash).to be_truthy
|
34
|
-
expect(Card["zz"]).to be_nil
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# NOT WORKING, BUT IT SHOULD
|
40
|
-
# describe Card, "a part of an unremovable card" do
|
41
|
-
# before do
|
42
|
-
# Card::Auth.as(Card::WagnBotID)
|
43
|
-
# # this ugly setup makes it so A+Admin is the actual user with edits..
|
44
|
-
# Card["Wagn Bot"].update_attributes! name: "A+Wagn Bot"
|
45
|
-
# end
|
46
|
-
# it "does not be removable" do
|
47
|
-
# @a = Card['A']
|
48
|
-
# @a.delete.should_not be_true
|
49
|
-
# end
|
50
|
-
# end
|
51
|
-
|
52
|
-
describe Card, "rename to trashed name" do
|
53
|
-
before do
|
54
|
-
Card::Auth.as_bot do
|
55
|
-
@a = Card["A"]
|
56
|
-
@b = Card["B"]
|
57
|
-
@a.delete! # trash
|
58
|
-
@b.update_attributes! name: "A", update_referers: true
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
it "renames b to a" do
|
63
|
-
expect(@b.name).to eq("A")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "renames a to a*trash" do
|
67
|
-
expect((c = Card.find(@a.id)).name.to_s).to eq("A*trash")
|
68
|
-
expect(c.name).to eq("A*trash")
|
69
|
-
expect(c.key).to eq("a*trash")
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe Card, "sent to trash" do
|
74
|
-
before do
|
75
|
-
Card::Auth.as_bot do
|
76
|
-
@c = Card["basicname"]
|
77
|
-
@c.delete!
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
it "is trash" do
|
82
|
-
expect(@c.trash).to eq(true)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "does not be findable by name" do
|
86
|
-
expect(Card["basicname"]).to eq(nil)
|
87
|
-
end
|
88
|
-
|
89
|
-
it "still has actions" do
|
90
|
-
expect(@c.actions.count).to eq(2)
|
91
|
-
expect(@c.last_change_on(:db_content).value).to eq("basiccontent")
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe Card, "revived from trash" do
|
96
|
-
before do
|
97
|
-
Card::Auth.as_bot do
|
98
|
-
Card["basicname"].delete!
|
99
|
-
|
100
|
-
@c = Card.create! name: "basicname", content: "revived content"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
it "does not be trash" do
|
105
|
-
expect(@c.trash).to eq(false)
|
106
|
-
end
|
107
|
-
|
108
|
-
it "has 3 actions" do
|
109
|
-
expect(@c.actions.count).to eq(3)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "still has old content" do
|
113
|
-
expect(@c.nth_action(1).value :db_content).to eq("basiccontent")
|
114
|
-
end
|
115
|
-
|
116
|
-
it "has the same content" do
|
117
|
-
expect(@c.content).to eq("revived content")
|
118
|
-
# Card.fetch(@c.name).content.should == 'revived content'
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe Card, "recreate trashed card via new" do
|
123
|
-
# before do
|
124
|
-
# Card::Auth.as(Card::WagnBotID)
|
125
|
-
# @c = Card.create! type: 'Basic', name: "BasicMe"
|
126
|
-
# end
|
127
|
-
|
128
|
-
# this test is known to be broken; we've worked around it for now
|
129
|
-
# it "deletes and recreate with a different cardtype" do
|
130
|
-
# @c.delete!
|
131
|
-
# @re_c = Card.new type: "Phrase", name: "BasicMe", content: "Banana"
|
132
|
-
# @re_c.save!
|
133
|
-
# end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe Card, "junction revival" do
|
137
|
-
before do
|
138
|
-
Card::Auth.as_bot do
|
139
|
-
@c = Card.create! name: "basicname+woot", content: "basiccontent"
|
140
|
-
@c.delete!
|
141
|
-
@c = Card.create! name: "basicname+woot", content: "revived content"
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
it "isn't trash" do
|
146
|
-
expect(@c.trash).to eq(false)
|
147
|
-
end
|
148
|
-
|
149
|
-
it "has 3 actions" do
|
150
|
-
expect(@c.actions.count).to eq(3)
|
151
|
-
end
|
152
|
-
|
153
|
-
it "still has old action" do
|
154
|
-
expect(@c.nth_action(1).value :db_content).to eq("basiccontent")
|
155
|
-
end
|
156
|
-
|
157
|
-
it "has old content" do
|
158
|
-
expect(@c.db_content).to eq("revived content")
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "remove tests" do
|
163
|
-
# I believe this is here to test a bug where cards with certain kinds of references
|
164
|
-
# would fail to delete. probably less of an issue now that delete is done through
|
165
|
-
# trash.
|
166
|
-
it "test_remove" do
|
167
|
-
assert Card["A"].delete!, "card should be deleteable"
|
168
|
-
assert_nil Card["A"]
|
169
|
-
end
|
170
|
-
|
171
|
-
example "recreate plus card name variant" do
|
172
|
-
Card.create(name: "rta+rtb").delete
|
173
|
-
Card["rta"].update_attributes name: "rta!"
|
174
|
-
Card.create! name: "rta!+rtb"
|
175
|
-
expect(Card["rta!+rtb"]).to be_a Card
|
176
|
-
expect(Card["rta!+rtb"].trash).to be_falsey
|
177
|
-
expect(Card.find_by_key("rtb*trash")).to be_nil
|
178
|
-
end
|
179
|
-
|
180
|
-
example "multiple trash collision" do
|
181
|
-
Card.create(name: "alpha").delete
|
182
|
-
3.times do
|
183
|
-
b = Card.create(name: "beta")
|
184
|
-
b.name = "alpha"
|
185
|
-
assert b.save!
|
186
|
-
b.delete
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
data/spec/models/card_spec.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
describe Card do
|
4
|
-
describe "test data" do
|
5
|
-
it "is findable by name" do
|
6
|
-
expect(Card["Wagn Bot"]).to be_a Card
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "creation" do
|
11
|
-
before(:each) do
|
12
|
-
Card::Auth.as_bot do
|
13
|
-
@b = Card.create! name: "New Card", content: "Great Content"
|
14
|
-
@c = Card.find(@b.id)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it "does not have errors" do expect(@b.errors.size).to eq(0) end
|
19
|
-
it "has the right class" do expect(@c.class).to eq(Card) end
|
20
|
-
it "has the right key" do expect(@c.key).to eq("new_card") end
|
21
|
-
it "has the right name" do expect(@c.name).to eq("New Card") end
|
22
|
-
it "has the right content" do expect(@c.content).to eq("Great Content") end
|
23
|
-
|
24
|
-
it "has the right content" do
|
25
|
-
expect(@c.db_content).to eq("Great Content")
|
26
|
-
expect(@c.content).to eq("Great Content")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "is findable by name" do
|
30
|
-
expect(Card["New Card"].class).to eq(Card)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "content change should create new action" do
|
35
|
-
before do
|
36
|
-
Card::Auth.as_bot do
|
37
|
-
@c = Card["basicname"]
|
38
|
-
@c.update_attributes! content: "foo"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
it "has 2 actions" do
|
43
|
-
expect(@c.actions.count).to eq(2)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "has original action" do
|
47
|
-
expect(@c.nth_action(1).value :db_content).to eq("basiccontent")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
example "creates a virtual card when missing" do
|
52
|
-
expect(Card.new(name: "A+*last edited")).to be_virtual
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "basic card tests" do
|
57
|
-
def assert_simple_card card
|
58
|
-
expect(card.name).to be, "name not null"
|
59
|
-
expect(card.name.empty?).to be_falsey, "name not empty"
|
60
|
-
action = card.last_action
|
61
|
-
expect(action).to be_instance_of Card::Action
|
62
|
-
expect(action.act.actor).to be_instance_of Card
|
63
|
-
end
|
64
|
-
|
65
|
-
def assert_samecard card1, card2
|
66
|
-
assert_equal card1, card2
|
67
|
-
end
|
68
|
-
|
69
|
-
def assert_stable card1
|
70
|
-
card2 = Card[card1.name]
|
71
|
-
assert_simple_card card1
|
72
|
-
assert_simple_card card2
|
73
|
-
assert_samecard card1, card2
|
74
|
-
assert_equal card1.right, card2.right
|
75
|
-
end
|
76
|
-
|
77
|
-
it "creates cards" do
|
78
|
-
alpha = Card.new name: "alpha", content: "alpha"
|
79
|
-
expect(alpha.content).to eq("alpha")
|
80
|
-
alpha.save
|
81
|
-
expect(alpha.name).to eq("alpha")
|
82
|
-
assert_stable alpha
|
83
|
-
end
|
84
|
-
|
85
|
-
it "does not find nonexistent" do
|
86
|
-
expect(Card["no such card+no such tag"]).to be_nil
|
87
|
-
expect(Card["HomeCard+no such tag"]).to be_nil
|
88
|
-
end
|
89
|
-
|
90
|
-
it "update_should_create_subcards" do
|
91
|
-
Card.create! name: "Banana"
|
92
|
-
Card["banana"].update_attributes! subcards: { "+peel" => { content: "yellow" } }
|
93
|
-
|
94
|
-
peel = Card["Banana+peel"]
|
95
|
-
expect(peel.content). to eq("yellow")
|
96
|
-
expect(Card["joe_user"].id).to eq(peel.creator_id)
|
97
|
-
end
|
98
|
-
|
99
|
-
it "update_should_create_subcards_as_wagn_bot_if_missing_subcard_permissions" do
|
100
|
-
Card.create name: "peel"
|
101
|
-
Card::Auth.current_id = Card::AnonymousID
|
102
|
-
expect(Card["Banana"]).not_to be
|
103
|
-
expect(Card["Basic"].ok?(:create)).to be_falsey, "anon can't creat"
|
104
|
-
|
105
|
-
Card.create! type: "Fruit", name: "Banana", subcards: { "+peel" => { content: "yellow" } }
|
106
|
-
expect(Card["Banana"]).to be
|
107
|
-
peel = Card["Banana+peel"]
|
108
|
-
|
109
|
-
expect(peel.db_content).to eq("yellow")
|
110
|
-
expect(peel.creator_id).to eq(Card::AnonymousID)
|
111
|
-
end
|
112
|
-
|
113
|
-
context "missing main card permissions" do
|
114
|
-
it "update doesn't create subcards" do
|
115
|
-
b = create! "Banana"
|
116
|
-
Card::Auth.as Card::AnonymousID do
|
117
|
-
b.update_attributes subcards: { "+peel" => { content: "yellow" } }
|
118
|
-
expect(b.errors[:permission_denied]).not_to be_empty
|
119
|
-
|
120
|
-
c = Card.update(b.id, subcards: { "+peel" => { content: "yellow" } })
|
121
|
-
expect(c.errors[:permission_denied]).not_to be_empty
|
122
|
-
expect(Card["Banana+peel"]).to be_nil
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
it "create_without_read_permission" do
|
129
|
-
c = Card.create!(name: "Banana", type: "Fruit", content: "mush")
|
130
|
-
Card::Auth.as Card::AnonymousID do
|
131
|
-
assert_raises Card::Error::PermissionDenied do
|
132
|
-
c.ok! :read
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
require File.expand_path("../support/card_spec_loader.rb", __FILE__)
|
4
|
-
CardSpecLoader.init
|
5
|
-
|
6
|
-
require "rr"
|
7
|
-
|
8
|
-
CardSpecLoader.prefork do
|
9
|
-
CARD_TEST_SEED_PATH = File.expand_path("../../db/seed/test/fixtures", __FILE__)
|
10
|
-
|
11
|
-
CardSpecLoader.rspec_config do |config|
|
12
|
-
# require 'card-rspec-formatter'
|
13
|
-
config.mock_with :rr
|
14
|
-
|
15
|
-
config.mock_with :rspec do |mocks|
|
16
|
-
mocks.syntax = [:should, :expect]
|
17
|
-
mocks.verify_partial_doubles = true
|
18
|
-
end
|
19
|
-
config.expect_with :rspec do |c|
|
20
|
-
c.syntax = [:should, :expect]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
Card["*all+*style"].ensure_machine_output
|
25
|
-
Card["*all+*script"].ensure_machine_output
|
26
|
-
(ie9 = Card[:script_html5shiv_printshiv]) && ie9.ensure_machine_output
|
27
|
-
end
|
28
|
-
|
29
|
-
CardSpecLoader.each_run do
|
30
|
-
# This code will be run each time you run your specs.
|
31
|
-
require "simplecov"
|
32
|
-
end
|
33
|
-
|
34
|
-
CardSpecLoader.helper
|
35
|
-
|
36
|
-
class ActiveSupport::Logger
|
37
|
-
def rspec msg, console_text=nil
|
38
|
-
if Thread.current["logger-output"]
|
39
|
-
Thread.current["logger-output"] << msg
|
40
|
-
else
|
41
|
-
puts console_text || msg
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
@@ -1,74 +0,0 @@
|
|
1
|
-
%w[helper matchers].each do |load_dir|
|
2
|
-
load_path = File.expand_path "../#{load_dir}/*.rb", __FILE__
|
3
|
-
Dir[load_path].each { |f| require f }
|
4
|
-
end
|
5
|
-
|
6
|
-
|
7
|
-
class Card
|
8
|
-
# to be included in RSpec::Core::ExampleGroup
|
9
|
-
module SpecHelper
|
10
|
-
include RenderHelper
|
11
|
-
include EventHelper
|
12
|
-
include SaveHelper
|
13
|
-
|
14
|
-
# ~~~~~~~~~ HELPER METHODS ~~~~~~~~~~~~~~~#
|
15
|
-
include Rails::Dom::Testing::Assertions::SelectorAssertions
|
16
|
-
|
17
|
-
def login_as user
|
18
|
-
Card::Auth.current_id = (uc = Card[user.to_s]) && uc.id
|
19
|
-
return unless @request
|
20
|
-
@request.session[:user] = Card::Auth.current_id
|
21
|
-
# warn "(ath)login_as #{user.inspect}, #{Card::Auth.current_id}, "\
|
22
|
-
# "#{@request.session[:user]}"
|
23
|
-
end
|
24
|
-
|
25
|
-
def assert_view_select view_html, *args, &block
|
26
|
-
node = Nokogiri::HTML::Document.parse(view_html).root
|
27
|
-
if block_given?
|
28
|
-
assert_select node, *args, &block
|
29
|
-
else
|
30
|
-
assert_select node, *args
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def debug_assert_view_select view_html, *args, &block
|
35
|
-
log_html view_html
|
36
|
-
assert_view_select view_html, *args, &block
|
37
|
-
end
|
38
|
-
|
39
|
-
def log_html html
|
40
|
-
parsed = CodeRay.scan(Nokogiri::XML(html, &:noblanks).to_s, :html)
|
41
|
-
if Rails.logger.respond_to? :rspec
|
42
|
-
Rails.logger.rspec "#{parsed.div}#{CODE_RAY_STYLE}"
|
43
|
-
else
|
44
|
-
puts parsed.text
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
CODE_RAY_STYLE = <<-HTML
|
49
|
-
<style>
|
50
|
-
.CodeRay {
|
51
|
-
background-color: #FFF;
|
52
|
-
border: 1px solid #CCC;
|
53
|
-
padding: 1em 0px 1em 1em;
|
54
|
-
}
|
55
|
-
.CodeRay .code pre { overflow: auto }
|
56
|
-
</style>
|
57
|
-
HTML
|
58
|
-
|
59
|
-
def users
|
60
|
-
SharedData::USERS.sort
|
61
|
-
end
|
62
|
-
|
63
|
-
def bucket_credentials key
|
64
|
-
@buckets ||= bucket_credentials_from_yml_file || {}
|
65
|
-
@buckets[key]
|
66
|
-
end
|
67
|
-
|
68
|
-
def bucket_credentials_from_yml_file
|
69
|
-
yml_file = ENV["BUCKET_CREDENTIALS_PATH"] ||
|
70
|
-
File.expand_path("../bucket_credentials.yml", __FILE__)
|
71
|
-
File.exist?(yml_file) && YAML.load_file(yml_file).deep_symbolize_keys
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
class CardSpecLoader
|
2
|
-
class << self
|
3
|
-
def init
|
4
|
-
require "spork"
|
5
|
-
ENV["RAILS_ENV"] = "test"
|
6
|
-
require "timecop"
|
7
|
-
end
|
8
|
-
|
9
|
-
def prefork
|
10
|
-
Spork.prefork do
|
11
|
-
unless ENV["RAILS_ROOT"]
|
12
|
-
raise Card::Error, "No RAILS_ROOT given. Can't load environment."
|
13
|
-
end
|
14
|
-
require File.join ENV["RAILS_ROOT"], "config/environment"
|
15
|
-
load_shared_examples
|
16
|
-
require File.expand_path("../simplecov_helper.rb", __FILE__)
|
17
|
-
require File.expand_path("../../../db/seed/test/seed.rb", __FILE__)
|
18
|
-
|
19
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
20
|
-
# in spec/support/ and its subdirectories.
|
21
|
-
Dir[File.join(Cardio.gem_root, "spec/support/matchers/*.rb")].each do |f|
|
22
|
-
require f
|
23
|
-
end
|
24
|
-
yield if block_given?
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def each_run
|
29
|
-
# This code will be run each time you run your specs.
|
30
|
-
yield if block_given?
|
31
|
-
end
|
32
|
-
|
33
|
-
def rspec_config
|
34
|
-
require "rspec/rails"
|
35
|
-
|
36
|
-
@@joe_user_id = Card["joe_user"].id
|
37
|
-
RSpec.configure do |config|
|
38
|
-
config.include RSpec::Rails::Matchers::RoutingMatchers,
|
39
|
-
file_path: %r{\bspec/controllers/}
|
40
|
-
config.include RSpecHtmlMatchers
|
41
|
-
# format_index = ARGV.find_index {|arg| arg =~ /--format|-f/ }
|
42
|
-
# formatter = format_index ? ARGV[ format_index + 1 ] : 'documentation'
|
43
|
-
# config.default_formatter=formatter
|
44
|
-
|
45
|
-
config.infer_spec_type_from_file_location!
|
46
|
-
# config.include CustomMatchers
|
47
|
-
# config.include ControllerMacros, type: :controllers
|
48
|
-
|
49
|
-
# == Mock Framework
|
50
|
-
# If you prefer to mock with mocha, flexmock or RR,
|
51
|
-
# uncomment the appropriate symbol:
|
52
|
-
# :mocha, :flexmock, :rr
|
53
|
-
|
54
|
-
config.use_transactional_fixtures = true
|
55
|
-
config.use_instantiated_fixtures = false
|
56
|
-
|
57
|
-
config.before(:each) do |example|
|
58
|
-
Delayed::Worker.delay_jobs = false
|
59
|
-
unless example.metadata[:as_bot]
|
60
|
-
user_id =
|
61
|
-
case example.metadata[:with_user]
|
62
|
-
when String
|
63
|
-
Card.fetch_id example.metadata[:with_user]
|
64
|
-
when Card
|
65
|
-
Card.id
|
66
|
-
when Integer
|
67
|
-
example.metadata[:with_user]
|
68
|
-
else
|
69
|
-
@@joe_user_id
|
70
|
-
end
|
71
|
-
Card::Auth.current_id = user_id
|
72
|
-
end
|
73
|
-
Card::Cache.restore
|
74
|
-
Card::Env.reset
|
75
|
-
end
|
76
|
-
|
77
|
-
config.around(:example, :as_bot) do |example|
|
78
|
-
Card::Auth.current_id = @@joe_user_id
|
79
|
-
Card::Auth.as_bot do
|
80
|
-
example.run
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
config.after(:each) do
|
85
|
-
Timecop.return
|
86
|
-
end
|
87
|
-
yield config if block_given?
|
88
|
-
|
89
|
-
# # only needed for < 3.5.0
|
90
|
-
# [:controller, :view, :request].each do |type|
|
91
|
-
# config.include ::Rails::Controller::Testing::TestProcess, :type => type
|
92
|
-
# config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type
|
93
|
-
# config.include ::Rails::Controller::Testing::Integration, :type => type
|
94
|
-
# end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def helper
|
99
|
-
require File.expand_path "../card_spec_helper.rb", __FILE__
|
100
|
-
RSpec::Core::ExampleGroup.send :include, Card::SpecHelper
|
101
|
-
Card.send :include, Card::SpecHelper::CardHelper
|
102
|
-
Card.send :include, Card::SpecHelper::SetHelper
|
103
|
-
Card.send :extend, Card::SpecHelper::CardHelper::ClassMethods
|
104
|
-
end
|
105
|
-
|
106
|
-
def load_shared_examples
|
107
|
-
Card::Mod.dirs.each "spec/shared_examples" do |shared_ex_dir|
|
108
|
-
Dir["#{shared_ex_dir}/**/*.rb"].sort.each { |f| require f }
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|