camaleon_cms 2.4.5.5 → 2.4.5.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of camaleon_cms might be problematic. Click here for more details.

Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/app/apps/themes/default/views/partials/_comments.html.erb +36 -21
  3. data/app/apps/themes/default/views/post.html.erb +1 -1
  4. data/app/assets/javascripts/camaleon_cms/admin/uploader/_media_manager.js.coffee +4 -4
  5. data/app/controllers/camaleon_cms/admin/categories_controller.rb +3 -0
  6. data/app/controllers/camaleon_cms/admin/media_controller.rb +9 -6
  7. data/app/controllers/camaleon_cms/admin/sessions_controller.rb +1 -1
  8. data/app/controllers/camaleon_cms/admin/settings/post_types_controller.rb +2 -0
  9. data/app/controllers/concerns/camaleon_cms/frontend_concern.rb +17 -13
  10. data/app/decorators/camaleon_cms/post_decorator.rb +0 -1
  11. data/app/helpers/camaleon_cms/captcha_helper.rb +1 -1
  12. data/app/helpers/camaleon_cms/frontend/nav_menu_helper.rb +1 -0
  13. data/app/helpers/camaleon_cms/hooks_helper.rb +6 -1
  14. data/app/helpers/camaleon_cms/site_helper.rb +1 -1
  15. data/app/helpers/camaleon_cms/uploader_helper.rb +36 -27
  16. data/app/models/camaleon_cms/custom_fields_relationship.rb +6 -0
  17. data/app/models/camaleon_cms/media.rb +54 -0
  18. data/app/models/camaleon_cms/post.rb +1 -0
  19. data/app/models/camaleon_cms/site.rb +7 -0
  20. data/app/uploaders/camaleon_cms_aws_uploader.rb +21 -23
  21. data/app/uploaders/camaleon_cms_local_uploader.rb +20 -26
  22. data/app/uploaders/camaleon_cms_uploader.rb +17 -45
  23. data/app/views/camaleon_cms/admin/categories/index.html.erb +2 -2
  24. data/app/views/camaleon_cms/admin/media/_render_file_item.html.erb +53 -36
  25. data/app/views/camaleon_cms/admin/media/index.html.erb +1 -1
  26. data/app/views/camaleon_cms/admin/post_tags/index.html.erb +4 -4
  27. data/app/views/camaleon_cms/admin/posts/index.html.erb +1 -0
  28. data/app/views/camaleon_cms/admin/settings/_configuration_settings.html.erb +5 -1
  29. data/app/views/camaleon_cms/admin/settings/post_types/_form.html.erb +1 -1
  30. data/app/views/camaleon_cms/default_theme/partials/_comments.html.erb +45 -28
  31. data/app/views/camaleon_cms/default_theme/single.html.erb +1 -1
  32. data/config/locales/camaleon_cms/admin/es.yml +1 -0
  33. data/config/locales/camaleon_cms/admin/js.yml +54 -3
  34. data/config/locales/camaleon_cms/admin/ru.yml +39 -28
  35. data/db/migrate/20180124132318_create_media.rb +17 -0
  36. data/lib/camaleon_cms/version.rb +1 -1
  37. data/lib/ext/string.rb +8 -0
  38. data/lib/generators/camaleon_cms/gem_plugin_generator.rb +29 -25
  39. data/lib/plugin_routes.rb +27 -0
  40. data/spec/dummy/config/application.rb +1 -0
  41. data/spec/dummy/config/environments/test.rb +2 -0
  42. data/spec/dummy/db/schema.rb +1 -140
  43. data/spec/dummy/db/test.sqlite3 +0 -0
  44. data/spec/dummy/public/favicon.ico +0 -0
  45. data/spec/factories/post_type.rb +17 -0
  46. data/spec/factories/site.rb +8 -0
  47. data/spec/features/{categories_spec.rb → admin/categories_spec.rb} +1 -1
  48. data/spec/features/{comments_spec.rb → admin/comments_spec.rb} +16 -9
  49. data/spec/features/{contact_form_spec.rb → admin/contact_form_spec.rb} +16 -9
  50. data/spec/features/{content_groups_spec.rb → admin/content_groups_spec.rb} +19 -11
  51. data/spec/features/{custom_fields_spec.rb → admin/custom_fields_spec.rb} +1 -1
  52. data/spec/features/{languages_spec.rb → admin/languages_spec.rb} +1 -1
  53. data/spec/features/{media_spec.rb → admin/media_spec.rb} +1 -1
  54. data/spec/features/{menus_spec.rb → admin/menus_spec.rb} +2 -2
  55. data/spec/features/{pages_spec.rb → admin/pages_spec.rb} +1 -1
  56. data/spec/features/{plugins_spec.rb → admin/plugins_spec.rb} +1 -1
  57. data/spec/features/{posts_spec.rb → admin/posts_spec.rb} +4 -3
  58. data/spec/features/admin/session_spec.rb +102 -0
  59. data/spec/features/{settings_spec.rb → admin/settings_spec.rb} +1 -1
  60. data/spec/features/{shortcodes_spec.rb → admin/shortcodes_spec.rb} +1 -1
  61. data/spec/features/{sites_spec.rb → admin/sites_spec.rb} +22 -14
  62. data/spec/features/{tags_spec.rb → admin/tags_spec.rb} +17 -8
  63. data/spec/features/{themes_spec.rb → admin/themes_spec.rb} +1 -1
  64. data/spec/features/{user_roles_spec.rb → admin/user_roles_spec.rb} +25 -19
  65. data/spec/features/{users_spec.rb → admin/users_spec.rb} +2 -2
  66. data/spec/features/{widgets_spec.rb → admin/widgets_spec.rb} +19 -12
  67. data/spec/features/frontend/pages_spec.rb +86 -5
  68. data/spec/features/frontend/post_type_spec.rb +16 -0
  69. data/spec/helpers/email_helper_spec.rb +1 -1
  70. data/spec/helpers/uploader_helper_spec.rb +56 -0
  71. data/spec/mailers/send_mail_spec.rb +3 -3
  72. data/spec/{decorators/camaleon_cms/post_decorator_spec.rb → models/post_spec.rb} +3 -3
  73. data/spec/rails_helper.rb +79 -0
  74. data/spec/spec_helper.rb +25 -56
  75. data/spec/support/common.rb +10 -24
  76. data/spec/support/fixtures/rails.png +0 -0
  77. data/spec/support/fixtures/rails_tmp.png +0 -0
  78. metadata +64 -50
  79. data/app/views/camaleon_cms/admin/media/_files_list.html.erb +0 -2
  80. data/app/views/camaleon_cms/admin/media/_render_folder_item.html.erb +0 -15
  81. data/spec/decorators/post_type_spec.rb +0 -13
  82. data/spec/features/session_spec.rb +0 -74
