adyen-skinbuilder 0.2.6 → 0.3.0

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.
Files changed (56) hide show
  1. data/.gitignore +3 -4
  2. data/.travis.yml +5 -0
  3. data/CHANGELOG.md +22 -0
  4. data/Gemfile.lock +51 -7
  5. data/LICENSE +3 -3
  6. data/README.markdown +83 -24
  7. data/Rakefile +6 -0
  8. data/adyen-skinbuilder.gemspec +12 -11
  9. data/bin/adyen-skinbuilder +28 -3
  10. data/lib/adyen-skinbuilder.rb +1 -4
  11. data/lib/adyen-skinbuilder/helper/adyen.rb +29 -0
  12. data/lib/adyen-skinbuilder/helper/render.rb +32 -0
  13. data/lib/adyen-skinbuilder/server.rb +112 -58
  14. data/lib/adyen-skinbuilder/server/views/_adyen_form.html.erb +37 -0
  15. data/{adyen/main_content.html → lib/adyen-skinbuilder/server/views/_adyen_payment_fields.html.erb} +534 -530
  16. data/lib/adyen-skinbuilder/server/views/css/reset.css +306 -0
  17. data/lib/adyen-skinbuilder/server/views/img/icons/error.png +0 -0
  18. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK1.png +0 -0
  19. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK10.png +0 -0
  20. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK2.png +0 -0
  21. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK3.png +0 -0
  22. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK4.png +0 -0
  23. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK5.png +0 -0
  24. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK6.png +0 -0
  25. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK7.png +0 -0
  26. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK8.png +0 -0
  27. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANK9.png +0 -0
  28. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANKCANCELLED.png +0 -0
  29. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANKPENDING.png +0 -0
  30. data/lib/adyen-skinbuilder/server/views/img/pm/TESTBANKREFUSED.png +0 -0
  31. data/lib/adyen-skinbuilder/server/views/img/pm/amex_small.png +0 -0
  32. data/lib/adyen-skinbuilder/server/views/img/pm/card.png +0 -0
  33. data/lib/adyen-skinbuilder/server/views/img/pm/ideal.png +0 -0
  34. data/lib/adyen-skinbuilder/server/views/img/pm/mc_small.png +0 -0
  35. data/lib/adyen-skinbuilder/server/views/img/pm/unknown_small.png +0 -0
  36. data/lib/adyen-skinbuilder/server/views/img/pm/vias_small.png +0 -0
  37. data/lib/adyen-skinbuilder/server/views/img/pm/visa.png +0 -0
  38. data/lib/adyen-skinbuilder/server/views/img/pm/visa_small.png +0 -0
  39. data/lib/adyen-skinbuilder/server/views/index.html.erb +118 -0
  40. data/lib/adyen-skinbuilder/server/views/js/default.js +385 -0
  41. data/lib/adyen-skinbuilder/server/views/layout.html.erb +33 -0
  42. data/lib/adyen-skinbuilder/server/views/skeleton.html +56 -0
  43. data/lib/adyen-skinbuilder/server/views/skin.html.erb +18 -0
  44. data/lib/adyen-skinbuilder/version.rb +1 -1
  45. data/lib/hash.rb +15 -0
  46. data/spec/fixtures/example.zip +0 -0
  47. data/spec/fixtures/skins/DV3tf95f/inc/order_data.txt +1 -0
  48. data/spec/fixtures/skins/JH0815/css/screen.css +262 -0
  49. data/spec/fixtures/skins/JH0815/skin.html.erb +13 -0
  50. data/spec/lib/adyen-skinbuilder/server_spec.rb +166 -38
  51. data/spec/spec_helper.rb +2 -2
  52. metadata +109 -31
  53. data/adyen/skeleton.html +0 -70
  54. data/lib/adyen-skinbuilder/launcher.rb +0 -40
  55. data/lib/adyen-skinbuilder/railtie.rb +0 -9
  56. data/lib/adyen-skinbuilder/tasks/skin.rake +0 -65
