redditor 0.1.12 → 0.1.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bba15b3e99f1e69bfa1ab7de2bb7a6865a2b942b
4
- data.tar.gz: 97945de1614e7c854ff8d8d510dcd340bfa1601e
3
+ metadata.gz: 04ff6d5b84a9af7e952457bf4152e61e452cfd45
4
+ data.tar.gz: 14883d81bbe9394caf1dc7df81389e9d6951d1a3
5
5
  SHA512:
6
- metadata.gz: 6701646c7c6fad6c0aa50244d81e87ee233681961d9c2a68be1f6aa5eb4ba97b4904127f52bb462009a3ce0c1124939e281fdaea916fd2f230250d134307b55f
7
- data.tar.gz: ea79fa075d9d566e4770cdfdbd8cff8419d33a143b552cf660a9e803685105f6dc139bfaaa194105dd6404b4e6bbd4b19f54e606d20ff52b7f7ee893c4f5737f
6
+ metadata.gz: 45c34e057d72a2ede65fc11562fdc55facaf642c371c6eb28aa62877cbf1bc3812429aef85c51a1530a327f46c1f9d9346fa7eed8dd037d0a2f4f83c1d300835
7
+ data.tar.gz: 996b6f0500b2900fdb13a16cb95f1242111fef407425ae5a960ac16baffa919cff86697310f61b38ab0c148acca0d7ce365582f5fd42b94db0f01126825d265c
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
- script: bundle exec rspec
1
+ script: CAPYBARA_WAIT_TIME=60 bundle exec rspec
2
2
  language: ruby
3
3
  notifications:
4
4
  email: false
@@ -15,8 +15,8 @@ class Redditor::Admin::ImagesController < Redditor::Admin::BaseController
15
15
 
16
16
  def create
17
17
  @slider_block = @page.slider_blocks.find(params[:slider_block_id])
18
- @image = @slider_block.images.build(src: params[:file])
19
- if @image.save
18
+ @image = @slider_block.images.build
19
+ if @image.update_attributes(src: params[:file])
20
20
  render "redditor/admin/slider_block_image"
21
21
  end
22
22
  end
@@ -4,16 +4,15 @@ module Redditor
4
4
  class Image < ActiveRecord::Base
5
5
  self.table_name = "redditor_images"
6
6
 
7
- after_initialize :default_values # чтобы файл загружался, пока через html5 не передаем позицию
7
+ after_initialize :set_default_values # чтобы файл загружался, пока через html5 не передаем позицию
8
8
 
9
- # attr_accessible :descr, :imageable_id, :imageable_type, :position, :src
10
9
  attr_accessor :object_id
11
10
 
12
11
  mount_uploader :src, RedditorUploader
13
12
 
14
- validates :src, :presence => true
13
+ validates :src, presence: true
15
14
 
16
- belongs_to :imageable, :polymorphic => true
15
+ belongs_to :imageable, polymorphic: true, touch: true
17
16
 
18
17
  default_scope -> { order(:position) }
19
18
 
@@ -22,7 +21,7 @@ module Redditor
22
21
  end
23
22
 
24
23
  private
25
- def default_values
24
+ def set_default_values
26
25
  self.position ||= 1000
27
26
  end
28
27
  end
@@ -4,9 +4,7 @@ module Redditor
4
4
  class Page < ActiveRecord::Base
5
5
  self.table_name = "redditor_pages"
6
6
 
7
- # attr_accessible :pageable_id, :pageable_type, :metakey, :metadesc, :text_blocks_attributes, :video_blocks_attributes, :images_attributes, :slider_blocks_attributes
8
-
9
- belongs_to :pageable, polymorphic: true
7
+ belongs_to :pageable, polymorphic: true, touch: true
10
8
  has_many :text_blocks, class_name: "Redditor::TextBlock"
11
9
  has_many :video_blocks, class_name: "Redditor::VideoBlock"
12
10
  has_many :images, as: :imageable, class_name: "Redditor::Image"
@@ -4,11 +4,10 @@ module Redditor
4
4
  class SliderBlock < ActiveRecord::Base
5
5
  self.table_name = "redditor_slider_blocks"
6
6
 
