landing_page 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/app/controllers/landing_page/users_controller.rb +3 -1
  3. data/app/models/landing_page/user.rb +6 -0
  4. data/app/views/landing_page/users/create.html.slim +1 -1
  5. data/lib/landing_page/version.rb +1 -1
  6. data/spec/controllers/landing_page/users_controller_spec.rb +39 -0
  7. data/spec/dummy/README.rdoc +261 -0
  8. data/spec/dummy/Rakefile +7 -0
  9. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  10. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  11. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  12. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  13. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  14. data/spec/dummy/config.ru +4 -0
  15. data/spec/dummy/config/application.rb +65 -0
  16. data/spec/dummy/config/boot.rb +10 -0
  17. data/spec/dummy/config/database.yml +25 -0
  18. data/spec/dummy/config/environment.rb +5 -0
  19. data/spec/dummy/config/environments/development.rb +37 -0
  20. data/spec/dummy/config/environments/production.rb +67 -0
  21. data/spec/dummy/config/environments/test.rb +37 -0
  22. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  23. data/spec/dummy/config/initializers/inflections.rb +15 -0
  24. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  25. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  26. data/spec/dummy/config/initializers/session_store.rb +8 -0
  27. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  28. data/spec/dummy/config/locales/en.yml +5 -0
  29. data/spec/dummy/config/routes.rb +4 -0
  30. data/spec/dummy/db/schema.rb +26 -0
  31. data/spec/dummy/db/test.sqlite3 +0 -0
  32. data/spec/dummy/log/test.log +438 -0
  33. data/spec/dummy/public/404.html +26 -0
  34. data/spec/dummy/public/422.html +26 -0
  35. data/spec/dummy/public/500.html +25 -0
  36. data/spec/dummy/public/favicon.ico +0 -0
  37. data/spec/dummy/script/rails +6 -0
  38. data/spec/features/user_leave_email_spec.rb +27 -0
  39. data/spec/features/user_share_page_spec.rb +14 -0
  40. data/spec/models/landing_page/user_spec.rb +45 -0
  41. data/spec/spec_helper.rb +49 -0
  42. data/spec/support/factories.rb +5 -0
  43. data/spec/support/helper.rb +8 -0
  44. metadata +95 -37
  45. data/README.rdoc +0 -5
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ include LandingPageHelper
4
+
5
+ module LandingPage
6
+ describe "User" do
7
+ context "when he leaves a valid email" do
8
+ it "see a success message" do
9
+ subscribe_with 'Name', 'dummy@email.com'
10
+ expect(page).to have_selector '.lp-message.lp-message-success', text: 'You have been subscribed'
11
+ end
12
+ end
13
+ context "when he leaves an invalid email" do
14
+ it "see an error message" do
15
+ subscribe_with 'Name', 'not_valid_email'
16
+ expect(page).to have_selector '.lp-message.lp-message-error', text: 'The email is not valid'
17
+ end
18
+ end
19
+ context "when he leaves a repeated email" do
20
+ it "see an error message" do
21
+ FactoryGirl.create :user, email: 'dummy@email.com'
22
+ subscribe_with 'Name', 'dummy@email.com'
23
+ expect(page).to have_selector '.lp-message.lp-message-error', text: 'has already been taken'
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ include LandingPageHelper
4
+
5
+ module LandingPage
6
+ describe "User" do
7
+ context "when he leaves a valid email" do
8
+ it "see share buttons" do
9
+ subscribe_with 'Name', 'dummy@email.com'
10
+ expect(page).to have_selector '.lp-share'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ module LandingPage
4
+ describe User do
5
+ it "has email attribute" do
6
+ expect(User.new).to respond_to :email
7
+ end
8
+ describe "email" do
9
+ it "is required" do
10
+ expect(User.new).to validate_presence_of(:email)
11
+ end
12
+ it "is a valid email address" do
13
+ expect(User.new).to allow_value("dummy@mail.com").for(:email)
14
+ expect(User.new).to_not allow_value("invalid_email").for(:email)
15
+ end
16
+ it "is unique" do
17
+ expect(User.new).to validate_uniqueness_of(:email)
18
+ end
19
+ end
20
+ it "has name attribute" do
21
+ expect(User.new).to respond_to :name
22
+ end
23
+ it "has locale attribute" do
24
+ expect(User.new).to respond_to :locale
25
+ end
26
+ describe "before save" do
27
+ it "set the locale attribute to the current locale" do
28
+ user = FactoryGirl.create :user
29
+ expect(user.locale).to eq I18n.locale.to_s
30
+ end
31
+ end
32
+ describe "after save" do
33
+ context "when campaign monitor is configured" do
34
+ it "add the email to campaign monitor" do
35
+ LandingPage.campaign_monitor_api_key = 'whatever'
36
+ LandingPage.campaign_monitor_list_id = 'whatever'
37
+ name = 'dummy name'
38
+ email = 'dummy@email.com'
39
+ CreateSend::Subscriber.should_receive(:add).with({api_key: LandingPage.campaign_monitor_api_key}, LandingPage.campaign_monitor_list_id, email, name, [{:Key => 'locale', :Value => I18n.locale.to_s}], true).and_return(nil)
40
+ FactoryGirl.create :user, name: name, email: email
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,49 @@
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 'rspec/autorun'
6
+ require 'factory_girl'
7
+ require 'shoulda-matchers'
8
+
9
+ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
10
+
11
+ # Requires supporting ruby files with custom matchers and macros, etc,
12
+ # in spec/support/ and its subdirectories.
13
+ Dir[Rails.root.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each { |f| require f }
14
+
15
+ RSpec.configure do |config|
16
+ # ## Mock Framework
17
+ #
18
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
19
+ #
20
+ # config.mock_with :mocha
21
+ # config.mock_with :flexmock
22
+ # config.mock_with :rr
23
+
24
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
25
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
26
+
27
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
28
+ # examples within a transaction, remove the following line or assign false
29
+ # instead of true.
30
+ config.use_transactional_fixtures = true
31
+
32
+ # If true, the base class of anonymous controllers will be inferred
33
+ # automatically. This will be the default behavior in future versions of
34
+ # rspec-rails.
35
+ config.infer_base_class_for_anonymous_controllers = false
36
+
37
+ # Run specs in random order to surface order dependencies. If you find an
38
+ # order dependency and want to debug it, you can fix the order by providing
39
+ # the seed, which is printed after each run.
40
+ # --seed 1234
41
+ config.order = "random"
42
+
43
+ config.before(:each, type: :controller) { @routes = LandingPage::Engine.routes }
44
+
45
+ config.before(:each) do
46
+ LandingPage.campaign_monitor_api_key = nil
47
+ LandingPage.campaign_monitor_list_id = nil
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :user, class: LandingPage::User do
3
+ email 'dummy@email.com'
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ module LandingPageHelper
2
+ def subscribe_with name, email
3
+ visit "/landing_page/"
4
+ fill_in 'Name', with: name
5
+ fill_in 'Email', with: email
6
+ click_button 'Subscribe'
7
+ end
8
+ end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: landing_page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Marc Busqué
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-30 00:00:00.000000000 Z
11
+ date: 2013-09-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 4.0.0
19
+ version: '3.2'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 4.0.0
26
+ version: '3.2'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: slim-rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: createsend
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,23 +55,20 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: sqlite3
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec-rails
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: capybara
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,29 +97,26 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: factory_girl_rails
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
117
103
  version: '4.2'
118
- - - ! '>='
104
+ - - '>='
119
105
  - !ruby/object:Gem::Version
120
106
  version: 4.2.1
121
107
  type: :development
122
108
  prerelease: false
123
109
  version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
110
  requirements:
126
111
  - - ~>
127
112
  - !ruby/object:Gem::Version
128
113
  version: '4.2'
129
- - - ! '>='
114
+ - - '>='
130
115
  - !ruby/object:Gem::Version
131
116
  version: 4.2.1
132
117
  - !ruby/object:Gem::Dependency
133
118
  name: shoulda-matchers
134
119
  requirement: !ruby/object:Gem::Requirement
135
- none: false
136
120
  requirements:
137
121
  - - ~>
138
122
  - !ruby/object:Gem::Version
@@ -140,12 +124,13 @@ dependencies:
140
124
  type: :development
141
125
  prerelease: false
142
126
  version_requirements: !ruby/object:Gem::Requirement
143
- none: false
144
127
  requirements:
145
128
  - - ~>
146
129
  - !ruby/object:Gem::Version
147
130
  version: '2.2'
148
- description: Coming soon, before setember 2013
131
+ description: Minimal, flexible, unobstrusive rails 3 engine for an email subscription
132
+ form. It collects name, email and locale used. Optional integration with Campaign
133
+ Monitor. Ready for I18n.
149
134
  email:
150
135
  - marc@lamarciana.com
151
136
  executables: []
@@ -174,31 +159,104 @@ files:
174
159
  - lib/tasks/landing_page_tasks.rake
175
160
  - COPYING.txt
176
161
  - Rakefile
177
- - README.rdoc
178
- homepage: https://github.com/laMarciana/landing_page
162
+ - spec/dummy/Rakefile
163
+ - spec/dummy/script/rails
164
+ - spec/dummy/db/test.sqlite3
165
+ - spec/dummy/db/schema.rb
166
+ - spec/dummy/public/422.html
167
+ - spec/dummy/public/500.html
168
+ - spec/dummy/public/404.html
169
+ - spec/dummy/public/favicon.ico
170
+ - spec/dummy/app/assets/stylesheets/application.css
171
+ - spec/dummy/app/assets/javascripts/application.js
172
+ - spec/dummy/app/views/layouts/application.html.erb
173
+ - spec/dummy/app/controllers/application_controller.rb
174
+ - spec/dummy/app/helpers/application_helper.rb
175
+ - spec/dummy/log/test.log
176
+ - spec/dummy/config/boot.rb
177
+ - spec/dummy/config/database.yml
178
+ - spec/dummy/config/environments/production.rb
179
+ - spec/dummy/config/environments/development.rb
180
+ - spec/dummy/config/environments/test.rb
181
+ - spec/dummy/config/routes.rb
182
+ - spec/dummy/config/environment.rb
183
+ - spec/dummy/config/application.rb
184
+ - spec/dummy/config/initializers/backtrace_silencers.rb
185
+ - spec/dummy/config/initializers/mime_types.rb
186
+ - spec/dummy/config/initializers/secret_token.rb
187
+ - spec/dummy/config/initializers/inflections.rb
188
+ - spec/dummy/config/initializers/wrap_parameters.rb
189
+ - spec/dummy/config/initializers/session_store.rb
190
+ - spec/dummy/config/locales/en.yml
191
+ - spec/dummy/config.ru
192
+ - spec/dummy/README.rdoc
193
+ - spec/support/helper.rb
194
+ - spec/support/factories.rb
195
+ - spec/features/user_share_page_spec.rb
196
+ - spec/features/user_leave_email_spec.rb
197
+ - spec/models/landing_page/user_spec.rb
198
+ - spec/controllers/landing_page/users_controller_spec.rb
199
+ - spec/spec_helper.rb
200
+ homepage: https://github.com/laMarciana/landing_page/tree/rails_3.2
179
201
  licenses:
180
202
  - GPL3
203
+ metadata: {}
181
204
  post_install_message:
182
205
  rdoc_options: []
183
206
  require_paths:
184
207
  - lib
185
208
  required_ruby_version: !ruby/object:Gem::Requirement
186
- none: false
187
209
  requirements:
188
- - - ! '>='
210
+ - - '>='
189
211
  - !ruby/object:Gem::Version
190
212
  version: '0'
191
213
  required_rubygems_version: !ruby/object:Gem::Requirement
192
- none: false
193
214
  requirements:
194
- - - ! '>='
215
+ - - '>='
195
216
  - !ruby/object:Gem::Version
196
217
  version: '0'
197
218
  requirements: []
198
219
  rubyforge_project:
199
- rubygems_version: 1.8.23
220
+ rubygems_version: 2.0.3
200
221
  signing_key:
201
- specification_version: 3
202
- summary: Rails 4 engine for a landing page
203
- test_files: []
204
- has_rdoc:
222
+ specification_version: 4
223
+ summary: Rails 3.2 engine for a landing page (email subscription form)
224
+ test_files:
225
+ - spec/dummy/Rakefile
226
+ - spec/dummy/script/rails
227
+ - spec/dummy/db/test.sqlite3
228
+ - spec/dummy/db/schema.rb
229
+ - spec/dummy/public/422.html
230
+ - spec/dummy/public/500.html
231
+ - spec/dummy/public/404.html
232
+ - spec/dummy/public/favicon.ico
233
+ - spec/dummy/app/assets/stylesheets/application.css
234
+ - spec/dummy/app/assets/javascripts/application.js
235
+ - spec/dummy/app/views/layouts/application.html.erb
236
+ - spec/dummy/app/controllers/application_controller.rb
237
+ - spec/dummy/app/helpers/application_helper.rb
238
+ - spec/dummy/log/test.log
239
+ - spec/dummy/config/boot.rb
240
+ - spec/dummy/config/database.yml
241
+ - spec/dummy/config/environments/production.rb
242
+ - spec/dummy/config/environments/development.rb
243
+ - spec/dummy/config/environments/test.rb
244
+ - spec/dummy/config/routes.rb
245
+ - spec/dummy/config/environment.rb
246
+ - spec/dummy/config/application.rb
247
+ - spec/dummy/config/initializers/backtrace_silencers.rb
248
+ - spec/dummy/config/initializers/mime_types.rb
249
+ - spec/dummy/config/initializers/secret_token.rb
250
+ - spec/dummy/config/initializers/inflections.rb
251
+ - spec/dummy/config/initializers/wrap_parameters.rb
252
+ - spec/dummy/config/initializers/session_store.rb
253
+ - spec/dummy/config/locales/en.yml
254
+ - spec/dummy/config.ru
255
+ - spec/dummy/README.rdoc
256
+ - spec/support/helper.rb
257
+ - spec/support/factories.rb
258
+ - spec/features/user_share_page_spec.rb
259
+ - spec/features/user_leave_email_spec.rb
260
+ - spec/models/landing_page/user_spec.rb
261
+ - spec/controllers/landing_page/users_controller_spec.rb
262
+ - spec/spec_helper.rb