@@ -1,5 +1,86 @@
1
- # require 'rails_helper'
2
- # describe "Post frontend", js: true do
3
- # login_success
4
- # pages_test
5
- # end
1
+ require 'rails_helper'
2
+ describe "Post frontend", js: true do
3
+ before(:each) do
4
+ @site = create(:site).decorate
5
+ @post = @site.the_post('sample-post').decorate
6
+ end
7
+
8
+ it 'visit post' do
9
+ visit @post.the_url(as_path: true)
10
+ expect(page).to have_text(@post.the_title)
11
+ end
12
+
13
+ describe 'comments' do
14
+
15
+ describe 'anonymous' do
16
+ before(:each) do
17
+ @post.set_meta('has_comments', '1') # enable comments for this post
18
+ @site.set_option('permit_anonimos_comment', true) # enable anonymous comment
19
+ end
20
+
21
+ it 'anonymous comment' do
22
+ visit @post.the_url(as_path: true)
23
+ expect(page).to have_text('New Comment')
24
+
25
+ within("#form-comment") do
26
+ fill_in 'post_comment_name', :with => 'Owen'
27
+ fill_in 'post_comment_email', :with => 'owenperedo@gmail.com'
28
+ fill_in 'post_comment_content', :with => 'Sample comment'
29
+ end
30
+ click_button 'Comment'
31
+ expect(page).to have_text('The comment has been created')
32
+ end
33
+
34
+ it 'anonymous comment valid captcha' do
35
+ @site.set_option('enable_captcha_for_comments', true) # enable anonymous captcha
36
+ Capybara.using_session("test session") do
37
+ visit cama_captcha_path(len: 4, t: Time.current.to_i)
38
+ captcha = page.get_rack_session['cama_captcha']
39
+ visit @post.the_url(as_path: true)
40
+ expect(page).to have_text('New Comment')
41
+ within("#form-comment") do
42
+ fill_in 'post_comment_name', :with => 'Owen'
43
+ fill_in 'post_comment_email', :with => 'owenperedo@gmail.com'
44
+ fill_in 'post_comment_content', :with => 'Sample comment'
45
+ fill_in 'captcha', :with => captcha
46
+ end
47
+ click_button 'Comment'
48
+ expect(page).to have_text('The comment has been created')
49
+ end
50
+ end
51
+
52
+ it 'anonymous comment wrong captcha' do
53
+ @site.set_option('enable_captcha_for_comments', true) # enable anonymous captcha
54
+ visit @post.the_url(as_path: true)
55
+ expect(page).to have_text('New Comment')
56
+
57
+ within("#form-comment") do
58
+ fill_in 'post_comment_name', :with => 'Owen'
59
+ fill_in 'post_comment_email', :with => 'owenperedo@gmail.com'
60
+ fill_in 'post_comment_content', :with => 'Sample comment'
61
+ end
62
+ click_button 'Comment'
63
+ expect(page).not_to have_text('The comment has been created')
64
+ end
65
+ end
66
+
67
+ it 'comment with user session' do
68
+ @post.set_meta('has_comments', '1') # enable comments for this post
69
+ admin_sign_in
70
+ visit @post.the_url(as_path: true)
71
+ expect(page).to have_text('New Comment')
72
+ within("#form-comment") do
73
+ fill_in 'post_comment_content', :with => 'Sample comment'
74
+ end
75
+ click_button 'Comment'
76
+ expect(page).to have_text('The comment has been created')
77
+ end
78
+
79
+ it 'post not enabled for comments' do
80
+ @post.set_meta('has_comments', '0')
81
+ admin_sign_in
82
+ visit @post.the_url(as_path: true)
83
+ expect(page).not_to have_text('New Comment')
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,16 @@
1
+ require 'rails_helper'
2
+ describe "Posttype frontend", js: true do
3
+ before(:each) do
4
+ @site = create(:site).decorate
5
+ @post = @site.the_post('sample-post').decorate
6
+ @post_type = @post.post_type.decorate
7
+ end
8
+
9
+ it 'public uri with group structure' do
10
+ expect(@post_type.the_group_url(as_path: true)).to include("/group/#{@post_type.id}")
11
+ end
12
+
13
+ it "public url" do
14
+ expect(@post_type.the_url).to include("/#{@post_type.slug}")
15
+ end
16
+ end
@@ -1,7 +1,7 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  describe "CamaleonCms::EmailHelper" do
4
- get_current_test_site()
4
+ before(:each){get_current_test_site()}
5
5
  describe "#send_email (old way)" do
