Permalink
Browse files

refactor tests

  • Loading branch information...
1 parent bab9fd0 commit e071a1deb373713607d6299e49d3f0bd4caa7235 @mrbrdo committed Nov 16, 2012
View
@@ -104,19 +104,14 @@ GEM
rdoc (3.12)
json (~> 1.4)
rmagick (2.13.1)
- rspec (2.10.0)
- rspec-core (~> 2.10.0)
- rspec-expectations (~> 2.10.0)
- rspec-mocks (~> 2.10.0)
- rspec-core (2.10.1)
- rspec-expectations (2.10.0)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
- rspec-mocks (2.10.1)
- rspec-rails (2.10.1)
- actionpack (>= 3.0)
- activesupport (>= 3.0)
- railties (>= 3.0)
- rspec (~> 2.10.0)
+ rspec-mocks (2.11.3)
slop (2.4.4)
spork (0.9.2)
sprockets (2.1.3)
@@ -143,7 +138,6 @@ DEPENDENCIES
has_moderated!
pry
rmagick
- rspec
- rspec-rails
+ rspec (>= 2.11)
spork
sqlite3
@@ -19,8 +19,7 @@ Gem::Specification.new do |s|
s.add_dependency "rails", ">=3.0.0"
s.add_development_dependency 'sqlite3'
- s.add_development_dependency 'rspec'
- s.add_development_dependency 'rspec-rails'
+ s.add_development_dependency 'rspec', ">=2.11"
s.add_development_dependency 'pry'
s.add_development_dependency 'rmagick'
s.add_development_dependency 'growl'
@@ -1,20 +1,14 @@
require 'spec_helper'
-def reload_models
- crazy_models.reset
- crazy_models.with_helpers &block if block_given?
- crazy_models
-end
-
-describe Photo do
+describe "Photo" do
before(:each) do
FileUtils.rm_rf(TEMPDIR) # remove temp dir
FileUtils.rm_rf(File.expand_path("../../tmp/uploads", __FILE__)) # remove uploads dir
end
context "create moderated:" do
before do
- reload_models.photo {
+ dynamic_models.photo {
mount_uploader :avatar, GenericUploader
has_moderated_create
send :include, HasModerated::CarrierWave
@@ -52,7 +46,7 @@ def reload_models
context "not moderated:" do
before do
- reload_models.photo {
+ dynamic_models.photo {
mount_uploader :avatar, GenericUploader
}
end
@@ -71,7 +65,7 @@ def reload_models
context "update moderated:" do
before do
- reload_models.photo {
+ dynamic_models.photo {
mount_uploader :avatar, GenericUploader
send :include, HasModerated::CarrierWave
has_moderated_carrierwave_field :avatar
@@ -133,17 +127,17 @@ def reload_models
context "moderated as association to has_moderated_create:" do
before do
- reload_models.task {
- has_many :renamed_subtasks, :class_name => subtask_class_name, :foreign_key => task_fk
- has_many :photos, :class_name => photo_class_name, :foreign_key => "parentable_id"
+ dynamic_models.task {
+ has_many :renamed_subtasks, :class_name => "Subtask", :foreign_key => "task_id"
+ has_many :photos, :class_name => "Photo", :foreign_key => "parentable_id"
has_moderated_create :with_associations => [:photos, :renamed_subtasks]
}.subtask {
- belongs_to :task, :class_name => task_class_name
+ belongs_to :task, :class_name => "Task"
}.photo {
mount_uploader :avatar, GenericUploader
send :include, HasModerated::CarrierWave
has_moderated_carrierwave_field :avatar
- belongs_to :task, :class_name => task_class_name, :foreign_key => "parentable_id"
+ belongs_to :task, :foreign_key => "parentable_id"
}
end
@@ -196,7 +190,7 @@ def reload_models
context "moderation preview" do
it "should show the temporary file as the photo" do
- reload_models.photo {
+ dynamic_models.photo {
mount_uploader :avatar, GenericUploader
send :include, HasModerated::CarrierWave
has_moderated_carrierwave_field :avatar
@@ -218,7 +212,7 @@ def reload_models
end
it "should show the temporary file as the photo (create moderation)" do
- reload_models.photo {
+ dynamic_models.photo {
mount_uploader :avatar, GenericUploader
send :include, HasModerated::CarrierWave
has_moderated_create
@@ -239,7 +233,7 @@ def reload_models
end
it "should not move image to uploads when calling save on live_preview" do
- reload_models.photo {
+ dynamic_models.photo {
mount_uploader :avatar, GenericUploader
send :include, HasModerated::CarrierWave
has_moderated_create
@@ -259,7 +253,7 @@ def reload_models
end
it "should not move image to uploads when calling save on preview" do
- reload_models.photo {
+ dynamic_models.photo {
mount_uploader :avatar, GenericUploader
send :include, HasModerated::CarrierWave
has_moderated_create
@@ -277,14 +271,14 @@ def reload_models
end
it "should show the temporary file as the photo (create assoc moderation)" do
- reload_models.task {
- has_many :photos, :class_name => photo_class_name, :foreign_key => "parentable_id"
+ dynamic_models.task {
+ has_many :photos, :class_name => "Photo", :foreign_key => "parentable_id"
has_moderated_create :with_associations => [:photos]
}.photo {
mount_uploader :avatar, GenericUploader
send :include, HasModerated::CarrierWave
has_moderated_carrierwave_field :avatar
- belongs_to :task, :class_name => task_class_name, :foreign_key => "parentable_id"
+ belongs_to :task, :foreign_key => "parentable_id"
}
photo_file = carrierwave_test_photo
@@ -303,16 +297,16 @@ def reload_models
end
it "should show the temporary file as the photo (assoc moderation)" do
- reload_models.task {
- has_many :photos, :class_name => photo_class_name, :foreign_key => "parentable_id"
+ dynamic_models.task {
+ has_many :photos, :class_name => "Photo", :foreign_key => "parentable_id"
has_moderated_association :photos
}.photo {
mount_uploader :avatar, GenericUploader
send :include, HasModerated::CarrierWave
has_moderated_carrierwave_field :avatar
- belongs_to :task, :class_name => task_class_name, :foreign_key => "parentable_id"
+ belongs_to :task, :foreign_key => "parentable_id"
}
-
+
photo_file = carrierwave_test_photo
task = Task.new
photo = task.photos.build :avatar => photo_file
@@ -329,7 +323,7 @@ def reload_models
end
it "should display preview of photo versions correctly" do
- reload_models.photo {
+ dynamic_models.photo {
mount_uploader :avatar, GenericUploader
send :include, HasModerated::CarrierWave
has_moderated_carrierwave_field :avatar
Oops, something went wrong.

0 comments on commit e071a1d

Please sign in to comment.