diff options
| author | Marc Florisson | 2012-06-01 12:20:57 +0200 |
|---|---|---|
| committer | Marc Florisson | 2012-06-01 12:20:57 +0200 |
| commit | ee866a45955bac5cef7a8bdec58f86ffcb7cb702 (patch) | |
| tree | e66d3da0e628034afc362b524b52a1a71977f4ff /spec | |
| parent | 7fd20ad1409398e06fb1167332c57b4ac4c9aadc (diff) | |
| parent | 7082d66ec221aee194d64a17ab5d21eb2955f419 (diff) | |
| download | chouette-core-ee866a45955bac5cef7a8bdec58f86ffcb7cb702.tar.bz2 | |
Merge branch 'master' of chouette.dryade.priv:/srv/git/chouette2
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/factories.rb | 10 | ||||
| -rw-r--r-- | spec/fixtures/neptune.zip | bin | 0 -> 4904 bytes | |||
| -rw-r--r-- | spec/models/import_log_message_spec.rb | 16 | ||||
| -rw-r--r-- | spec/models/import_spec.rb | 32 | ||||
| -rw-r--r-- | spec/views/connection_links/show.html.erb_spec.rb | 2 | ||||
| -rw-r--r-- | spec/views/lines/show.html.erb_spec.rb | 2 | ||||
| -rw-r--r-- | spec/views/networks/show.html.erb_spec.rb | 2 | ||||
| -rw-r--r-- | spec/views/routes/show.html.erb_spec.rb | 2 | ||||
| -rw-r--r-- | spec/views/stop_areas/edit.html.erb_spec.rb | 2 | ||||
| -rw-r--r-- | spec/views/stop_areas/show.html.erb_spec.rb | 2 |
10 files changed, 63 insertions, 7 deletions
diff --git a/spec/factories.rb b/spec/factories.rb index b77102321..c5c1c0ff0 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -11,4 +11,14 @@ FactoryGirl.define do f.password_confirmation "secret" end + factory :import do |f| + f.resources { Rack::Test::UploadedFile.new 'spec/fixtures/neptune.zip', 'application/zip', false } + f.association :referential + end + + factory :import_log_message do |f| + f.association :import + f.sequence(:key) { "key_#{n}" } + end + end diff --git a/spec/fixtures/neptune.zip b/spec/fixtures/neptune.zip Binary files differnew file mode 100644 index 000000000..86b688b51 --- /dev/null +++ b/spec/fixtures/neptune.zip diff --git a/spec/models/import_log_message_spec.rb b/spec/models/import_log_message_spec.rb new file mode 100644 index 000000000..dab951255 --- /dev/null +++ b/spec/models/import_log_message_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe ImportLogMessage do + + describe "#attributes" do + + subject { create :import_log_message } + + it "should read json stored in database" do + subject.update_attribute :arguments, { "key" => "value"} + subject.raw_attributes.should == { "key" => "value"}.to_json + end + + end + +end diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 734445b8b..f307b59db 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -1,7 +1,37 @@ require 'spec_helper' describe Import do + + subject { create :import } + + RSpec::Matchers.define :be_log_message do |expected| + match do |actual| + actual and expected.all? { |k,v| actual[k.to_s] == v } + end + end - + describe "#import" do + + before(:each) do + subject.stub :loader => mock(:import => true) + end + + it "should create a ImportLogmessage :started when started" do + subject.import + subject.log_messages.first.should be_log_message(:key => "started") + end + + it "should create a ImportLogmessage :completed when completed" do + subject.import + subject.log_messages.last.should be_log_message(:key => "completed") + end + + it "should create a ImportLogmessage :failed when failed" do + subject.loader.stub(:import).and_raise("import failed") + subject.import + subject.log_messages.last.should be_log_message(:key => "failed") + end + + end end diff --git a/spec/views/connection_links/show.html.erb_spec.rb b/spec/views/connection_links/show.html.erb_spec.rb index 8a03f5339..80d3adfb6 100644 --- a/spec/views/connection_links/show.html.erb_spec.rb +++ b/spec/views/connection_links/show.html.erb_spec.rb @@ -4,7 +4,7 @@ describe "/connection_links/show" do let!(:referential) { assign(:referential, create(:referential)) } let!(:connection_link) { assign(:connection_link, create(:connection_link)) } - let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } + let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>'.html_safe)) } it "should render h2 with the connection_link name" do render diff --git a/spec/views/lines/show.html.erb_spec.rb b/spec/views/lines/show.html.erb_spec.rb index 42261005a..f77722672 100644 --- a/spec/views/lines/show.html.erb_spec.rb +++ b/spec/views/lines/show.html.erb_spec.rb @@ -5,7 +5,7 @@ describe "/lines/show" do let!(:referential) { assign :referential, create(:referential) } let!(:line) { assign :line, create(:line) } let!(:routes) { assign :routes, Array.new(2) { create(:route, :line => line) }.paginate } - let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } + let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>'.html_safe)) } it "should render h2 with the line name" do render diff --git a/spec/views/networks/show.html.erb_spec.rb b/spec/views/networks/show.html.erb_spec.rb index 9c05fe4aa..08ecdd95d 100644 --- a/spec/views/networks/show.html.erb_spec.rb +++ b/spec/views/networks/show.html.erb_spec.rb @@ -4,7 +4,7 @@ describe "/networks/show" do let!(:referential) { assign(:referential, create(:referential)) } let!(:network) { assign(:network, create(:network)) } - let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } + let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>'.html_safe)) } it "should render h2 with the network name" do render diff --git a/spec/views/routes/show.html.erb_spec.rb b/spec/views/routes/show.html.erb_spec.rb index 5fa7485b7..2f39adb9a 100644 --- a/spec/views/routes/show.html.erb_spec.rb +++ b/spec/views/routes/show.html.erb_spec.rb @@ -6,7 +6,7 @@ describe "/routes/show" do let!(:line) { assign :line, create(:line) } let!(:route) { assign :route, create(:route, :line => line) } let!(:stop_points) { assign :stop_points, Array.new(2) { create(:stop_point) }.paginate } - let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } + let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>'.html_safe)) } it "should render h2 with the route name" do render diff --git a/spec/views/stop_areas/edit.html.erb_spec.rb b/spec/views/stop_areas/edit.html.erb_spec.rb index c3b89918d..17e9ca104 100644 --- a/spec/views/stop_areas/edit.html.erb_spec.rb +++ b/spec/views/stop_areas/edit.html.erb_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe "/stop_areas/edit" do let!(:referential) { assign(:referential, create(:referential)) } let!(:stop_area) { assign(:stop_area, create(:stop_area)) } - let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } + let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>'.html_safe)) } describe "test" do it "should render h2 with the group name" do diff --git a/spec/views/stop_areas/show.html.erb_spec.rb b/spec/views/stop_areas/show.html.erb_spec.rb index 443a37232..b4be2c5e0 100644 --- a/spec/views/stop_areas/show.html.erb_spec.rb +++ b/spec/views/stop_areas/show.html.erb_spec.rb @@ -4,7 +4,7 @@ describe "/stop_areas/show" do let!(:referential) { assign :referential, create(:referential) } let!(:stop_area) { assign :stop_area, create(:stop_area) } - let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } + let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>'.html_safe)) } it "should render h2 with the stop_area name" do render |