6
6
  it "returns empty" do
7
7
  expect(helper.send_email('test@gmail.com', 'Test Email', 'test content', 'owenperedo@gmail.com')).to be_a_kind_of(ActionMailer::DeliveryJob)
@@ -0,0 +1,56 @@
1
+ require 'rails_helper'
2
+ describe CamaleonCms::UploaderHelper do
3
+ init_site
4
+ before(:each) do
5
+ @path = "#{CAMALEON_CMS_ROOT}/spec/support/fixtures/rails_tmp.png"
6
+ FileUtils.cp("#{CAMALEON_CMS_ROOT}/spec/support/fixtures/rails.png", @path)
7
+ end
8
+
9
+ it "upload a local file" do
10
+ expect(upload_file(File.open(@path)).keys.include?(:error)).not_to eql(true)
11
+ expect(upload_file(File.open(@path), {thumb_size: '20x20'}).keys.include?(:error)).not_to eql(true)
12
+ expect(upload_file(File.open(@path), {folder: 'sample'}).keys.include?(:error)).not_to eql(true)
13
+ end
14
+
15
+ it "upload a local file max size" do
16
+ expect(upload_file(File.open(@path), {maximum: 1.byte}).keys.include?(:error)).to eql(true)
17
+ end
18
+
19
+ it "upload a local file custom dimension" do
20
+ expect(upload_file(File.open(@path), {dimension: '50x50'}).keys.include?(:error)).not_to eql(true)
21
+ expect(upload_file(File.open(@path), {dimension: 'x50'}).keys.include?(:error)).not_to eql(true)
22
+ expect(upload_file(File.open(@path), {dimension: '50x'}).keys.include?(:error)).not_to eql(true)
23
+ expect(upload_file(File.open(@path), {dimension: '50x20?'}).keys.include?(:error)).not_to eql(true)
24
+ end
25
+
26
+ it "upload a local file invalid format" do
27
+ expect(upload_file(File.open(@path), {formats: 'audio'}).keys.include?(:error)).to eql(true)
28
+ end
29
+
30
+ it "upload a local file with versions" do
31
+ expect(upload_file(File.open(@path), {versions: '300x300,505x350,20x'}).keys.include?(:error)).not_to eql(true)
32
+ end
33
+
34
+ it "add auto orient for cropping images" do
35
+ callback = lambda do |params|
36
+ params[:img] = params[:img].auto_orient
37
+ end
38
+ PluginRoutes.add_anonymous_hook('before_crop_image', callback, 'my_custom_hook')
39
+ expect(upload_file(File.open(@path), {versions: '300x300,505x350,20x'}).keys.include?(:error)).not_to eql(true)
40
+ PluginRoutes.remove_anonymous_hook('before_crop_image','my_custom_hook')
41
+ end
42
+
43
+ it "add auto orient for resizing" do
44
+ callback = lambda do |params|
45
+ params[:img] = params[:img].auto_orient
46
+ end
47
+ PluginRoutes.add_anonymous_hook('before_resize_crop', callback, 'my_custom_hook')
48
+ expect(upload_file(File.open(@path), {versions: '300x300,505x350,20x'}).keys.include?(:error)).not_to eql(true)
49
+ PluginRoutes.remove_anonymous_hook('before_resize_crop','my_custom_hook')
50
+ end
51
+
52
+ it "upload a external file" do
53
+ expect(upload_file('http://camaleon.tuzitio.com/media/132/slider/slide33.jpg').keys.include?(:error)).not_to eql(true)
54
+ end
55
+
56
+ end
@@ -1,8 +1,10 @@
1
1
  require 'rails_helper'
