2011-06-27 15:27:07 +00:00
|
|
|
### Theme assets
|
|
|
|
|
|
|
|
# helps create a theme asset
|
2012-04-25 19:26:02 +00:00
|
|
|
def new_plain_text_asset(name, type)
|
|
|
|
FactoryGirl.build(:theme_asset, {
|
2012-02-27 11:48:06 +00:00
|
|
|
:site => @site,
|
|
|
|
:plain_text_name => name,
|
|
|
|
:plain_text => 'Lorem ipsum',
|
|
|
|
:plain_text_type => type,
|
|
|
|
:performing_plain_text => true
|
2011-06-27 15:27:07 +00:00
|
|
|
})
|
2012-04-25 19:26:02 +00:00
|
|
|
end
|
2012-02-27 11:48:06 +00:00
|
|
|
|
2012-04-25 19:26:02 +00:00
|
|
|
def create_plain_text_asset(name, type)
|
|
|
|
asset = new_plain_text_asset(name, type)
|
2011-06-27 15:27:07 +00:00
|
|
|
asset.save!
|
|
|
|
end
|
|
|
|
|
|
|
|
# creates various theme assets
|
|
|
|
|
|
|
|
Given /^a javascript asset named "([^"]*)"$/ do |name|
|
|
|
|
@asset = create_plain_text_asset(name, 'javascript')
|
|
|
|
end
|
|
|
|
|
2012-04-25 19:26:02 +00:00
|
|
|
Given /^a javascript asset named "([^"]*)" with id "([^"]*)"$/ do |name, id|
|
|
|
|
@asset = new_plain_text_asset(name, 'javascript')
|
|
|
|
@asset.id = BSON::ObjectId(id)
|
|
|
|
@asset.save!
|
|
|
|
end
|
|
|
|
|
2011-06-27 15:27:07 +00:00
|
|
|
Given /^a stylesheet asset named "([^"]*)"$/ do |name|
|
|
|
|
@asset = create_plain_text_asset(name, 'stylesheet')
|
|
|
|
end
|
|
|
|
|
2012-04-25 19:26:02 +00:00
|
|
|
Given /^a stylesheet asset named "([^"]*)" with id "([^"]*)"$/ do |name, id|
|
|
|
|
@asset = new_plain_text_asset(name, 'stylesheet')
|
|
|
|
@asset.id = BSON::ObjectId(id)
|
|
|
|
@asset.save!
|
|
|
|
end
|
|
|
|
|
2011-08-20 09:08:37 +00:00
|
|
|
Given /^I have an image theme asset named "([^"]*)"$/ do |name|
|
2012-03-01 10:07:22 +00:00
|
|
|
@asset = FactoryGirl.create(:theme_asset, :site => @site, :source => File.open(Rails.root.join('..', 'fixtures', 'assets', '5k.png')))
|
2011-08-20 09:08:37 +00:00
|
|
|
@asset.source_filename = name
|
|
|
|
@asset.save!
|
|
|
|
end
|
|
|
|
|
2011-06-27 15:27:07 +00:00
|
|
|
# other stuff
|
|
|
|
|
2012-02-27 11:48:06 +00:00
|
|
|
# change the template
|
2012-02-28 10:25:51 +00:00
|
|
|
When /^I change the theme asset code to "([^"]*)"$/ do |plain_text|
|
|
|
|
page.evaluate_script "window.application_view.view.editor.setValue('#{plain_text}')"
|
|
|
|
end
|
2012-02-27 11:48:06 +00:00
|
|
|
|
2012-02-28 10:25:51 +00:00
|
|
|
Then /^I should see "([^"]*)" as the theme asset code$/ do |code|
|
|
|
|
find(:css, "#theme_asset_plain_text").value.should == code
|
2011-08-20 09:08:37 +00:00
|
|
|
end
|
|
|
|
|
2012-03-01 10:07:22 +00:00
|
|
|
Then /^I should see a delete link$/ do
|
|
|
|
page.has_css?(".box ul li .more a.remove").should be_true
|
2011-08-20 09:08:37 +00:00
|
|
|
end
|
|
|
|
|
2012-03-01 10:07:22 +00:00
|
|
|
Then /^I should not see a delete link$/ do
|
|
|
|
page.has_css?(".box ul li .more a.remove").should be_false
|
2011-08-20 09:08:37 +00:00
|
|
|
end
|