Skip to content

Commit

Permalink
Removed all imported related functionality from the create action alo…
Browse files Browse the repository at this point in the history
…ng with the respective specs
  • Loading branch information
baphled committed Jul 28, 2010
1 parent 5d1f7b8 commit 10c05ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 95 deletions.
44 changes: 14 additions & 30 deletions app/controllers/features_controller.rb
Expand Up @@ -6,6 +6,7 @@ class FeaturesController < ApplicationController
before_filter :find_features_stories, :only => [:show, :update, :stories]
before_filter :find_tag

# after_filter :find_features_stories, :only => [:sync]
def index
@features = Feature.paginate(:page => params[:page],:per_page => 5)
respond_to do |format|
Expand All @@ -29,24 +30,9 @@ def create
@feature = Feature.new(params[:feature])
respond_to do |format|
if @feature.save
find_features_stories
if "Import" == params[:commit]
@project = Project.find(params[:current_project_id])
@imported = @project.import_features
if @imported.empty?
flash[:notice] = "No more features to import"
format.html { redirect_to :back }
format.js { render "index.rjs" }
else
flash[:notice] = "Feature: #{@feature.title}, was imported"
format.html { redirect_to :back }
format.js { render "import.rjs" }
end
else
flash[:notice] = "Feature: #{@feature.title}, was created"
format.html { redirect_to @feature }
format.js { render "create.rjs" }
end
flash[:notice] = "Feature: #{@feature.title}, was created"
format.html { redirect_to @feature }
format.js { render "create.rjs" }
else
format.js { render :action => "edit" }
format.html { render :action => "edit" }
Expand All @@ -59,18 +45,16 @@ def sync
respond_to do |format|
if @feature.save
find_features_stories
if "Import" == params[:commit]
@project = Project.find(params[:current_project_id])
@imported = @project.import_features
if @imported.empty?
flash[:notice] = "No more features to import"
format.html { redirect_to :back }
format.js { render "index.rjs" }
else
flash[:notice] = "Feature: #{@feature.title}, was imported"
format.html { redirect_to :back }
format.js { render "import.rjs" }
end
@project = Project.find(params[:current_project_id])
@imported = @project.import_features
if @imported.empty?
flash[:notice] = "No more features to import"
format.html { redirect_to :back }
format.js { render "index.rjs" }
else
flash[:notice] = "Feature: #{@feature.title}, was imported"
format.html { redirect_to :back }
format.js { render "import.rjs" }
end
else
format.js { render :action => "edit" }
Expand Down
65 changes: 0 additions & 65 deletions spec/controllers/features_controller_spec.rb
Expand Up @@ -36,71 +36,6 @@ def mock_feature(stubs={})
@feature.save.should_not eql true
end
end

context "saving an imported feature" do
before(:each) do
@project = Project.make
request.env["HTTP_REFERER"] = import_project_path @project
assigns[:current_project_id] = @project.id
@feature.stub!(:save).and_return true
end

it "redirects to the import page" do
post :create, {:commit => 'Import', :current_project_id => @project.id}
response.should redirect_to import_project_path(@project)
end

context "importing over XHR" do

it "does not redirects to the import page" do
xhr :post, :create, {:commit => 'Import', :current_project_id => @project.id}
response.should_not redirect_to import_project_path(@project)
end

context "more features to import" do
before(:each) do
@project.stub!(:features_to_import?).and_return true
xhr :post, :create, {:commit => 'Import', :current_project_id => @project.id}
end

it "finds the project the feature was imported from" do
@feature.stub!(:find_by_project_id).and_return Project.first
end

it "renders the import RJS file" do
response.should render_template "import.rjs"
end

it "displays a message stating the feature has been imported" do
flash[:notice].should contain "Feature: #{@feature.title}, was imported"
end
end

context "no more features to import" do
before(:each) do
@project = Project.make
@project.stub!(:import_features).and_return []
Project.stub!(:find).and_return @project
xhr :post, :create, {:commit => 'Import', :current_project_id => @project.id}
end

it "renders the project RJS file" do
response.should render_template "index.rjs"
end

it "displays a notice stating that there are no more features to import" do
flash[:notice].should contain "No more features to import"
end

it "displays the features information" do
pending "Need to finish functionality" do
response.should have_selector :h3, :content => 'Feature Info'
end
end
end

end
end
end

describe "POST, sync" do
Expand Down

0 comments on commit 10c05ea

Please sign in to comment.