2
2
 
3
3
  describe "CamaleonCms::HtmlMailer" do
4
+ before(:each) do
5
+ @site = create(:site).decorate
6
+ end
4
7
  describe 'empty content' do
5
- get_current_test_site()
6
8
  let(:mail) { CamaleonCms::HtmlMailer.sender('test@gmail.com', "test") }
7
9
 
8
10
  it 'renders the subject' do
@@ -23,9 +25,7 @@ describe "CamaleonCms::HtmlMailer" do
23
25
  end
24
26
 
25
27
  describe 'custom content' do
26
- get_current_test_site()
27
28
  let(:mail) { CamaleonCms::HtmlMailer.sender('test@gmail.com', "test", content: 'custom content', cc_to: ['a@gmail.com', 'b@gmail.com']) }
28
-
29
29
  it 'renders the sender email' do
30
30
  expect(mail.cc).to eql(['a@gmail.com', 'b@gmail.com'])
31
31
  end
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
-
3
- RSpec.describe CamaleonCms::PostDecorator do
2
+ include CamaleonCms::Frontend::ApplicationHelper
3
+ RSpec.describe 'PostDecorator' do
4
4
  it "next and previous post related to post type" do
5
5
  post_type = create_test_post_type(slug: 'test-post-type')
6
6
  post3 = create_test_post(post_type, slug: 'test3', post_order: 3).decorate