7
- # attr_accessible :page_id, :position
8
7
  attr_accessor :object_id, :kind
9
8
 
10
- belongs_to :page, :class_name => "Redditor::Page"
11
- has_many :images, :as => :imageable, :dependent => :destroy
9
+ belongs_to :page, class_name: "Redditor::Page", touch: true
10
+ has_many :images, as: :imageable, dependent: :destroy
12
11
  accepts_nested_attributes_for :images
13
12
 
14
13
  def self.model_name
@@ -4,14 +4,13 @@ module Redditor
4
4
  class TextBlock < ActiveRecord::Base
5
5
  self.table_name = "redditor_text_blocks"
6
6
 
7
- # attr_accessible :body, :page_id, :position, :translations_attributes
8
7
  attr_accessor :object_id
9
8
 
10
- belongs_to :page, :class_name => "Redditor::Page"
9
+ belongs_to :page, class_name: "Redditor::Page", touch: true
11
10
 
12
11
  default_scope -> { order(:position) }
13
12
 
14
- validates :position, :body, :presence => true
13
+ validates :position, :body, presence: true
15
14
 
16
15
  def self.model_name
17
16
  ActiveModel::Name.new(self, nil, 'TextBlock')
@@ -13,12 +13,11 @@ module Redditor
13
13
  class VideoBlock < ActiveRecord::Base
14
14
  self.table_name = "redditor_video_blocks"
15
15
 
16
- # attr_accessible :height, :page_id, :position, :width, :youtube
17
16
  attr_accessor :object_id
18
17
 
19
- validates :youtube, :length => { :is => 11 }, :youtube => true
18
+ validates :youtube, length: { is: 11 }, youtube: true
20
19
 
21
- belongs_to :page, :class_name => "Redditor::Page"
20
+ belongs_to :page, class_name: "Redditor::Page", touch: true
22
21
 
23
22
  def self.model_name
24
23
  ActiveModel::Name.new(self, nil, 'VideoBlock')
@@ -22,7 +22,8 @@ class RedditorUploader < CarrierWave::Uploader::Base
22
22
  end
23
23
 
24
24
  version :show do
25
- process :resize_to_fill => [600, 400]
25
+ process :resize_to_fill => [960, 640], :if => :is_slider?
26
+ process :resize_to_limit => [960, 3000], :if => :is_image?
26
27
  end
27
28
 
28
29
  # Provide a default URL as a default if there hasn't been a file uploaded:
@@ -42,6 +43,17 @@ class RedditorUploader < CarrierWave::Uploader::Base
42
43
  # process :scale => [50, 50]
43
44
  # end
44
45
 
46
+
47
+ # Для того чтобы можно было использовать эти методы ввиде условий необходимо,
48
+ # чтобы изображение сохранялось через update_attributes вместо save
49
+ def is_slider? picture
50
+ model.imageable_type == "Redditor::SliderBlock"
51
+ end
52
+
53
+ def is_image? picture
54
+ model.imageable_type == "Redditor::Page"
55
+ end
56
+
45
57
  # Add a white list of extensions which are allowed to be uploaded.
46
58
  # For images you might use something like this:
47
59
  # def extension_white_list
@@ -1,3 +1,3 @@
1
1
  module Redditor
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.14"
3
3
  end
@@ -19,6 +19,8 @@ module Dummy
19
19
  g.template_engine :haml
20
20
  end
21
21
 
22
+ I18n.enforce_available_locales = false
23
+
22
24
  # I18n.enforce_available_locales = true
23
25
 
24
26
  # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
@@ -23,13 +23,13 @@ describe "Text block" do
23
23
  find(".redditor__textarea").set("test text block")
24
24
  submit
25
25
  show_text_area
26
- expect(page.find(".redditor__textarea").value).to have_content "test text block"
26
+ wait_until { expect(page.find(".redditor__textarea").value).to have_content "test text block" }
27
27
  end
28
28
 
29
29
  it "Shows validation error if text block content is empty", type: :feature, js: true do
30
30
  add_block
31
31
  submit
32
- expect(page).to have_content "can't be blank"
32
+ wait_until { expect(page).to have_content "can't be blank" }
33
33
  end
