Skip to content

Commit

Permalink
Work on controller specs, mianly create and update. Not done yet...
Browse files Browse the repository at this point in the history
modified:   Gemfile
modified:   Gemfile.lock
modified:   app/assets/templates/home.html
modified:   app/controllers/audio_events_controller.rb
modified:   app/controllers/home_controller.rb
modified:   app/models/audio_event.rb
modified:   app/models/progress.rb
modified:   app/serializers/analysis_item_serializer.rb
modified:   app/serializers/audio_event_serializer.rb
modified:   app/serializers/audio_recording_serializer.rb
new file:   app/views/audio_events/download.csv.erb
modified:   app/views/layouts/application.html.erb
modified:   config/routes.rb
modified:   spec/controllers/analysis_items_controller_spec.rb
modified:   spec/controllers/analysis_jobs_controller_spec.rb
modified:   spec/controllers/analysis_scripts_controller_spec.rb
modified:   spec/controllers/audio_events_controller_spec.rb
modified:   spec/controllers/audio_recordings_controller_spec.rb
modified:   spec/controllers/bookmarks_controller_spec.rb
modified:   spec/controllers/permissions_controller_spec.rb
modified:   spec/controllers/photos_controller_spec.rb
modified:   spec/controllers/progresses_controller_spec.rb
modified:   spec/controllers/projects_controller_spec.rb
modified:   spec/controllers/saved_searches_controller_spec.rb
modified:   spec/controllers/sites_controller_spec.rb
modified:   spec/controllers/tags_controller_spec.rb
modified:   spec/controllers/users_controller_spec.rb
modified:   spec/factories/bookmark_factory.rb
new file:   spec/factories/common_factory.rb
modified:   spec/models/module_audio_spec.rb
modified:   spec/models/module_cache_spec.rb
modified:   spec/models/permission_spec.rb
modified:   spec/models/tag_spec.rb
new file:   spec/support/api_examples_create.rb
new file:   spec/support/api_examples_delete.rb
renamed:    spec/support/shared_api_examples.rb -> spec/support/api_examples_idempotent.rb
new file:   spec/support/api_examples_new.rb
new file:   spec/support/api_examples_update.rb
modified:   spec/support/helpers.rb
modified:   spec/support/shared_api_examples.rb
modified:   vendor/bin/install_console_audio_tools.sh
  • Loading branch information
Mark Cottman-Fields committed Jan 23, 2013
1 parent 44f6779 commit a2dcc53
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 20 deletions.
6 changes: 0 additions & 6 deletions app/assets/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ <h2>Home</h2>
<a href="/projects">Projects</a>
<a href="/sites">Sites</a>
<a href="/photos">Photos</a>
<a href="/bookmarks">Bookmarks</a>
<a href="/tags">Tags</a>
<a href="/audioEvents">Audio Events</a>
<a href="/searches/">Saved searches</a>


</p>

<h3>Audio Recordings and Annotations</h3>
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/audio_events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def create
#@audio_event.audio_event_tags.count.times { @audio_event.audio_event_tags.build }

respond_to do |format|
if @audio_event.save!
if @audio_event.save
#@audio_event.audio_event_tags.reload
format.json { render json: @audio_event, status: :created, location: @audio_event }
else
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ def index
head :not_acceptable
end
end

def whoami
head 418, :status => "I'm a teapot"
end
end
4 changes: 2 additions & 2 deletions app/models/audio_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ class AudioEvent < ActiveRecord::Base
belongs_to :audio_recording

has_many :tags, :through => :audio_event_tags, :uniq => true
#accepts_nested_attributes_for :tags
accepts_nested_attributes_for :tags

has_many :audio_event_tags
accepts_nested_attributes_for :audio_event_tags
#accepts_nested_attributes_for :audio_event_tags

# attr
attr_accessible :audio_recording_id, :end_time_seconds, :high_frequency_hertz, :is_reference,
Expand Down
6 changes: 2 additions & 4 deletions app/models/progress.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Progress < ActiveRecord::Base

# ↓ these are just keys ↓
:activity, :saved_search_id, :audio_recording_id,
:start_offset_seconds, :end_offset_seconds
:start_offset_seconds, :end_offset_seconds, :creator_id