@@ -8,7 +8,7 @@ RSpec.describe CamaleonCms::PostDecorator do
8
8
  post2 = create_test_post(post_type, slug: 'test2', post_order: 2).decorate
9
9
  post2_1 = create_test_post(post_type, slug: 'test2_1', post_order: 2).decorate
10
10
  post4 = create_test_post(post_type, slug: 'test4', post_order: 4).decorate
11
-
11
+
12
12
  expect(post3.the_next_post.slug).to eq('test4')
13
13
  expect(post3.the_prev_post.slug).to eq('test2_1')
14
14
 
@@ -1 +1,80 @@
1
1
  require 'spec_helper'
2
+ require 'transactional_capybara/rspec'
3
+
4
+ # spec/support/factory_bot.rb
5
+ RSpec.configure do |config|
6
+ config.include FactoryBot::Syntax::Methods
7
+ end
8
+
9
+ # RSpec without Rails
10
+ RSpec.configure do |config|
11
+ config.include FactoryBot::Syntax::Methods
12
+
13
+ config.before(:suite) do
14
+ FactoryBot.find_definitions
15
+ end
16
+ end
17
+
18
+ # rspec cleaner
19
+ RSpec.configure do |config|
20
+
21
+ config.before(:suite) do
22
+ DatabaseCleaner.strategy = :transaction
23
+ DatabaseCleaner.clean_with(:truncation)
24
+ end
25
+
26
+ config.around(:each) do |example|
27
+ DatabaseCleaner.cleaning do
28
+ example.run
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ # capyobara cleaner
35
+ RSpec.configure do |config|
36
+
37
+ config.use_transactional_fixtures = false
38
+
39
+ config.before(:suite) do
40
+ if config.use_transactional_fixtures?
41
+ raise(<<-MSG)
42
+ Delete line `config.use_transactional_fixtures = true` from rails_helper.rb
43
+ (or set it to false) to prevent uncommitted transactions being used in
44
+ JavaScript-dependent specs.
45
+
46
+ During testing, the app-under-test that the browser driver connects to
47
+ uses a different database connection to the database connection used by
48
+ the spec. The app's database connection would not be able to access
49
+ uncommitted transaction data setup over the spec's database connection.
50
+ MSG
51
+ end
52
+ DatabaseCleaner.clean_with(:truncation)
53
+ end
54
+
55
+ config.before(:each) do
56
+ DatabaseCleaner.strategy = :transaction
57
+ end
58
+
59
+ config.before(:each, type: :feature) do
60
+ # :rack_test driver's Rack app under test shares database connection
61
+ # with the specs, so continue to use transaction strategy for speed.
62
+ driver_shares_db_connection_with_specs = Capybara.current_driver == :rack_test
63
+
64
+ unless driver_shares_db_connection_with_specs
65
+ # Driver is probably for an external browser with an app
66
+ # under test that does *not* share a database connection with the
67
+ # specs, so use truncation strategy.
68
+ DatabaseCleaner.strategy = :truncation
69
+ end
70
+ end
71
+
72
+ config.before(:each) do
73
+ DatabaseCleaner.start
74
+ end
75
+
76
+ config.append_after(:each) do
77
+ DatabaseCleaner.clean
78
+ end
79
+
80
+ end
@@ -1,6 +1,3 @@
1
- # Configuration was inspired by:
2
- # https://www.viget.com/articles/rails-engine-testing-with-rspec-capybara-and-factorygirl
3
-
4
1
  ENV['RAILS_ENV'] ||= 'test'