@@ -0,0 +1,18 @@
1
+ <!-- ### inc/cheader_[locale].txt or inc/cheader.txt (fallback) ### -->
2
+ <%= render_file "cheader" %>
3
+
4
+ <% adyen_form_tag do %>
5
+ <!-- ### inc/pmheader_[locale].txt or inc/pmheader.txt (fallback) ### -->
6
+ <%= render_file "pmheader" %>
7
+
8
+ <%= adyen_payment_fields %>
9
+
10
+ <!-- ### inc/pmfooter_[locale].txt or inc/pmfooter.txt (fallback) ### -->
11
+ <%= render_file "pmfooter" %>
12
+
13
+ <!-- ### inc/customfields_[locale].txt or inc/customfields.txt (fallback) ### -->
14
+ <%= render_file "customfields" %>
15
+ <% end %>
16
+
17
+ <!-- ### inc/cfooter_[locale].txt or inc/cfooter.txt (fallback) ### -->
18
+ <%= render_file "cfooter" %>
@@ -1,5 +1,5 @@
1
1
  module Adyen
2
2
  module Skinbuilder
3
- VERSION = '0.2.6'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
data/lib/hash.rb ADDED
@@ -0,0 +1,15 @@
1
+ # Taken from File activesupport/lib/active_support/core_ext/hash/keys.rb, line 23
2
+ # + added symbolize_keys! for values
3
+
4
+ class Hash
5
+ def symbolize_keys!
6
+ keys.each do |key|
7
+ self[(key.to_sym rescue key) || key] = if (value = delete(key)) && value.is_a?(Hash)
8
+ value.symbolize_keys!
9
+ else
10
+ value
11
+ end
12
+ end
13
+ self
14
+ end
15
+ end
Binary file
@@ -0,0 +1 @@
1
+ My Custom Order Data
@@ -0,0 +1,262 @@
1
+ html, body {
2
+ height: 100%;
3
+ margin: 0;
4
+ padding: 0;
5
+ font: 15px/19px verdana, serif;
6
+ color: #FFF;
7
+ background: #6A96BB url(../img/bg_gr.jpg) repeat-x top;
8
+ }
9
+
10
+ #content2 h1, #content2 h2, #content2 h3, #content2 h4, #content2 h5 {
11
+ /* Headers inside the actual content2sbox */
12
+ margin: 1em 17px 0.5em 10px;
13
+ text-align: right;
14
+ font-size: 1.4em;
15
+ }
16
+
17
+ h1, h2, h3, h4 {font-family: "georgia", serif; font-weight: bold;}
18
+
19
+ h3 { font-size: 1.2em;}
20
+ h3 a, h3 a:visited { text-decoration: none; color: #fff;}
21
+ h3 a:active { color: #f00;}
22
+ h3 a:hover { color: #fff000;}
23
+
24
+ #center {
25
+ /* Makes the page in center of the viewport */
26
+ position: relative;
27
+ width: 792px;
28
+ height: 100%;
29
+ margin: 0 auto;
30
+ background: transparent url(../img/blog_gr.jpg) repeat-y top right;
31
+ }
32
+
33
+ #pageform{
34
+ height: 20px;
35
+
36
+ }
37
+
38
+ #archives {
39
+ position: relative;
40
+ left: -20px;
41
+ padding: 0;
42
+ top: 228px;
43
+ width: 271px;
44
+ }
45
+
46
+ #archives h3 {
47
+ /* the clouds graphic is a background of every h3 inside #achives */
48
+ background: transparent url(../img/category.gif) no-repeat top right;
49
+ padding: 0 15px;
50
+ margin: 0;
51
+ vertical-align: middle;
52
+ line-height: 30px;
53
+ height: 38px;
54
+ text-align: right;
55
+
56
+ }
57
+
58
+ /* the archives list is a real list, but I don't dots or numbers, and that I change with the following: */
59
+
60
+ #archives ul {
61
+ margin: 0 22px 0 0;
62
+ padding: 0 0 10px 0;
63
+ }
64
+
65
+ #archives ul li {
66
+ list-style-type: none;
67
+ text-align: right;
68
+ margin: 5px 0;
69
+ }
70
+
71
+ #archives ul li a {
72
+ text-decoration: none;
73
+ color: #2F3B55;
74
+ font-family: "georgia", "palatino linotype", "times new roman", serif;
75
+ }
76
+
77
+ #archives ul li a:hover {color: #fff; text-decoration: underline;}
78
+
79
+
80
+ #content2 {
81
+ /* the actual content2 of the page */
82
+ position: absolute;
83
+ top: 198px;
84
+ width: 502px;
85
+ right: 0;
86
+ padding-right: 10px;
87
+ padding-left: 28px;
88
+ background: transparent url(../img/blog_gr.jpg) repeat-y top right;
89
+ }
90
+
91
+
92
+ #foot {
93
+ /* height: 60px;
94
+ background-color: white;
95
+ */
96
+ }
97
+
98
+ #content2 p {
99
+ margin: 15px 17px 15px 0px;
100
+ text-align: justify;
101
+ }
102
+
103
+ #content2 h2 {
104
+ color: #C8E5FF;
105
+ border-top: 1px dotted;
106
+ padding-top: 12px;
107
+ margin-left: 0px;
108
+ }
109
+
110
+
111
+ #home {
112
+ /* the box in the upper-left corner */
113
+ position: absolute;
114
+ top: 15px;
115
+ left: 80px;
116
+ width: 200px;
117
+ text-align: center;
118
+ z-index: 1;
119
+ }
120
+
121
+ #home * {
122
+ margin: 0;
123
+ padding: 3px 0;
124
+ }
125
+
126
+ #top1, #top2, #top3 {
127
+ display: block;
128
+ position: absolute;
129
+ top: 0;
130
+ background-repeat: no-repeat;
131
+ background-color: transparent;
132
+ }
133
+
134
+ /* the top-graphic is made with these three elements: */
135
+
136
+ #top1 {
137
+ right: 503px;
138
+ width: 55px;
139
+ height: 223px;
140
+ background-image: url(../img/top1.jpg);
141
+ }
142
+
143
+ #top2 {
144
+ right: 5px;
145
+ width: 498px;
146
+ height: 223px;
147
+ background-image: url(../img/top2.jpg);
148
+ }
149
+
150
+ #top3 {
151
+ right: -25px;
152
+ width: 30px;
153
+ height: 231px;
154
+ background-image: url(../img/top3.jpg);
155
+ }
156
+
157
+ pre {font-family: courier, monospace; font-size: 1em; color: black; }
158
+ table.basetable { margin-left: 5px;}
159
+ table.basetable td { padding-bottom: 0.6em; padding-right: 0.6em;}
160
+ table.od { margin: 10px 0px 10px 40px;}
161
+ table.od td { padding: 5px; border: 1px solid #999;}
162
+ table.od th { padding: 5px; font-weight: bold; border: 1px solid #999;}
163
+ .r { text-align: right; }
164
+ .l { text-align: left; }
165
+ .fr { float: right; }
166
+ .fl { float: left; }
167
+ .b {font-size:1em; font-weight:bold;}
168
+
169
+ .imgB {
170
+ width: 138px;
171
+ height: 32px;
172
+ padding: 0;
173
+ border: 0;
174
+ background: transparent url(../img/bg_buttons.png) no-repeat left 0px;
175
+ overflow: hidden;
176
+ color: white;
177
+ cursor: pointer; /* hand-shaped cursor */
178
+ cursor: hand; /* for IE 5.x */
179
+ font-weight: bold;
180
+ font-size: 1.2em;
181
+ }
182
+ form>.imgB { /* For non-IE browsers*/
183
+ height: 0px;
184
+ }
185
+
186
+ #footerb1div {
187
+ float: right;
188
+ }
189
+ #footerb2div {
190
+ float: right;
191
+ }
192
+
193
+ .pmB {
194
+ width: 238px;
195
+ height: 42px;
196
+ padding-left: 85px;
197
+ text-align: left;
198
+ margin-bottom: 6px;
199
+ font-size: 1.1em;
200
+ }
201
+
202
+ .footerB {
203
+ border: 2px outset black;
204
+ background-color: #ccc;
205
+ margin: 6px 10px 0 0;
206
+ }
207
+ .footerB:active {
208
+ border: 2px inset black;
209
+ }
210
+
211
+ #nextstep {display: none;}
212
+
213
+ .red {color:#c00;}
214
+ .popupMsg { display: none; border: 1px solid #666; color: black; background-color: #eee; margin-bottom:5px; padding: 6px;}
215
+
216
+ input, select
217
+ {
218
+ font-size: 0.95em;
219
+ padding: 1px;
220
+ border: 1px solid #C3C3C3;
221
+ border-top-color: #7C7C7C;
222
+ border-bottom-color: #DDD;
223
+ background: white url(../img/input_bg.png) 0 0 repeat-x;
224
+ }
225
+
226
+ input[type=text]:focus, input[type=password]:focus, select:focus {
227
+ background-color: #E7F1F8 !important;
228
+ }
229
+
230
+ select {
231
+ font-weight: bold;
232
+ }
233
+
234
+
235
+ select {
236
+ font-size: 0.9em;
237
+ }
238
+
239
+ table.basetable .inputField {
240
+ padding: 1px 2px 2px 2px;
241
+ background-color: white;
242
+ }
243
+
244
+
245
+ table.basetable .errorField {
246
+ border: 2px solid #f33;
247
+ background-color: #fff3f3;
248
+ padding: 1px 1px 1px 1px;
249
+ }
250
+
251
+ .fieldDiv {
252
+ padding-right: 20px;
253
+ background: transparent;
254
+ }
255
+ .errorDiv {
256
+ background: transparent url(/hpp/img/icons/error.png) no-repeat right 3px;
257
+ padding-right: 20px;
258
+ }
259
+ .errorFrame {
260
+ background-color: #fff3f3;
261
+ }
262
+
@@ -0,0 +1,13 @@
1
+ <!-- ### inc/cheader_[locale].txt or inc/cheader.txt (fallback) ### -->
2
+
3
+ <% adyen_form_tag do %>
4
+ <!-- ### inc/pmheader_[locale].txt or inc/pmheader.txt (fallback) ### -->
5
+
6
+ <%= adyen_payment_fields %>
7
+
8
+ <!-- ### inc/pmfooter_[locale].txt or inc/pmfooter.txt (fallback) ### -->
9
+
10
+ <!-- ### inc/customfields_[locale].txt or inc/customfields.txt (fallback) ### -->
11
+ <% end %>
12
+
13
+ <!-- ### inc/cfooter_[locale].txt or inc/cfooter.txt (fallback) ### -->
@@ -1,71 +1,199 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+
2
+ require 'spec_helper'
2
3
  require 'rack/test'
3
4
 
4
5
  describe 'SkinBuilder server' do
5
-
6
6
  include Rack::Test::Methods
7
7
 
8
+ let(:skins_directory) { File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures/skins')) }
9
+ let(:skin_code) { "/DV3tf95f" }
10
+
8
11
  def app
9
- Adyen::SkinBuilder::Server.app(
10
- :skins_directory => File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures/skins/DV3tf95f'))
11
- )
12
+ Adyen::SkinBuilder::Server.tap do |app|
13
+ app.set :skins_directory, skins_directory
14
+ end.new
12
15
  end
13
-
14
- describe 'get asset from skin directory' do
16
+
17
+ before do
18
+ Adyen::Admin.stub(:login)
19
+ end
20
+
21
+ describe 'assets' do
22
+ let(:file) { '/css/screen.css' }
23
+
15
24
  before(:each) do
16
- get '/sf/DV3tf95f/css/screen.css'
25
+ get "/sf" + skin_code + file
17
26
  end
18
-
27
+
19
28
  it 'responds with 200 status' do
20
29
  last_response.status.should == 200
21
30
  end
22
-
31
+
23
32
  it 'responds with "text/css" content type header for CSS file' do
24
- last_response.headers.fetch('Content-Type').should == 'text/css'
33
+ last_response.headers.fetch('Content-Type').should == 'text/css;charset=utf-8'
25
34
  end
26
- end
27
-
28
- describe 'get asset from skins base directory' do
29
- before(:each) do
30
- get '/sf/DV3tf95f/css/print.css'
31
- end
32
-
33
- it 'responds with 200 status' do
34
- last_response.status.should == 200
35
+
36
+ it 'returns file content' do
37
+ last_response.body.should == File.read(skins_directory + skin_code + file)
35
38
  end
36
-
37
- it 'responds with "text/css" content type header for CSS file' do
38
- last_response.headers.fetch('Content-Type').should == 'text/css'
39
+
40
+ context 'file not available, falls back to base' do
41
+ let(:file) { '/css/print.css' }
42
+
43
+ it 'responds with 200 status' do
44
+ last_response.status.should == 200
45
+ end
46
+
47
+ it 'responds with "text/css" content type header for CSS file' do
48
+ last_response.headers.fetch('Content-Type').should == 'text/css;charset=utf-8'
49
+ end
50
+
51
+ it 'returns file content from base' do
52
+ last_response.body.should == File.read(skins_directory + "/base" + file)
53
+ end
39
54
  end
40
55
  end
41
-
56
+
42
57
  describe 'GET /' do
43
- before(:each) do
44
- get '/'
45
- end
46
-
47
- it 'responds with 200 status' do
48
- last_response.status.should == 200
58
+ context "split files skin" do
59
+ before(:each) do
60
+ get path
61
+ end
62
+
63
+ describe "index" do
64
+ let(:path) { '/' }
65
+
66
+ it 'responds with 200 status' do
67
+ last_response.status.should == 200
68
+ end
69
+
70
+ it 'returns adyen skeleton in HTML format' do
71
+ last_response.headers.fetch('Content-Type').should == 'text/html;charset=utf-8'
72
+ end
73
+
74
+ it 'returns skins_directory' do
75
+ last_response.body.should include(skins_directory)
76
+ end
77
+
78
+ it 'returns avilable skins' do
79
+ last_response.body.should include(skin_code)
80
+ end
81
+ end
82
+
83
+ describe "skin" do
84
+ let(:path) { skin_code }
85
+
86
+ it 'responds with 200 status' do
87
+ last_response.status.should == 200
88
+ end
89
+
90
+ it 'returns adyen skeleton in HTML format' do
91
+ last_response.headers.fetch('Content-Type').should == 'text/html;charset=utf-8'
92
+ end
93
+
94
+ it 'returns adyen form' do
95
+ last_response.body.should include('<form id="pageform" action="" method="post" onsubmit="return formValidate(this);">')
96
+ end
97
+
98
+ it 'returns order data' do
99
+ last_response.body.should include(File.read(skins_directory + skin_code + '/inc/order_data.txt'))
100
+ end
101
+ end
49
102
  end
50
-
51
- it 'returns adyen skeleton in HTML format' do
52
- last_response.headers.fetch('Content-Type').should == 'text/html'
103
+
104
+ context "one file skin" do
105
+ describe "compile" do
106
+ let(:skin_code) { "/JH0815" }
107
+ let(:path) { skin_code + "?compile=true" }
108
+
109
+ before(:each) do
110
+ get path
111
+ end
112
+
113
+ after do
114
+ FileUtils.rm_rf(skins_directory + skin_code + '/inc')
115
+ `rm JH0815.zip`
116
+ end
117
+
118
+ it 'writes cheader' do
119
+ File.read(skins_directory + skin_code + '/inc/cheader.txt').should == "<!-- ### inc/cheader_[locale].txt or inc/cheader.txt (fallback) ### -->"
120
+ end
121
+
122
+ it 'writes pmheader' do
123
+ File.read(skins_directory + skin_code + '/inc/pmheader.txt').should == "<!-- ### inc/pmheader_[locale].txt or inc/pmheader.txt (fallback) ### -->"
124
+ end
125
+
126
+ it 'writes pmfooter' do
127
+ File.read(skins_directory + skin_code + '/inc/pmfooter.txt').should == "<!-- ### inc/pmfooter_[locale].txt or inc/pmfooter.txt (fallback) ### -->\n\n <!-- ### inc/customfields_[locale].txt or inc/customfields.txt (fallback) ### -->"
128
+ end
129
+
130
+ it 'writes cfooter' do
131
+ File.read(skins_directory + skin_code + '/inc/cfooter.txt').should == "<!-- ### inc/cfooter_[locale].txt or inc/cfooter.txt (fallback) ### -->"
132
+ end
133
+
134
+ it "returns zip file" do
135
+ last_response.headers["Content-Type"].should == "application/zip"
136
+ end
137
+ end
138
+
139
+ describe "upload" do
140
+ let(:path) { skin_code + "?upload=true" }
141
+ let!(:skin) { Adyen::Admin::Skin.new(:path => skins_directory + skin_code) }
142
+
143
+ after do
144
+ `rm -rf #{skins_directory + skin_code}/inc/*er.txt`
145
+ end
146
+
147
+ it "calls upload on skin" do
148
+ Adyen::Admin::Skin.should_receive(:new).and_return(skin)
149
+ skin.should_receive(:upload)
150
+ get path
151
+ end
152
+ end
153
+
154
+ describe "download" do
155
+ let(:skin_code) { "vQW0fEo8" }
156
+ let(:path) { "/?download=vQW0fEo8" }
157
+ let(:skin) { Adyen::Admin::Skin.new(:code => skin_code) }
158
+
159
+ before do
160
+ `cp spec/fixtures/example.zip spec/fixtures/#{skin_code}.zip`
161
+ end
162
+
163
+ after do
164
+ `rm -rf #{skin.path}`
165
+ end
166
+
167
+ it "call download on skin" do
168
+ Adyen::Admin::Skin.should_receive(:find).and_return(skin)
169
+ skin.should_receive(:download).and_return("spec/fixtures/#{skin_code}.zip")
170
+ get path
171
+ File.should be_exists("spec/fixtures/skins/#{skin_code}/skin.html.erb")
172
+ end
173
+
174
+ # it "copies skin template" do
175
+ # Adyen::Admin::Skin.should_receive(:find).and_return(skin)
176
+ # skin.should_receive(:download).and_return("spec/fixtures/#{skin_code}.zip")
177
+ # get path
178
+
179
+ # end
180
+ end
53
181
  end
54
182
  end
55
-
183
+
56
184
  describe 'HEAD /' do
57
185
  before(:each) do
58
186
  head '/'
59
187
  end
60
-
188
+
61
189
  it 'responds withr 200 status' do
62
190
  last_response.status.should == 200
63
191
  end
64
-
192
+
65
193
  it 'returns content type header' do
66
- last_response.headers.should == { 'Content-Type' => 'text/html' }
194
+ last_response.headers.fetch('Content-Type').should == 'text/html;charset=utf-8'
67
195
  end
68
-
196
+
69
197
  it 'returns empty body' do
70
198
  last_response.body.should == ''
71
199
  end