# userstamp
Expand All @@ -24,9 +24,7 @@ class Progress < ActiveRecord::Base
scope: [:saved_search_id, :audio_recording_id,
:start_offset_seconds, :end_offset_seconds, :creator_id]

validates_presence_of :offset_list,
:activity, :saved_search_id, :audio_recording_id,
:start_offset_seconds, :end_offset_seconds, :creator_id
validates_presence_of :offset_list, :activity, :saved_search_id, :audio_recording_id, :creator_id

validates :start_offset_seconds, :presence => true, :numericality => { :greater_than_or_equal_to => 0 }
validates :end_offset_seconds, :presence => true, :numericality => { :greater_than_or_equal_to => 0 }
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/analysis_item_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class AnalysisItemSerializer < CommonAttributesSerializer
attributes :id, :worker_info, :worker_started_utc,
:worker_run_details, :status, :offset_start_seconds,
:offset_end_seconds
:offset_end_seconds, :audio_recording_id

#has_one :audio_recording

Expand Down
5 changes: 4 additions & 1 deletion app/serializers/audio_event_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ class AudioRecordingIdsSerializer < CommonAttributesSerializer
attributes :id, :uuid
end

class AudioEventTagsInAESerializer < CommonAttributesSerializer
attributes :audio_event_id, :tag_id
end


class AudioEventSerializer < CommonAttributesSerializer
attributes :id, :audio_recording_id, :end_time_seconds, :high_frequency_hertz, :is_reference,
:low_frequency_hertz, :start_time_seconds

has_many :audio_event_tags
has_many :audio_event_tags, :AudioEventTagsSerializer => AudioEventTagsInAESerializer
has_one :audio_recording, :serializer => AudioRecordingIdsSerializer


Expand Down
9 changes: 7 additions & 2 deletions app/serializers/audio_recording_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
require 'common_attributes'

class AudioRecordingInSiteSerializer < CommonAttributesSerializer
attributes :id, :name
end

class AudioRecordingSerializer < CommonAttributesSerializer
attributes :bit_rate_bps, :channels, :data_length_bytes,
attributes :id, :bit_rate_bps, :channels, :data_length_bytes,
:duration_seconds, :file_hash, :media_type, :notes,
:recorded_date, :sample_rate_hertz, :status, :uploader_id,
:site_id, :uuid, :id
:uuid

has_many :sites, :serializer => AudioRecordingInSiteSerializer
end


8 changes: 8 additions & 0 deletions app/views/audio_events/download.csv.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Annotation Id, Start Date, Start Time, End Date, End Time, Max Frequency (hz), Min Frequency (hz), Projects, Site, Audio Recording Id, Tagged by, Player link, Tag 1 Id, Tag 1 Text, Tag 1 Type, Tag 1 Is Taxanomic, Tag 2 Id, Tag 2 Text, Tag 2 Type, Tag 2 Is Taxanomic, Tag 3 Id, Tag 3 Text, Tag 3 Type, Tag 3 Is Taxanomic
<%=
CSV.generate do |csv|
@formatted_annotations.each do |annotation|
csv << annotation
end
end
%>
2 changes: 0 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
<h1><a href="/">Bioacoustic Workbench</a></h1>
<ul>
<li><a href="/projects">Browse Projects</a></li>
<li><a href="/searches">Search Recordings</a></li>
<li><a href ng-click="$reloadView()">refresh</a></li>
<li ng-controller="LoginCtrl">
<span ng-show="loggedIn">
Welcome <a href="/user/{{userData.user_id}}" title="{{friendly_name}}: {{email}}">{{email}}</a>&nbsp;&nbsp;<a href ng-click="logout()">Sign Out</a>
Expand Down
8 changes: 7 additions & 1 deletion vendor/bin/install_console_audio_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ echo "Installing audio tools"
sudo apt-get update
sudo apt-get upgrade
# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 16126D3A3E5C1192
sudo apt-get install ffmpeg mp3splt sox wavpack --fix-missing
sudo apt-get install ffmpeg mp3splt sox wavpack --fix-missing

echo "testing for audio tools"
ffmpeg -version
mp3splt -version
sox --version
wvunpack

0 comments on commit a2dcc53

Please sign in to comment.