5
2
 
6
3
  CAMALEON_CMS_ROOT = Pathname.new(__FILE__).join('../..')
@@ -13,45 +10,27 @@ ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate',
13
10
  require 'rspec/rails'
14
11
  require "capybara/rspec"
15
12
  require 'database_cleaner'
13
+ require "rack_session_access/capybara"
16
14
 
17
- # This file was generated by the `rails generate rspec:install` command. Conventionally, all
18
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
19
- # The generated `.rspec` file contains `--require spec_helper` which will cause
20
- # this file to always be loaded, without a need to explicitly require it in any
21
- # files.
22
- #
23
- # Given that it is always loaded, you are encouraged to keep this file as
24
- # light-weight as possible. Requiring heavyweight dependencies from this file
25
- # will add to the boot time of your test suite on EVERY test run, even for an
26
- # individual file that may not need all of that loaded. Instead, consider making
27
- # a separate helper file that requires the additional dependencies and performs
28
- # the additional setup, and require it from the spec files that actually need
29
- # it.
30
- #
31
- # The `.rspec` file also contains a few flags that are not defaults but that
32
- # users commonly want.
33
- #
34
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
35
15
 
36
16
  require 'capybara/rspec'
37
17
  require 'capybara-screenshot/rspec'
38
- # Capybara.javascript_driver = :webkit
18
+ Capybara.javascript_driver = :webkit
39
19
 
40
20
  # define screenshot errors name
41
21
  Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
42
22
  "screenshot_#{example.description.gsub(' ', '-').gsub(/^.*\/spec\//,'')}"
43
23
  end
44
24
 
25
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
45
26
  #****** configuration to test using poltergeist *****#
46
- require 'capybara/poltergeist'
47
- # Note: you need phantomjs 1.9.x which can be downloaded from here: https://code.google.com/archive/p/phantomjs/downloads
48
- if File.exist?(File.join(CAMALEON_CMS_ROOT, 'spec', 'bin', 'phantomjs'))
49
- Capybara.register_driver :poltergeist do |app|
50
- Capybara::Poltergeist::Driver.new(app, :phantomjs => File.join(CAMALEON_CMS_ROOT, 'spec', 'bin', 'phantomjs').to_s)
51
- end
52
- end
53
- Capybara.javascript_driver = :poltergeist
54
-
27
+ # require 'capybara/poltergeist'
28
+ # Check here if you have problems with phantomjs: https://github.com/teampoltergeist/poltergeist
29
+ # Don't forget bundle update to use last stable poltergaist gem
30
+ # Capybara.register_driver :poltergeist do |app|
31
+ # Capybara::Poltergeist::Driver.new(app, :inspector => true, timeout: 1.minute)
32
+ # end
33
+ # Capybara.javascript_driver = :poltergeist
55
34
 
56
35
  RSpec.configure do |config|
57
36
  # rspec-expectations config goes here. You can use an alternate
@@ -170,34 +149,24 @@ RSpec.configure do |config|
170
149
  # The different available types are documented in the features, such as in
171
150
  # https://relishapp.com/rspec/rspec-rails/docs
172
151
  config.infer_spec_type_from_file_location!
173
- config.before :type => :decorator do
174
- ApplicationController.new.view_context
175
- end
152
+ # config.before :type => :decorator do
153
+ # ApplicationController.new.view_context
154
+ # end
176
155
  end
177
156
 
178
- RSpec.configure do |config|
157
+ Capybara::Webkit.configure do |config|
158
+ # Enable debug mode. Prints a log of everything the driver is doing.
159
+ config.debug = false
179
160
 
