type_station 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/lib/type_station/version.rb +1 -1
  3. data/spec/controllers/type_station/admin/pages_controller_spec.rb +37 -0
  4. data/spec/dummy/README.rdoc +28 -0
  5. data/spec/dummy/Rakefile +6 -0
  6. data/spec/dummy/app/assets/javascripts/application.js +14 -0
  7. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  8. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  9. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  10. data/spec/dummy/app/views/layouts/application.html.erb +17 -0
  11. data/spec/dummy/app/views/pages/blank_index.html.erb +0 -0
  12. data/spec/dummy/app/views/pages/index_other.html.erb +160 -0
  13. data/spec/dummy/bin/bundle +3 -0
  14. data/spec/dummy/bin/rails +4 -0
  15. data/spec/dummy/bin/rake +4 -0
  16. data/spec/dummy/config.ru +4 -0
  17. data/spec/dummy/config/application.rb +29 -0
  18. data/spec/dummy/config/boot.rb +5 -0
  19. data/spec/dummy/config/environment.rb +5 -0
  20. data/spec/dummy/config/environments/development.rb +34 -0
  21. data/spec/dummy/config/environments/production.rb +75 -0
  22. data/spec/dummy/config/environments/test.rb +39 -0
  23. data/spec/dummy/config/initializers/assets.rb +8 -0
  24. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  25. data/spec/dummy/config/initializers/config.rb +23 -0
  26. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  27. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  28. data/spec/dummy/config/initializers/inflections.rb +16 -0
  29. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  30. data/spec/dummy/config/initializers/session_store.rb +3 -0
  31. data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
  32. data/spec/dummy/config/locales/en.yml +23 -0
  33. data/spec/dummy/config/mongoid.yml +12 -0
  34. data/spec/dummy/config/routes.rb +3 -0
  35. data/spec/dummy/config/secrets.yml +22 -0
  36. data/spec/dummy/db/seeds.rb +11 -0
  37. data/spec/dummy/public/404.html +67 -0
  38. data/spec/dummy/public/422.html +67 -0
  39. data/spec/dummy/public/500.html +66 -0
  40. data/spec/dummy/public/favicon.ico +0 -0
  41. data/spec/dummy/tmp/cache/assets/test/sass/fde2fd9fd4415e2893f7c202128d5909c847645f/admin_bar.css.scssc +0 -0
  42. data/spec/dummy/tmp/cache/assets/test/sass/fde2fd9fd4415e2893f7c202128d5909c847645f/base.css.scssc +0 -0
  43. data/spec/dummy/tmp/cache/assets/test/sprockets/0825425ebf24766be13ebf4e696dc267 +0 -0
  44. data/spec/dummy/tmp/cache/assets/test/sprockets/0b495c71c71a2d087e00d9f77c89b537 +0 -0
  45. data/spec/dummy/tmp/cache/assets/test/sprockets/0cbda04368ddbf6d761e788334075e7c +0 -0
  46. data/spec/dummy/tmp/cache/assets/test/sprockets/0d8f54d1682f575aec8f27993d3af45e +0 -0
  47. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  48. data/spec/dummy/tmp/cache/assets/test/sprockets/182d8b06dcdb4f799088741f553903d3 +0 -0
  49. data/spec/dummy/tmp/cache/assets/test/sprockets/1b64a5fd92110dbd078f4ea964e2d0ad +0 -0
  50. data/spec/dummy/tmp/cache/assets/test/sprockets/2155dbeb10a65c2519b49179b3bc6f3a +0 -0
  51. data/spec/dummy/tmp/cache/assets/test/sprockets/21f725a9b3479e57849414f8272a905b +0 -0
  52. data/spec/dummy/tmp/cache/assets/test/sprockets/2535956b4e5e79e8fbd3d30f68de7024 +0 -0
  53. data/spec/dummy/tmp/cache/assets/test/sprockets/28ad54c6e5882957dd269b1b2a3c3c75 +0 -0
  54. data/spec/dummy/tmp/cache/assets/test/sprockets/2d13dd9465026b66cce912e30e142020 +0 -0
  55. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  56. data/spec/dummy/tmp/cache/assets/test/sprockets/300f6f1e08668cacf691691df4d13889 +0 -0
  57. data/spec/dummy/tmp/cache/assets/test/sprockets/311ffc36d5a7e1d3216e672b3e57e7ed +0 -0
  58. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  59. data/spec/dummy/tmp/cache/assets/test/sprockets/3a3d03c0a92f21419e1e85991774a28b +0 -0
  60. data/spec/dummy/tmp/cache/assets/test/sprockets/3dea6de9e06b1e372ebf4790f5eecc48 +0 -0
  61. data/spec/dummy/tmp/cache/assets/test/sprockets/4144b15d96ec80b5c7fb367b57aaeef3 +0 -0
  62. data/spec/dummy/tmp/cache/assets/test/sprockets/4729c7f6ab6a91a079ab04a8f04e932b +0 -0
  63. data/spec/dummy/tmp/cache/assets/test/sprockets/4c324a18fe6bf7dbf7a04cccbfdb366e +0 -0
  64. data/spec/dummy/tmp/cache/assets/test/sprockets/535f36c50d5b36ff83bc03bc6a19b8fc +0 -0
  65. data/spec/dummy/tmp/cache/assets/test/sprockets/55c2f55c27a62b998b8d33555158da53 +0 -0
  66. data/spec/dummy/tmp/cache/assets/test/sprockets/56afaea2e164564be4d5f5bbc7f81050 +0 -0
  67. data/spec/dummy/tmp/cache/assets/test/sprockets/579b1a727fe5b55dfe450b0835c56a65 +0 -0
  68. data/spec/dummy/tmp/cache/assets/test/sprockets/6f7174fb7f1fbb8e01d382a128a979e8 +0 -0
  69. data/spec/dummy/tmp/cache/assets/test/sprockets/7746e5b6582f701e40ad5ae69e7a6d25 +0 -0
  70. data/spec/dummy/tmp/cache/assets/test/sprockets/7f14b0b39c11df4f58e03d390b589547 +0 -0
  71. data/spec/dummy/tmp/cache/assets/test/sprockets/8091ad5bff4f0d3d70f874750430241b +0 -0
  72. data/spec/dummy/tmp/cache/assets/test/sprockets/825bd4dba50f1ea2c0ae5e8a3708119e +0 -0
  73. data/spec/dummy/tmp/cache/assets/test/sprockets/85d858ed64f06543161931735cb77748 +0 -0
  74. data/spec/dummy/tmp/cache/assets/test/sprockets/8803d0a63bbf3fce683c968d4a900480 +0 -0
  75. data/spec/dummy/tmp/cache/assets/test/sprockets/887e2151ef4cd6e915fd9bfc27c41d7d +0 -0
  76. data/spec/dummy/tmp/cache/assets/test/sprockets/90c324b461b60cdeb6b549dbf932f162 +0 -0
  77. data/spec/dummy/tmp/cache/assets/test/sprockets/92d59399e3f951cc11721f03a2b328fd +0 -0
  78. data/spec/dummy/tmp/cache/assets/test/sprockets/966db607ae0e7aad72cf171b8fec537a +0 -0
  79. data/spec/dummy/tmp/cache/assets/test/sprockets/99fd048521a12239746f91aa138613bf +0 -0
  80. data/spec/dummy/tmp/cache/assets/test/sprockets/a539d3e91d5fb8eeb973ac8706bbf5c9 +0 -0
  81. data/spec/dummy/tmp/cache/assets/test/sprockets/a87019c62b5fb3b3dc75db921d98ad59 +0 -0
  82. data/spec/dummy/tmp/cache/assets/test/sprockets/a87cf4d10d892fb23f2fc818d7ca7207 +0 -0
  83. data/spec/dummy/tmp/cache/assets/test/sprockets/ab4192212bd78e95967e5a716548236f +0 -0
  84. data/spec/dummy/tmp/cache/assets/test/sprockets/af97ed366de5933460d41b9198ddc99e +0 -0
  85. data/spec/dummy/tmp/cache/assets/test/sprockets/b6f21db694cacb7f5bcbb93cf45f65ed +0 -0
  86. data/spec/dummy/tmp/cache/assets/test/sprockets/bd3113e1418cbc640eb6e1b06d486163 +0 -0
  87. data/spec/dummy/tmp/cache/assets/test/sprockets/c0600b832214f9e16294a1c37c0c3f6e +0 -0
  88. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  89. data/spec/dummy/tmp/cache/assets/test/sprockets/d05d272f053261f2d5e3dcca85f19172 +0 -0
  90. data/spec/dummy/tmp/cache/assets/test/sprockets/d1e5823c113c9ee03e6c6d7773eb6fac +0 -0
  91. data/spec/dummy/tmp/cache/assets/test/sprockets/d1f0a2d6fd58a203f3ca66950c822c33 +0 -0
  92. data/spec/dummy/tmp/cache/assets/test/sprockets/d4248f8b11c6b21abffed4a5e718722d +0 -0
  93. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  94. data/spec/dummy/tmp/cache/assets/test/sprockets/db1a08b3c680b077476f767a8addb44b +0 -0
  95. data/spec/dummy/tmp/cache/assets/test/sprockets/dd9f84cc20227ad66bbd1f26bbc11ccc +0 -0
  96. data/spec/dummy/tmp/cache/assets/test/sprockets/de9d72cab443cce32e1d45e62d2b4c04 +0 -0
  97. data/spec/dummy/tmp/cache/assets/test/sprockets/e03c578b73cf9936edc84ff2b48c07da +0 -0
  98. data/spec/dummy/tmp/cache/assets/test/sprockets/ebdd71d1c3cf34d7d174e5c1abb123b7 +0 -0
  99. data/spec/dummy/tmp/cache/assets/test/sprockets/f14e64162f52a8d2d22ff9e1c1cc4fac +0 -0
  100. data/spec/dummy/tmp/cache/assets/test/sprockets/f566af7037e0e3042b19bd5ee11b21c4 +0 -0
  101. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  102. data/spec/dummy/tmp/cache/assets/test/sprockets/fd1cae0417fea68172ab7b747a1d6fd8 +0 -0
  103. data/spec/integration/pages_index_spec.rb +48 -0
  104. data/spec/lib/type_station/dsl_spec.rb +53 -0
  105. data/spec/lib/type_station/view_helpers_spec.rb +181 -0
  106. data/spec/models/type_station/content_spec.rb +38 -0
  107. data/spec/models/type_station/page_spec.rb +107 -0
  108. data/spec/presenters/type_station/page_presenter_spec.rb +36 -0
  109. data/spec/spec_helper.rb +34 -0
  110. data/spec/type_station_spec.rb +7 -0
  111. metadata +296 -13
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe "Test", :type => :request do
4
+
5
+ describe "With a defined Pages" do
6
+
7
+ describe "GET /" do
8
+
9
+ before do
10
+ @root = TypeStation::Page.create!(title: 'Index page', template_name: 'blank_index')
11
+ @page = TypeStation::Page.create!(title: 'About us', template_name: 'blank_index', parent: @root)
12
+ @page2 = TypeStation::Page.create!(title: 'Redirect', template_name: 'blank_index', redirect_to: '/place-to-redirect', parent: @root)
13
+ @page3 = TypeStation::Page.create!(title: 'place to redirect', template_name: 'blank_index', parent: @root)
14
+ end
15
+
16
+ it "will return 200 on get /" do
17
+ get "/type_station"
18
+ expect(response).to have_http_status(200)
19
+ end
20
+
21
+ it "will return 200 on get /type_station/about-us" do
22
+ get "/type_station/about-us"
23
+ expect(response).to have_http_status(200)
24
+ end
25
+
26
+ it "will return 200 on get /type_station/about-us/" do
27
+ get "/type_station/about-us/"
28
+ expect(response).to have_http_status(200)
29
+ end
30
+
31
+ it "will return 200 on get /type_station/redirect" do
32
+ get "/type_station/redirect"
33
+ expect(response).to have_http_status(302)
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ describe "Without a defined Index Page" do
41
+ describe "GET /" do
42
+ it "will return a 404" do
43
+ get "/type_station"
44
+ expect(response).to have_http_status(404)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ require 'type_station/dsl'
3
+
4
+ RSpec.describe TypeStation::DSL do
5
+
6
+ before do
7
+
8
+ TypeStation::DSL.build 'Homepage' do
9
+ page 'About us' do
10
+ page 'Team'
11
+ page 'Contact us', redirect_to: '/contact-us'
12
+ page 'Another Page Title', template: 'standard', slug: 'another-one'
13
+ end
14
+ page 'Contact us'
15
+ page 'Projects', template: 'about_us'
16
+ end
17
+
18
+ end
19
+
20
+
21
+ it 'will create an index page' do
22
+ expect(TypeStation::Page.root.title).to eq('Homepage')
23
+ end
24
+
25
+ it 'will set the index page template to index' do
26
+ expect(TypeStation::Page.root.template_name).to eq('index')
27
+ end
28
+
29
+ it 'will create 3 children for the root page' do
30
+ expect(TypeStation::Page.root.children.count).to eq(3)
31
+ end
32
+
33
+ it 'will set the about us page template name to about_us' do
34
+ expect(TypeStation::Page.find_by_path('/about-us').template_name).to eq('about_us')
35
+ end
36
+
37
+ it 'will set the projects page template to about-us' do
38
+ expect(TypeStation::Page.find_by_path('/projects').template_name).to eq('about_us')
39
+ end
40
+
41
+ it 'will set the about-us/contact-us page redirect_to to /contact-us' do
42
+ expect(TypeStation::Page.find_by_path('about-us/contact-us').redirect_to).to eq('/contact-us')
43
+ end
44
+
45
+ it 'will create children of children' do
46
+ expect(TypeStation::Page.find_by_path('/about-us/team')).to eq(TypeStation::Page.where(title: 'Team').first)
47
+ end
48
+
49
+ it 'will create a page with a defined slug' do
50
+ expect(TypeStation::Page.find_by_path('/about-us/another-one')).to eq(TypeStation::Page.where(title: 'Another Page Title').first)
51
+ end
52
+
53
+ end
@@ -0,0 +1,181 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe TypeStation::ViewHelpers do
4
+ include RSpec::Rails::HelperExampleGroup
5
+
6
+ describe 'Emtpy without any values' do
7
+
8
+ before do
9
+ @root = TypeStation::Page.create(title: 'Test Index')
10
+ @page = TypeStation::Page.create(title: 'Test Page', parent: @root)
11
+
12
+ view_context = Struct.new(:test) do
13
+ def edit_admin_page_url(page)
14
+ 'URL'
15
+ end
16
+ end
17
+
18
+ @presenter = TypeStation::PagePresenter.new @page, view_context.new
19
+ allow(@presenter).to receive(:edit_url).and_return("URL")
20
+ end
21
+
22
+ describe 'none Admin mode' do
23
+
24
+ before do
25
+ allow(helper).to receive(:type_station_current_user).and_return(false)
26
+ end
27
+
28
+ it 'will render the default text value' do
29
+ value = helper.editable @presenter, :title_test do
30
+ 'Test'
31
+ end
32
+ expect(value).to eq('Test')
33
+ end
34
+
35
+ it 'will render the default html value' do
36
+ value = helper.editable @presenter, :body, type: :html do
37
+ '<h1>Test</h1>'.html_safe
38
+ end
39
+ expect(value).to eq('<h1>Test</h1>')
40
+ end
41
+
42
+ it 'will render the default image value' do
43
+ value = helper.editable @presenter, :image, type: :image do |image|
44
+ image.url || "http://placehold.it/350x150"
45
+ end
46
+ expect(value).to eq('http://placehold.it/350x150')
47
+ end
48
+
49
+ it 'will render the default multiple_select value' do
50
+ value = helper.editable @presenter, :multiple_select, type: :multiple_select do |multiple_select|
51
+ multiple_select.values || "Other"
52
+ end
53
+ expect(value).to eq('Other')
54
+ end
55
+
56
+ end
57
+
58
+ describe 'Inline edit' do
59
+
60
+ before do
61
+ allow(helper).to receive(:type_station_current_user).and_return({})
62
+ end
63
+
64
+ it 'will render the default text value' do
65
+ value = helper.editable @presenter, :title_test, id: 'test' do
66
+ 'Test'
67
+ end
68
+ result = content_tag(:span, "Test", id: 'test', class: 'ts-editable-text', data: {ts_id: @presenter.to_param, ts_edit_url: @presenter.edit_url, ts_field: :title_test, ts_data:{} })
69
+ expect(value).to eq(result)
70
+ end
71
+
72
+ it 'will render the default html value' do
73
+ value = helper.editable @presenter, :body, type: :html, id: 'test' do
74
+ '<h1>Test</h1>'.html_safe
75
+ end
76
+ result = content_tag(:div,'<h1>Test</h1>'.html_safe, id: 'test', class: 'ts-editable-html', data: {ts_id: @presenter.to_param, ts_edit_url: @presenter.edit_url, ts_field: :body, ts_data:{} })
77
+ expect(value).to eq(result)
78
+ end
79
+
80
+ it 'will render the default image value' do
81
+ value = helper.editable @presenter, :image, type: :image, id: 'test' do |image|
82
+ image.url || "http://placehold.it/350x150"
83
+ end
84
+ result = content_tag(:div,'http://placehold.it/350x150', id: 'test', class: 'ts-editable-image', data: {ts_id: @presenter.to_param, ts_edit_url: @presenter.edit_url, ts_field: :image, ts_data:{} })
85
+ expect(value).to eq(result)
86
+ end
87
+
88
+ it 'will render the default select value' do
89
+ value = helper.editable @presenter, :select, type: :select, id: 'test' do |multiple_select|
90
+ multiple_select.values || "Other"
91
+ end
92
+ result = content_tag(:div,'Other', id: 'test', class: 'ts-editable-select', data: {ts_id: @presenter.to_param, ts_edit_url: @presenter.edit_url, ts_field: :select, ts_data:{} })
93
+ expect(value).to eq(result)
94
+ end
95
+
96
+ it 'will render the default multiple_select value' do
97
+ value = helper.editable @presenter, :multiple_select, type: :multiple_select, id: 'test' do |multiple_select|
98
+ multiple_select.values || "Other"
99
+ end
100
+ result = content_tag(:div,'Other', id: 'test', class: 'ts-editable-multiple-select', data: {ts_id: @presenter.to_param, ts_edit_url: @presenter.edit_url, ts_field: :multiple_select, ts_data:{} })
101
+ expect(value).to eq(result)
102
+ end
103
+
104
+ end
105
+
106
+ end
107
+
108
+ describe 'With values' do
109
+
110
+ before do
111
+ @root = TypeStation::Page.create(title: 'Test Index')
112
+ @page = TypeStation::Page.create(title: 'Test Page', parent: @root)
113
+ @content_text = @page.contents.build(name: :title_test, type: :text)
114
+ @content_text.set('My Text')
115
+ @content_html = @page.contents.build(name: :body, type: :html)
116
+ @content_html.set('<h1>My Text</h1>')
117
+ @content_image = @page.contents.build(name: :image, type: :image)
118
+ @content_image.set({url: 'test', alt: 'Blah', 'string_url' => 'string_test'})
119
+ @content_select = @page.contents.build(name: :select, type: :select)
120
+ @content_select.set('test')
121
+ @content_multiple_select = @page.contents.build(name: :multiple_select, type: :multiple_select)
122
+ @content_multiple_select.set('test, blah')
123
+ @page.save!
124
+ view_context = Struct.new(:test) do
125
+ def edit_admin_page_url(page)
126
+ 'URL'
127
+ end
128
+ end
129
+
130
+ @presenter = TypeStation::PagePresenter.new @page, view_context.new
131
+ allow(@presenter).to receive(:edit_url).and_return("URL")
132
+ end
133
+
134
+ describe 'none Admin mode' do
135
+
136
+ before do
137
+ allow(helper).to receive(:type_station_current_user).and_return(false)
138
+ end
139
+
140
+ it 'will render the text value' do
141
+ value = helper.editable @presenter, :title_test do
142
+ 'Test'
143
+ end
144
+ expect(value).to eq('My Text')
145
+ end
146
+
147
+ it 'will render the html value' do
148
+ value = helper.editable @presenter, :body, type: :html do
149
+ '<h1>Test</h1>'.html_safe
150
+ end
151
+ expect(value).to eq('<h1>My Text</h1>')
152
+ end
153
+
154
+ it 'will render the image value' do
155
+ value = helper.editable @presenter, :image, type: :image do |image|
156
+ image.string_url || "http://placehold.it/350x150"
157
+ end
158
+ expect(value).to eq('string_test')
159
+ end
160
+
161
+ it 'will render the select value' do
162
+ value = helper.editable @presenter, :select, type: :select do |select|
163
+ select
164
+ end
165
+ expect(value).to eq('test')
166
+ end
167
+
168
+ it 'will render the multiple_select value' do
169
+ value = helper.editable @presenter, :multiple_select, type: :multiple_select do |multiple_select|
170
+ multiple_select.join('-')
171
+ end
172
+ expect(value).to eq('test-blah')
173
+ end
174
+
175
+ end
176
+
177
+
178
+ end
179
+
180
+
181
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe TypeStation::Content do
4
+ subject {TypeStation::Content.new(name: :title, type: :text)}
5
+ it { should validate_presence_of(:name) }
6
+ it { should validate_presence_of(:type) }
7
+
8
+ describe 'Text' do
9
+ before do
10
+ @content = TypeStation::Content.new(name: :title, type: :text)
11
+ end
12
+
13
+ it 'will return my simple text' do
14
+ @content.set('My Test')
15
+ expect(@content.get).to eq('My Test')
16
+ end
17
+ end
18
+
19
+
20
+ describe 'Multiple Select' do
21
+ before do
22
+ @content = TypeStation::Content.new(name: :title, type: :multiple_select)
23
+ @content2 = TypeStation::Content.new(name: :title, type: :multiple_select)
24
+ end
25
+
26
+ it 'will return an array from string' do
27
+ @content.set('My Test')
28
+ @content2.set('My Test, Test 2')
29
+ expect(@content.get).to eq(['My Test'])
30
+ expect(@content2.get).to eq(['My Test', 'Test 2'])
31
+ end
32
+
33
+ it 'will return an array from array' do
34
+ @content.set(['My Test'])
35
+ expect(@content.get).to eq(['My Test'])
36
+ end
37
+ end
38
+ end