Skip to content

Commit b930950

Browse files
author
Nils Henning
committed
[REFACTOR] refactor vue_js_component_name implementation, make it inheritable
1 parent 75d54be commit b930950

File tree

4 files changed

+12
-289
lines changed

4 files changed

+12
-289
lines changed

app/concepts/matestack/ui/core/component/dynamic.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ def dynamic_tag_attributes
2424
end
2525

2626
def get_vue_js_name
27-
if @vue_js_component_name.present?
28-
@vue_js_component_name
29-
else
30-
self.class.vue_js_name
31-
end
27+
self.class.vue_js_name
3228
end
3329

3430
class << self
31+
32+
def inherited(subclass)
33+
subclass.vue_js_component_name vue_js_name unless self == Matestack::Ui::Core::Component::Dynamic
34+
end
35+
3536
def vue_js_component_name(name)
3637
@vue_js_name = name.to_s
3738
end

app/concepts/matestack/ui/core/isolate/isolate.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ class Isolate < Matestack::Ui::Core::Component::Dynamic
66
def initialize(*args)
77
super
88
@public_options = args.map { |hash| hash[:public_options] }[0]
9-
# using this instance var here as users inherit from this class and would need
10-
# to use `vue_js_component_name "matestack-ui-core-isolate"` in their components
11-
# which is not convinient
12-
@vue_js_component_name = "matestack-ui-core-isolate"
139
end
1410

1511
def public_options

spec/test/components/dynamic/isolate/isolate_spec.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def response
7070
end
7171

7272
visit "/example"
73-
7473
# used on page
7574
expect(page).to have_xpath('//div[@id="page-div"]/div[@class="matestack-isolated-component-container"]/div[@class="matestack-isolated-component-wrapper"]/div[@class="some-isolated-component"]/span[@id="text" and contains(.,"some isolated compenent")]')
7675

@@ -161,7 +160,7 @@ def response
161160
class SomeNonAuthorizedIsolatedComponent < Matestack::Ui::IsolatedComponent
162161

163162
def response
164-
span text: "should't work, because authorized? method is not implemented"
163+
span text: "shouldn't work, because authorized? method is not implemented"
165164
end
166165

167166

@@ -182,19 +181,19 @@ def response
182181
visit "/example"
183182

184183
expect(page).to have_content("page!") # rest of the page still works
185-
expect(page).not_to have_content("should't work, because authorized? method is not implemented")
184+
expect(page).not_to have_content("shouldn't work, because authorized? method is not implemented")
186185
expect(page).not_to have_content("please implement the `authorized? method") # async request gets that error, so it's not visible
187186

188187
visit "/example?component_class=SomeNonAuthorizedIsolatedComponent"
189188

190189
expect(page).not_to have_content("page!") # page is not requested
191-
expect(page).not_to have_content("should't work, because authorized? method is not implemented")
190+
expect(page).not_to have_content("shouldn't work, because authorized? method is not implemented")
192191
expect(page).to have_content("please implement the `authorized? method")
193192

194193
class SomeForbiddenIsolatedComponent < Matestack::Ui::IsolatedComponent
195194

196195
def response
197-
span text: "should't work, because authorized? method is returning false"
196+
span text: "shouldn't work, because authorized? method is returning false"
198197
end
199198

200199
def authorized?
@@ -218,13 +217,13 @@ def response
218217
visit "/example"
219218

220219
expect(page).to have_content("page!") # rest of the page still works
221-
expect(page).not_to have_content("should't work, because authorized? method is returning false")
220+
expect(page).not_to have_content("shouldn't work, because authorized? method is returning false")
222221
expect(page).not_to have_content("not authorized") # async request gets that error, so it's not visible
223222

224223
visit "/example?component_class=SomeForbiddenIsolatedComponent"
225224

226225
expect(page).not_to have_content("page!") # page is not requested
227-
expect(page).not_to have_content("should't work, because authorized? method is returning false")
226+
expect(page).not_to have_content("shouldn't work, because authorized? method is returning false")
228227
expect(page).to have_content("not authorized")
229228

230229

@@ -302,7 +301,6 @@ def response
302301

303302
visit "/example"
304303

305-
# sleep
306304
page_timestamp = page.find('#page-timestamp').text.to_i
307305
component_timestamp = page.find('#isolated-component-timestamp').text.to_i
308306

spec/test/components/isolate_spec.rb

Lines changed: 0 additions & 272 deletions
This file was deleted.

0 commit comments

Comments
 (0)