180
- config.before(:suite) do
181
- DatabaseCleaner.strategy = :transaction
182
- DatabaseCleaner.clean_with(:truncation)
183
- end
161
+ # Allow pages to make requests to any URL without issuing a warning.
162
+ config.allow_unknown_urls
184
163
 
185
- config.around(:each) do |example|
186
- DatabaseCleaner.cleaning do
187
- example.run
188
- end
189
- end
164
+ # Don't raise errors when SSL certificates can't be validated
165
+ config.ignore_ssl_errors
190
166
 
191
- end
167
+ # Don't load images
168
+ config.skip_image_loading
192
169
 
193
- # Windows less than 1000px wide produce broken rendering on some pages:
194
- # https://github.com/owen2345/camaleon-cms/issues/481
195
- # Workaround: maximize the window in capybara:
196
- # https://makandracards.com/makandra/9773-how-to-start-selenium-browser-maximized-or-with-custom-window-size
197
- # http://stackoverflow.com/questions/18390071/change-default-capybara-browser-window-size
198
- RSpec.configure do |config|
199
- config.before(:each, js: true) do
200
- Capybara.page.driver.browser.manage.window.maximize rescue nil
201
- page.driver.allow_url("fonts.googleapis.com") rescue nil
202
- end
203
- end
170
+ # Raise JavaScript errors as exceptions
171
+ # config.raise_javascript_errors = true
172
+ end
@@ -3,32 +3,17 @@ require 'rails_helper'
3
3
 
4
4
  # do login for admin panel and also verify if the site was created
5
5
  # if site is not created, then create a new site
6
- def login_success
7
- if !CamaleonCms::Site.any? && !defined?($install_called)
8
- $install_called = true
9
- it "Verify Install Camaleon", js: true do
10
- visit "#{cama_root_relative_path}/admin/installers"
11
- within("#new_site") do
12
- fill_in 'site_name', :with => 'Test Site'
13
- select "Default Theme", from: "theme"
14
- end
15
- click_button 'Submit'
16
- expect(page).to have_content 'successfully'
17
-
18
- admin_sign_in(true)
19
- end
20
- else
21
- it "signs me in" do
22
- admin_sign_in
23
- end
6
+ def init_site
7
+ before(:each) do
8
+ @site = create(:site).decorate
9
+ @post = @site.the_post('sample-post').decorate
24
10
  end
25
11
  end
26
12
 
27
13
  # sign in for admin panel
28
14
  # skip: true => close the skip button for intro
29
- def admin_sign_in(close = false, user = "admin", pass = "admin123")
15
+ def admin_sign_in(user = "admin", pass = "admin123")
30
16
  visit "#{cama_root_relative_path}/admin/logout"
31
- screenshot_and_save_page
32
17
  within("#login_user") do
33
18
  fill_in 'user[username]', :with => user
34
19
  fill_in 'user[password]', :with => pass
@@ -73,6 +58,7 @@ end
73
58
 
74
59
  # return the id of the first post
75
60
  def get_tag_attr(attr = "id", pos = "first")
61
+ puts "----------------#{Cama::Site.first.decorate.the_tags.to_a.inspect}"
76
62
  res = Cama::Site.first.decorate.the_tags.decorate.send(pos).send(attr)
77
63
  fix_db
78
64
  res
@@ -80,10 +66,10 @@ end
80
66
 
81
67
  # fix for: SQLite3::BusyException: database is locked: commit transaction
82
68
  def fix_db
83
- if ActiveRecord::Base.connection.adapter_name.downcase.include?('sqlite')
84
- ActiveRecord::Base.connection.execute("END;")
85
- ActiveRecord::Base.connection.execute("BEGIN TRANSACTION;")
86
- end
69
+ # if ActiveRecord::Base.connection.adapter_name.downcase.include?('sqlite')
70
+ # ActiveRecord::Base.connection.execute("END;")
71
+ # ActiveRecord::Base.connection.execute("BEGIN TRANSACTION;")
72
+ # end
87
73
  end
88
74
 
89
75
  def pages_test