34
34
 
35
35
  it "Deletes text block", type: :feature, js: true do
@@ -42,7 +42,7 @@ describe "Text block" do
42
42
  rescue
43
43
  nil
44
44
  end
45
- expect(text_value).to eq nil
45
+ wait_until { expect(text_value).to eq nil }
46
46
  end
47
47
 
48
48
  it "Saves text block to article on save button", type: :feature, js: true do
@@ -52,6 +52,6 @@ describe "Text block" do
52
52
  save_block
53
53
  visit_article
54
54
  show_text_area
55
- expect(page.find(".redditor__textarea").value).to have_content "test text block"
55
+ wait_until { expect(page.find(".redditor__textarea").value).to have_content "test text block" }
56
56
  end
57
57
  end
@@ -20,13 +20,13 @@ describe "Video block" do
20
20
  add_block
21
21
  page.find(".video-block-input").set("1"*11)
22
22
  submit
23
- expect(page.find("iframe").nil?).to eq false
23
+ wait_until { expect(page.find("iframe").nil?).to eq false }
24
24
  end
25
25
 
26
26
  it "Shows validation error if youtube block url is empty or invalid", type: :feature, js: true do
27
27
  add_block
28
28
  submit
29
- expect(page.find(".errors")).to have_content "is the wrong length"
29
+ expect(page).to have_content "is the wrong length"
30
30
  end
31
31
 
32
32
  it "Deletes video block", type: :feature, js: true do
@@ -39,7 +39,7 @@ describe "Video block" do
39
39
  rescue
40
40
  nil
41
41
  end
42
- expect(video_frame).to eq nil
42
+ wait_until { expect(video_frame).to eq nil }
43
43
  end
44
44
 
45
45
  it "Saves video block to article on save button", type: :feature, js: true do
@@ -47,6 +47,6 @@ describe "Video block" do
47
47
  page.find(".video-block-input").set("1"*11)
48
48
  save_block
49
49
  visit_article
50
- expect(page.find("iframe").nil?).to eq false
50
+ wait_until { expect(page.find("iframe").nil?).to eq false }
51
51
  end
52
52
  end
data/spec/spec_helper.rb CHANGED
@@ -14,8 +14,17 @@ require 'capybara/rails'
14
14
  require 'capybara/rspec'
15
15
  require 'capybara/poltergeist'
16
16
 
17
+ Capybara.default_wait_time = ENV['CAPYBARA_WAIT_TIME'].present? ? ENV['CAPYBARA_WAIT_TIME'].to_i : 5
18
+
19
+ Capybara.register_driver :poltergeist do |app|
20
+ Capybara::Poltergeist::Driver.new(app, {
21
+ debug: false,
22
+ phantomjs_options: ['--load-images=no', '--disk-cache=false'],
23
+ js_errors: false
24
+ })
25
+ end
26
+
17
27
  Capybara.javascript_driver = :poltergeist
18
- Capybara.default_wait_time = 10
19
28
 
20
29
  # Requires supporting ruby files with custom matchers and macros, etc,
21
30
  # in spec/support/ and its subdirectories.
@@ -46,9 +55,6 @@ RSpec.configure do |config|
46
55
 
47
56
  config.include FactoryGirl::Syntax::Methods
48
57
 
49
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
50
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
51
-
52
58
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
53
59
  # examples within a transaction, remove the following line or assign false
54
60
  # instead of true.
@@ -65,3 +71,11 @@ RSpec.configure do |config|
65
71
  # --seed 1234
66
72
  config.order = "random"
67
73
  end
74
+
75
+ def wait_until
76
+ require "timeout"
77
+ Timeout.timeout(Capybara.default_wait_time) do
78
+ sleep(0.1) until value = yield
79
+ value
80
+ end
81
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Bovykin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-03 00:00:00.000000000 Z
12
+ date: 2014-03-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -308,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
308
308
  version: '0'
309
309
  requirements: []
310
310
  rubyforge_project:
311
- rubygems_version: 2.0.6
311
+ rubygems_version: 2.0.3
312
312
  signing_key:
313
313
  specification_version: 4
314
314
  summary: Page editor