Changeset 8c82fb69f188ac11b1eb2c70bf0f70ee71c378f1
- Timestamp:
- 07/27/10 21:23:22 (6 weeks ago)
- Parents:
- 4d873e1c0c111a263ce1177d4c75ac80f32ef027
- git-committer:
- Alban Peignier <alban@tryphon.eu> / 2010-07-27T21:23:22Z+0200
- Files:
-
- 7 modified
-
app/models/stream.rb (modified) (3 diffs)
-
app/views/streams/_form.erb (modified) (1 diff)
-
app/views/streams/show.html.erb (modified) (2 diffs)
-
config/environment.rb (modified) (2 diffs)
-
config/locales/fr/stream.yml (modified) (1 diff)
-
spec/models/stream_spec.rb (modified) (3 diffs)
-
spec/views/streams/_form.erb_spec.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
app/models/stream.rb
r99b6862 r8c82fb6 8 8 validates_presence_of :name 9 9 10 attr_accessor :server, : password, :mount_point10 attr_accessor :server, :server_type, :password, :mount_point 11 11 acts_as_ip_port :port 12 validates_presence_of :server, :port, :mount_point, :password 12 validates_presence_of :server, :server_type, :port, :password 13 validates_presence_of :mount_point, :if => :icecast_server? 14 validates_inclusion_of :server_type, :in => [ :icecast2, :shoutcast ] 13 15 14 validates_format_of :mount_point, :with => %r{^[^/]} 16 validates_format_of :mount_point, :with => %r{^[^/]}, :allow_blank => true 15 17 16 18 attr_accessor :format … … 27 29 self.format ||= :vorbis 28 30 self.quality ||= 4 31 self.server_type ||= :icecast2 29 32 self.enabled = true if self.enabled.nil? 30 33 … … 56 59 def path 57 60 mount_point and mount_point.start_with?('/') ? mount_point : "/#{mount_point}" 61 end 62 63 def server_type=(server_type) 64 @server_type = server_type ? server_type.to_sym : nil 65 end 66 67 def icecast_server? 68 server_type == :icecast2 58 69 end 59 70 -
app/views/streams/_form.erb
r99b6862 r8c82fb6 5 5 6 6 <h3><%= t(".server_attributes") %></h3> 7 8 <p> 9 <%= form.label :server_type, Stream.human_attribute_name("server_type") %><br/> 10 <%= form.select :server_type, options_for_select([:icecast2, :shoutcast], @stream.server_type) %> 11 </p> 7 12 8 13 <p> -
app/views/streams/show.html.erb
r99b6862 r8c82fb6 3 3 <div class="stream description <%= @stream.presenter.status_class %>"> 4 4 <h3><%= t(".server_attributes") %></h3> 5 6 <p> 7 <%= Stream.human_attribute_name("server_type") %> : 8 <%= @stream.server_type %> 9 </p> 10 5 11 <p> 6 12 <%= Stream.human_attribute_name("server") %> : … … 13 19 </p> 14 20 15 <p> 16 <%= Stream.human_attribute_name("mount_point") %> : 17 <%= @stream.mount_point %> 18 </p> 21 <% if @stream.icecast_server? %> 22 <p> 23 <%= Stream.human_attribute_name("mount_point") %> : 24 <%= @stream.mount_point %> 25 </p> 26 <% end %> 19 27 20 28 <p> -
config/environment.rb
r5b70fb7 r8c82fb6 2 2 3 3 # Specifies gem version of Rails to use when vendor/rails is not present 4 RAILS_GEM_VERSION = '2.3. 5' unless defined? RAILS_GEM_VERSION4 RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION 5 5 6 6 # Bootstrap the Rails environment, frameworks, and default configuration … … 35 35 # config.gem "aws-s3", :lib => "aws/s3" 36 36 37 config.gem "inherited_resources", :version => "1.0. 3"37 config.gem "inherited_resources", :version => "1.0.6" 38 38 config.gem 'will_paginate', :version => '~> 2.3.11', :source => 'http://gemcutter.org' 39 39 config.gem 'delayed_job' -
config/locales/fr/stream.yml
r99b6862 r8c82fb6 8 8 related_url: URL associée 9 9 server: Serveur 10 server_type: Type de serveur 10 11 mount_point: Point de montage 11 12 password: Mot de passe -
spec/models/stream_spec.rb
r99b6862 r8c82fb6 20 20 it { should validate_presence_of :server } 21 21 it { should validate_presence_of :port } 22 it { should validate_presence_of :mount_point }23 22 it { should validate_presence_of :password } 24 23 … … 45 44 end 46 45 47 it "should use vorbis format for a new Stream" do 48 Stream.new.format.should == :vorbis 49 end 50 51 it "should use quality 4 for a new Stream" do 52 Stream.new.quality.should == 4 53 end 54 55 it "should enable a new Stream" do 56 Stream.new.should be_enabled 46 describe "for a new Stream" do 47 48 subject { Stream.new } 49 50 its(:format) { should == :vorbis } 51 its(:quality) { should == 4 } 52 it { should be_enabled } 53 its(:server_type) { should == :icecast2 } 54 55 end 56 57 58 describe "server_type" do 59 60 it { should validate_presence_of :server_type } 61 62 it "should support :icecast2 and :shoutcast" do 63 @stream.should allow_values_for :server_type, :icecast2, :shoutcast 64 @stream.should_not allow_values_for :server_type, :dummy 65 end 66 67 it "should be symbolized" do 68 @stream.server_type = "dummy" 69 @stream.server_type.should == :dummy 70 end 71 72 end 73 74 describe "mount_point" do 75 76 context "when server is an icecast server" do 77 before(:each) do 78 subject.stub :icecast_server? => true 79 end 80 it { should validate_presence_of :mount_point } 81 end 82 83 context "when server is not an icecast server" do 84 before(:each) do 85 subject.stub :icecast_server? => false 86 end 87 it { should_not validate_presence_of :mount_point } 88 end 89 57 90 end 58 91 … … 63 96 it "should support :vorbis, :mp3 and :aac" do 64 97 @stream.should allow_values_for :format, :vorbis, :mp3, :aac 65 @stream.should_not allow_values_for : dummy98 @stream.should_not allow_values_for :format, :dummy 66 99 end 67 100 -
spec/views/streams/_form.erb_spec.rb
rc3ae370 r8c82fb6 6 6 assigns[:stream] = @stream = Stream.new(:id => 1) 7 7 8 @form_builder = stub :text_field => '<input type="text"/>', :label => '<label/>', :collection_select => "<select/>", :check_box => '<input type="checkbox"/>' 8 @form_builder = stub :text_field => '<input type="text"/>', :label => '<label/>', :collection_select => "<select/>", :check_box => '<input type="checkbox"/>', :select => '<select/>' 9 9 10 10 template.stub!(:format_radio_buttons)